103 points · by KerryBeetge · 2y ago · 61 comments
https://www.jetbrains.com/help/inspectopedia/SuspiciousNameC...
I thought it was so sweet that someone had thought of this very specific possible mistake and warned me about it to save me a little bit of time and trouble.
(Maybe not this exact one since it was in JS not Java I believe, but the same idea)
You know, I read stuff like this and I wonder if anybody has thought maybe those things jeopardizing code quality should be discouraged as opposed to adding yet-another-tool.
It's not like people are perfect code developers.
It can be discouraged, but people will still use it, so helping is still good.
Plus it helps non AI use cases at same time
Note, I basically have scripted the same functionality as Qodana for our CI, but using the already existing capabilities of the IDE: https://github.com/rwth-i6/returnn/blob/master/tests/pycharm...
This script generates exactly the same warnings as the IDE does.
It downloads some PyCharm Community version and installs it.
It uses the bin/inspect.sh tool which is provided by the IDE.
The IDE bin/inspect.sh needs an existing PyCharm project (all the XML files etc), so this script creates the project files automatically.
This also needs the Python stubs, so this script can create those as well, in the same way the IDE would create them, or alternatively it can download them (I created them in advance for some PyCharm versions).
But then, bin/inspect.sh does not generate all the warnings you see in the IDE. The IDE additionally runs pycodestyle, and so I do the same in the script.
So, as you see, it took a bit of effort to get to all that within the CI, but now it works and I get the same warnings as in the IDE.
https://www.jetbrains.com/help/qodana/pricing.html#license-c...
At present, OSS Java libraries can use Qodana Community, but OSS .NET libraries can't.
It's completely from scratch through the whole project, every time. Maybe I could do it more cleverly and cache the last state somehow and only check changes files or so. But I wanted to keep that logic simple.
Neovim will let you configure your env to provide 90 percent of what an ide will do.
The 10 percent isnt "missing" its just going to be very different...
See how the other half lives and you might find some features you like and bring back home. You might find yourself running vim in pycharm ;)
It'll also become as slow as an IDE, though. I think it's the Arch Linux (or maybe the Gentoo) of IDEs, where you have to know and configure every subcomponent of your IDE yourself.
I have tweaked my Neovim for small code snippets where a full IDE is overkill, but I can't be bothered to turn it into a full IDE like some others do.
https://github.com/JetBrains/ideavim
Or you can waste months pissing around with Vim plugins to create a poor mans IDE out of sticks and stones like a caveman.
As someone who crosses those boundaries I can tell you that you're dead wrong.
Im happy to sit down and write code in something like Goland. Im happy to pick pycharm to work on a LARGE python code base. But the moment that I need to deal with a JS spa, legacy code (python, ruby) and go im probably NOT going to pick intelij.
Sorry but IntelliJ is just as much plugin nonsense anything else and sometimes your going to go backwards just to get things working: https://youtrack.jetbrains.com/issue/PY-70729/?_ga=2.1643681...
"tinkering with your vim plugins" is "tinkering with your Intellij plugins"... both involve search engines and RTFM, the former has more choice and a bit more downloading but the transition in either direction would amount to the same loss in productivity.
And I have played with VS code as well (and it too has its uses).
The only editor I dont like, is Emacs, and not because it is BAD but because you will spend more time tinkering with it than working.
I just use VSCode for most things, or nvim if I want to edit something very specific that doesn't require much navigation between files. I'm not a huge fan of my editor annoying me with stuff all the time, but I'm wondering if I'm missing out.
The type of errors are type checking errors.
import re
if re.match(r'[aoeui', sys.argv[1]):
print('ok!')
is a red error in the ide because it understands regex syntax, and similar if it can either prove what the syntax is (based on its position, as seen in that re.match), or in all cases one can annotate the string literal to have it help you: # language=json
not_json = """
{"oops:true}
"""
json.loads(not_json)
is similarly marked as red because that's not jsonit's turtles all the way down:
# language=yaml
gitlab_yaml = """
stages:
- build
my build:
image: docker.io/library/busybox
after_cript:
# language=sh
- |
if true; then
echo "awesome"
fi
"""
spots the suspicious "after_cript" (in yellow, because it cannot prove it's wrong, just suspicious) and then it also highlights the embedded shell script in the embedded yaml string literalRegrettably, it doesn't seem to run the shell validity checks on injected shell scripts, but I think that's a bug and not a limitation of the platform
let see = someOb.comments;
it tells me I have the error : "Unresolved Variable 'comments' ".
But the error goes away if I rewrite it as: let see = someOb ['comments'];
Why is that?Much easier to interpolate the hardcoded token rather than a string...despite the string being a final string and not some concatenation or dynamic value
However, it's a common typed-javascript idiom to use string-indexing when you're probing a value of unknown type. Even Typescript has settings to accept this.
I guess my question is, how can I make the
ob.something
NOT be (listed as) an error? When is it not an error (according to WebStorm linter)?(EDIT: should have RTFA)
I haven't used it, but thIs seems to be what their Qodana product is for: https://www.jetbrains.com/qodana/
Which is literally what the post is about...
https://www.jetbrains.com/qodana/
Edited: Oops, should have refreshed. Someone beat me to it
Well I’ll just hedge and say that it wasn’t obvious to the three of us how to get an in-your-face warning.
[1] EDIT: I realize now that my brain for some reason thought that “in your face” would immediately translate to everybody else as “fail the build”. What a drunken (but not drunk though) mistake.
Maybe this would suit you?
https://www.jetbrains.com/help/idea/code-inspection.html#acc...
That’s what I meant (edited now). I want compilation to fail. Or whatever “CI” is.
We didn’t find a way to promote inspections to some kind of static analysis run.