首页 > 解决方案 > 如何抑制有关命名约定的警告?

问题描述

对于我的枚举类之一,我想使用非标准命名:

enum class MyEnum {
    I_like_to_use,
    This_strange_naming_here
}

IDE(和代码检查)理所当然地抱怨:

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.

但是在这种情况下,我想积极抑制这个警告。我试过了@Suppress("naming"),但无济于事。

标签: intellij-ideakotlin

解决方案


请参阅禁止检查。您不应该手动键入它。

使用Alt+Enter调用灯泡的弹出菜单,从下拉菜单中选择检查或建议的快速修复,按键盘上的向右箭头打开右侧的子菜单,选择 Suppress 选项.

压制


推荐阅读