Naming convention inspection for test functions
#KT-21547 Fixed
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports test function names that do not follow the recommended naming conventions.
|
||||
</body>
|
||||
</html>
|
||||
@@ -2392,6 +2392,14 @@
|
||||
displayName="Function naming convention"
|
||||
level="WEAK WARNING"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.TestFunctionNameInspection"
|
||||
language="kotlin"
|
||||
groupPath="Kotlin"
|
||||
groupName="Naming conventions"
|
||||
enabledByDefault="true"
|
||||
displayName="Test function naming convention"
|
||||
level="WEAK WARNING"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.PropertyNameInspection"
|
||||
language="kotlin"
|
||||
groupPath="Kotlin"
|
||||
|
||||
@@ -127,7 +127,27 @@ class FunctionNameInspection : NamingConventionInspection(
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
|
||||
return object : KtVisitorVoid() {
|
||||
override fun visitNamedFunction(function: KtNamedFunction) {
|
||||
if (TestUtils.isInTestSourceContent(function) && function.nameIdentifier?.text?.startsWith("`") == true) {
|
||||
if (TestUtils.isInTestSourceContent(function)) {
|
||||
return
|
||||
}
|
||||
verifyName(function, holder)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestFunctionNameInspection : NamingConventionInspection(
|
||||
"Test function",
|
||||
"[a-z][A-Za-z_\\d]*",
|
||||
START_LOWER
|
||||
) {
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
|
||||
return object : KtVisitorVoid() {
|
||||
override fun visitNamedFunction(function: KtNamedFunction) {
|
||||
if (!TestUtils.isInTestSourceContent(function)) {
|
||||
return
|
||||
}
|
||||
if (function.nameIdentifier?.text?.startsWith("`") == true) {
|
||||
return
|
||||
}
|
||||
verifyName(function, holder)
|
||||
|
||||
Reference in New Issue
Block a user