Tobias Hermann
Tobias Hermann

Reputation: 10926

How to suppress warnings regarding naming conventions?

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.

Upvotes: 10

Views: 6372

Answers (3)

Vinay Kumar
Vinay Kumar

Reputation: 111

@Suppress("EnumEntryName") use these

Upvotes: 9

Nasib
Nasib

Reputation: 1549

For Kotlin/Java add

@Suppress("LocalVariableName", "PropertyName")

above the class name to suppress naming conventions warnings for global and local variables.

Upvotes: 11

CrazyCoder
CrazyCoder

Reputation: 401877

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.

Suppress

Upvotes: 5

Related Questions