Do not report code style warnings on overridden declarations (KT-25416)
#KT-25416 Fixed
This commit is contained in:
@@ -134,6 +134,9 @@ class FunctionNameInspection : NamingConventionInspection(
|
||||
) {
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
|
||||
return namedFunctionVisitor { function ->
|
||||
if (function.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
|
||||
return@namedFunctionVisitor
|
||||
}
|
||||
if (!TestUtils.isInTestSourceContent(function)) {
|
||||
verifyName(function, holder)
|
||||
}
|
||||
@@ -170,6 +173,10 @@ abstract class PropertyNameInspectionBase protected constructor(
|
||||
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
|
||||
return propertyVisitor { property ->
|
||||
if (property.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
|
||||
return@propertyVisitor
|
||||
}
|
||||
|
||||
if (property.getKind() == kind) {
|
||||
verifyName(property, holder)
|
||||
}
|
||||
|
||||
@@ -2,23 +2,22 @@
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<description>Function name <code>Foo</code> should start with a lowercase letter #loc</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>3</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<description>Function name <code>FOO_BAR</code> should not contain underscores #loc</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>7</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Class naming convention</problem_class>
|
||||
<description>Function name <code>`a b`</code> may contain only letters and digits #loc</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>10</line>
|
||||
<description>Function name <code>a_b</code> should not contain underscores #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
+9
-1
@@ -4,4 +4,12 @@ fun FOO_BAR() {}
|
||||
|
||||
fun xyzzy() {}
|
||||
|
||||
fun `a b`() {}
|
||||
fun `a b`() {}
|
||||
|
||||
interface I {
|
||||
fun a_b()
|
||||
}
|
||||
|
||||
class C : I {
|
||||
override fun a_b() {} // Shouldn't be reported
|
||||
}
|
||||
@@ -2,8 +2,11 @@
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>27</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<description>Property name <code>_Foo</code> should not start with an underscore #loc</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>37</line>
|
||||
<description>Property name <code>Foo</code> should start with a lowercase letter #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -31,4 +31,12 @@ class D {
|
||||
|
||||
var FOO_BAR: Int = 0
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
val Foo: Int
|
||||
}
|
||||
|
||||
class C : I {
|
||||
override override val Foo = 1
|
||||
}
|
||||
Reference in New Issue
Block a user