diff --git a/checks/src/main/java/com/omegar/lint/checks/detector/code_guidelines/kotlin_style/name/field/CompanionObjectFieldsDetector.kt b/checks/src/main/java/com/omegar/lint/checks/detector/code_guidelines/kotlin_style/name/field/CompanionObjectFieldsDetector.kt index 654c9d9..e9a3634 100644 --- a/checks/src/main/java/com/omegar/lint/checks/detector/code_guidelines/kotlin_style/name/field/CompanionObjectFieldsDetector.kt +++ b/checks/src/main/java/com/omegar/lint/checks/detector/code_guidelines/kotlin_style/name/field/CompanionObjectFieldsDetector.kt @@ -31,7 +31,7 @@ class CompanionObjectFieldsDetector : Detector(), Detector.UastScanner { private const val VAL_LABEL = "val" private const val COMPANION_NAME_LABEL = "Companion" - private val UPPER_REGEX = Regex("""^([A-Z]*_*)*$""") + private val UPPER_REGEX = Regex("""^([A-Z][1-9]*_*)*$""") } override fun getApplicableUastTypes(): List> = listOf(UClass::class.java) diff --git a/checks/src/main/java/com/omegar/lint/checks/detector/code_guidelines/kotlin_style/restrictions/class_methods_count/MaxMethodCountDetector.kt b/checks/src/main/java/com/omegar/lint/checks/detector/code_guidelines/kotlin_style/restrictions/class_methods_count/MaxMethodCountDetector.kt index 487df81..e3703ef 100644 --- a/checks/src/main/java/com/omegar/lint/checks/detector/code_guidelines/kotlin_style/restrictions/class_methods_count/MaxMethodCountDetector.kt +++ b/checks/src/main/java/com/omegar/lint/checks/detector/code_guidelines/kotlin_style/restrictions/class_methods_count/MaxMethodCountDetector.kt @@ -8,43 +8,46 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UMethod class MaxMethodCountDetector : Detector(), Detector.UastScanner { - companion object { - /** Issue describing the problem and pointing to the detector implementation */ - @JvmField - val ISSUE: Issue = Issue.create( - id = "OMEGA_NOT_EXCEED_MAX_METHODS_COUNT", - briefDescription = "Class methods count does not match the coding convention", - explanation = """ + companion object { + /** Issue describing the problem and pointing to the detector implementation */ + @JvmField + val ISSUE: Issue = Issue.create( + id = "OMEGA_NOT_EXCEED_MAX_METHODS_COUNT", + briefDescription = "Class methods count does not match the coding convention", + explanation = """ Class should has 30 methods or less. http://wiki.omega-r.club/dev-android-code#rec228195879 """, - category = Category.CORRECTNESS, - priority = 7, - severity = Severity.WARNING, - implementation = Implementation( - MaxMethodCountDetector::class.java, - Scope.JAVA_FILE_SCOPE - ) - ) + category = Category.CORRECTNESS, + priority = 7, + severity = Severity.WARNING, + implementation = Implementation( + MaxMethodCountDetector::class.java, + Scope.JAVA_FILE_SCOPE + ) + ) - private const val MAX_METHOD_COUNT = 30 - } + private const val MAX_METHOD_COUNT = 30 + } - override fun getApplicableUastTypes(): List> = listOf(UClass::class.java) + override fun getApplicableUastTypes(): List> = listOf(UClass::class.java) - override fun createUastHandler(context: JavaContext): UElementHandler { - return object : UElementHandler() { - override fun visitClass(node: UClass) { - val resultMethods = mutableListOf() - node.methods.forEach { - if (!it.isVarArgs && !it.isConstructor) { - resultMethods.add(it) - } - } - if (resultMethods.size > MAX_METHOD_COUNT) { - context.report(ISSUE, node, context.getNameLocation(node), ISSUE.getExplanation(TextFormat.TEXT)) - } - } - } - } + override fun createUastHandler(context: JavaContext): UElementHandler { + return object : UElementHandler() { + override fun visitClass(node: UClass) { + val resultMethods = mutableListOf() + node.methods.forEach { + resultMethods.add(it) + } + if (resultMethods.size > MAX_METHOD_COUNT) { + context.report( + ISSUE, + node, + context.getNameLocation(node), + ISSUE.getExplanation(TextFormat.TEXT) + ) + } + } + } + } } \ No newline at end of file