How to suppress warnings regarding naming conventions? - intellij-idea

For one of my enum classes I'd like to use non-standard naming:
enum class MyEnum {
I_like_to_use,
This_strange_naming_here
}
The IDE (and code inspection) rightfully complains with:
Enum entry name 'This_strange_naming_here' doesn't match regex '[A-Z]([A-Za-z\d]*|[A-Z_\d]*)'.
This inspection reports enum entry named that do not follow the recommended naming conventions.
However in this case, I would like to actively suppress this warning. I tried with #Suppress("naming"), but to no avail.

For Kotlin/Java add
#Suppress("LocalVariableName", "PropertyName")
above the class name to suppress naming conventions warnings for global and local variables.

#Suppress("EnumEntryName") use these

Please see Suppress inspections. You are not supposed to type it by hand.
Use Alt+Enter to invoke the pop-up menu for the light bulb, select the inspection or the suggested quick fix from the drop-down menu, press the right arrow on the keyboard to open the sub-menu on the right, choose the Suppress option.

Related

IntelliJ constants.getProperty() autocomplete field

I have a large constants.properties file.
When reading properties from it with constants.getProperty("PROPERTY_NAME") I often have to copy/paste the property names which is rather long.
I see that IntelliJ is able to detect when properties are used inside the code, is it be possible to have auto-completion of property names when I type the name in getProperty()?
Yes, IntelliJ IDEA provides the completion for the Java Properties, use Ctrl+Space to get the hints:

Disable "code hiding feature" in IntelliJ

Remark: This question is (up to now) not a duplicate. I know how to disable the hints. This is not what I am looking for.
In intelliJ a feature "hides" parts of my code, e.g. variable declarations as "var" or getter methods like in the example below.
The code shows t.message, but the code behind this visual abbrevation is t.getMessage(). How can I disable that feature and always show t.getMessage()?
Abbreviated code:
Real code:
Because I don't know the name of the feature I have no idea what I am looking for. Any ideas?
To disable showing val/var instead of variable type
go to Settings | Editor | General | Code Folding
and UnCheck Variable Declaration
And just next to it
Uncheck Getters and setters
to start showing getter Setter method calls with full method name
refer- https://stackoverflow.com/a/48271952/3661654

CLion highlight settings (override)

I'm using CLion IDE, and I really enjoy it, but one thing is quite annoying and I can't get rid of it.
CLion highlights every function declaration that overrides another function in base class with "Annotate this function with override or (rarely) final". As far as I know override keyword is an optional keyword. I would use it, but I recently joined this big sized project and I want to stay consistent to its conventions - and they don't use override keyword.
But the problem is that I couldn't find anywhere in CLion's settings where to disable this highlight option (I've tried using search option in settings, but still nothing).
It is a bit annoying because it highlights most of functions in my derived classes, and I have to mouse over it to check if it is an important notice, or just this "Annotate this...".
You can find on this link from jetbrains.com some explanations on how to disable inspections.
One of these method is temporary : Use the widget in the top-right corner of the editor and select the level 'None' in the Highlight list.

suppress an unused variable warning

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.

Disable IntelliJ Warnings

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...