In the newer intellij version a useful feature "Suppress X warning if annotated by Y" was added. I mistakenly applied it to "unused" warning, and want to roll that back. But I find no such option in the settings.
Basically I do want to get warnings when fields are not used even if annotated by #Inject or whatever.
Related
It's about something similar to the ReSharper feature "Go to Next/Previous Member", but inside IntelliJ (not this similarly named question)
The Alt+Up/Down in IntellJ is by default mapped to "Previous/Next Method", so it skips member variables, whereas ReSharper maps that to "Next/Previous Member", which obviously steps over everything, including fields and properties.
Is there any solution for IntelliJ to mimic ReSharper's feature, perhaps through a plugin or anything else?
This feature has been implemented and reverted because of negative feedback (https://youtrack.jetbrains.com/issue/IDEA-107538).
This behavior can still be turned on by adding to "Help | Edit custom VM options":
-Dide.structural.navigation.visit.fields=true
How can I suppress the inspection in Kotlin for an unused variable
val xyz = abc
I get the squiggly line but ALT-ENTER is useless for this, I tried also to create in another method several variables unused and they also lack the ALT-ENTER ability to ignore the warning. Although I have definitely used ALT-ENTER for this in the past, although maybe it was only in java, can't remember.
So I must manually construct it by hand. I've been trying several variations but I can't get anything to work. Please tell me the correct //noinspection or #SupressWarnings to use, thanks
In IntelliJ IDEA, a right-side arrow on an ALT+ENTER context menu (like this: ) means that you can use your arrow keys to navigate further along the menu. In this case, it leads to your answer:
#Suppress("UNUSED_VARIABLE")
val unused = ""
If you do not get the initial context menu (Remove variable '...'), you may have disabled the "Unused assignment" inspection in your current project. You can fix this by going to Settings -> Editor -> Inspections.
I suppressed a Resharper warning in a VB.NET class file (*.vb). As expected, the warning is not highlighted at the border of the text editor.
If I show all Resharper warnings for my project I would expect that the suppressed warning is neither shown in the Inspection Results view. However, it is shown, see screen shot.
How to I hide warnings in the InspectionResults that are suppressed in the code with an annotation?
I am using Resharper 8.2.3
(If you have issues with public properties in respect to xaml bindings also see this related question: Resharper says OnPropertyChange set member can be private while not true)
This appears to be a bug in ReSharper. It works as expected (that is, the suppressed warning does not appear in the find results) if you use the disable and restore style comments, rather than the disable once comments. I.e.:
' ReSharper disable MemberCanBePrivate.Global
Public Property Foo As String
' ReSharper restore MemberCanBePrivate.Global
I've raised an issue that you can track and vote on: https://youtrack.jetbrains.com/issue/RSRP-444615
It really annoys me that IntelliJ highlights certain 'errors' (that don't prevent successful compilation) the same way that real errors are highlighted. For example, a magic number is not really an error, but it will be flagged in exactly the same way as an incompatible type error.
How can I change this?
Go to Settings -> Inspections. Then you need to search through the long list for the offending inspection, which you can get the name of by hovering on the warning marker in the margin. You can change the severity of the inspection, whether it's an error, warning, etc. or just disable it altogether.
Edit: if you search for "magic" in Settings, you get the following, which should be helpful:
Whenever you see an inspection warning/error you can place the caret on it and press Alt+Enter (a light bulb also appears that tells you that). A menu will appear with suggested quick fixes. You may need to open a submenu by pressing Right, and you'll find "Edit inspection settings" there. Having invoked that, you may proceed as in hvgotcodes's answer :), it's just a faster way of getting to those settings.
As Michael Calvin said you can use the SuppressWarnings annotation. For example:
#SuppressWarnings("OptionalUsedAsFieldOrParameterType")
See https://github.com/JetBrains/intellij-community/blob/master/plugins/InspectionGadgets/src/inspectionDescriptions/OptionalUsedAsFieldOrParameterType.html
Usually searching the internet for the exact description leads me to this.
Not directly relevant to the OP, but may be of use to future Googlers
I got to this question while trying to figure out how to disable IntelliJ IDEA's warnings about Guava functionalities that have been replaced by Java 8 features. I'm not able to use the Java 8 versions of these features in my case because of a library we're using that was built with Guava (despite being a Java 8 project). So to solve that, I added a SuppressWarnings annotation before any class using Guava:
#SuppressWarnings(Guava)
public final class...
I've recently switched over to intellij for scala development.
I'm having trouble finding the following shortcut:
In eclipse, I could type a method call e.g.
method("hello", 1)
and press <command>1 to have eclipse popup a suggestion to let me create a method stub.
Is there such a shortcut in intellij?
Use Alt+Enter (Show Intention Actions in Settings | Keymap).
Verified, works fine in IDEA 11.0.1 with the current Scala plug-in:
Activate Type aware highlighting (See the [T] symbol in the image) and
Set Highlighting level to Inspections
Then it is possible to use alt + enter (similar to Ctrl+1 in Eclipse) to show menu, which has create method option.
Why isn't it enabled by default?
The feature is in beta (or maybe in alpha) and sometimes may report "false errors" in regular code. Usually, such "errors" "found" only in a truly complex code, and, normally, everything works just fine.
Scala plugin doesn't rely on compiler to analyze code. We're implementing our own model of the language, and sometimes it's challenging, especially when it comes to Scala's type system and type inference (to size up the problem, you may try to formally "infer" a type of "foo".map(_ + 1) expression by hand).