I'm using IntelliJ IDEA 13 to edit my Grails application and while it is very smart about some things, it doesn't display syntax errors very well.
E.g., I can misspell a property or method name, but IntelliJ shows a mellow barely noticeable black underline in code with the on-hover popup saying Cannot resolve symbol 'foobar'
.
If I go into View -> Tool Windows -> Messages
then it doesn't even show this issue, even after Build -> Rebuild project
(although it shows some useless deprecation messages in 3rd party plugin code).
How do I find a view showing all these potential issues so I can review them?
Edit - @lukelazarovic is totally right, I fixed a significant misconception about how Groovy/Grails works. Also question was partially covered by:
Will groovy (grails) give you compile time checking like java?
In the Project tool window, right-click the project and from the context menu, select Add Framework Support. In the dialog that opens, select Groovy and click OK. IntelliJ IDEA adds the Groovy SDK to your project and you can add Groovy classes and Groovy scripts.
Groovy The Groovy plugin is bundled with IntelliJ IDEA and enabled by default. IntelliJ IDEA supports the latest stable version of Groovy and Groovy 4 syntax.
You can't associate Jenkinsfile with Groovy in PyCharm, but you can associate them with Java.
Here what I've got so far:
Idea inspections should be a way to go. You can set them by right click on the project -> Analyze -> Inspect code ... and there is inspection profile selection which opens Inspections window.
There you can choose what inspections you'd like to run on your codebase and the severity of each inspection.
Go to Groovy -> Probable bugs -> Access to unresolved expression inspection and set the severity to Error.
Now you should see misspelled property or method name not with barely noticeable black underline but with red color, indicating error.
But what makes me mad is that I can't force Idea to show these errors in the results if you run Analyze on whole projects. It shows all the other inspection errors but not this one.
First some background information... IDEA only shows compile errors in the project tool window and in the Problems view. You can open a feature request asking that non-compile errors also show in these views.
Non-compile issues are discovered and shown via "Inspections". Failed inspections are fixed via "Intentions" (a.k.a. "Quick Fixes"). IDEA uses Inspection Profiles in which you can set what inspections are active and what severity level to show a failure of that inspection. You can define multiple profiles if desired. One of these profiles is set as the profile to use in the editor (F*ile > Settings > [Project Settings] > Inspections*). You can then (as you note) run an inspection profile (either the same one used in the editor or a different one) via Analyze > Inspect Code. You can also run a single inspection via Analyze > Run inspection by name.
IntelliJ shows a mellow barely noticeable black underline in code
If you do not think the issue shows prominently enough, you have three options (some of which you have partially discovered):
Steps:
There you can choose what inspections you'd like to run on your codebase and the severity of each inspection.
Just for clarification, the severity will determine how the inspections shows in the editor then the profile is used for the editor's inspection profile. When doing a code analysis, the main purpose for the severity is for grouping and filtering inspections in the output tool window. In general, its easiest to have a profile predefined that you use when you want to manually run a code inspection. Of course, you can use the same profile you have defined to be used in the editor.
But what makes me mad is that I can't force Idea to show these errors in the results if you run Analyze on whole projects. It shows all the other inspection errors but not this one.
All inspections defined (i.e. active) in the executed profile should be shown. The fact that the Groovy "access to unresolved expression" inspection is an apparent bug. I recommend opening a bug report for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With