From ad59e94352e5ff1fc479368b590e288b72966f27 Mon Sep 17 00:00:00 2001 From: DMarinhoCodacy Date: Fri, 31 Jul 2026 17:06:21 +0100 Subject: [PATCH 1/6] Improve LowerCasePatternMatching rule --- .circleci/config.yml | 4 ++-- build.sbt | 2 +- .../Custom_Scala_LowerCasePatternMatching.scala | 14 +++++++------- project/Dependencies.scala | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 77a036b..287f770 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2.1 orbs: - codacy: codacy/base@12.2.0 - codacy_plugins_test: codacy/plugins-test@1.1.1 + codacy: codacy/base@13.1.1 + codacy_plugins_test: codacy/plugins-test@2.1.2 workflows: version: 2 diff --git a/build.sbt b/build.sbt index 8737a78..50fd7f7 100644 --- a/build.sbt +++ b/build.sbt @@ -104,7 +104,7 @@ val dockerUser = "docker" daemonUser in Docker := dockerUser -dockerBaseImage := "amazoncorretto:8-alpine3.14-jre" +dockerBaseImage := "amazoncorretto:8-alpine3.24-jre" dockerCommands := dockerCommands.value.flatMap { case cmd @ Cmd("ADD", _) => diff --git a/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala b/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala index aa5f8aa..ac6f234 100644 --- a/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala +++ b/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala @@ -42,13 +42,13 @@ case object Custom_Scala_LowerCasePatternMatching extends Pattern { } } - private[this] def isLowerCase(pat: Pat) = { - pat match { - case q"${name: Pat.Var}" => - name.name.value.headOption.exists(Character.isLowerCase) - case _ => - false - } + private[this] def isLowerCase(pat: Pat): Boolean = pat match { + case Pat.Var(name) => + name.value.headOption.exists(c => Character.isLowerCase(c)) + case Pat.Bind(inner, _) => + isLowerCase(inner) + case _ => + false } private[this] def hasDeclaredType(pat: Pat) = { diff --git a/project/Dependencies.scala b/project/Dependencies.scala index eb51daa..a6c9c71 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -4,7 +4,7 @@ object Dependencies { val scalaV = "2.12.20" val betterFiles = "com.github.pathikrit" %% "better-files" % "3.8.0" - val codacyEngine = "com.codacy" %% "codacy-engine-scala-seed" % "5.0.2" + val codacyEngine = "com.codacy" %% "codacy-engine-scala-seed" % "6.1.4" val scalaReflect = "org.scala-lang" % "scala-reflect" % scalaV } From adc794ef789d8f3d0b40ef1d7b11a0c4759e4ec1 Mon Sep 17 00:00:00 2001 From: DMarinhoCodacy Date: Mon, 3 Aug 2026 12:23:03 +0100 Subject: [PATCH 2/6] Improve how we flag lower case variables --- .../Custom_Scala_LowerCasePatternMatching.scala | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala b/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala index ac6f234..15e3646 100644 --- a/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala +++ b/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala @@ -14,11 +14,15 @@ case object Custom_Scala_LowerCasePatternMatching extends Pattern { } private[this] def isOffender(tree: Tree, pat: Pat) = { - !hasDeclaredType(pat) && !isCaseFromCollect(tree) && !isCaseFromPartialFunction(tree) && isLowerCase(pat) + !hasDeclaredType(pat) && + !isCaseFromCollect(tree) && + !isCaseFromPartialFunction(tree) && + !isCaseFromCatch(tree) && + isLowerCase(pat) } private[this] def isPartialApplication(tpe: Term.Name) = tpe.toString match { - case "orElse" | "andThen" => true + case "orElse" | "andThen" | "recover" | "recoverWith" => true case _ => false } @@ -55,5 +59,12 @@ case object Custom_Scala_LowerCasePatternMatching extends Pattern { pat.collect { case t @ p"$expr: $tpe" => t }.nonEmpty } + private[this] def isCaseFromCatch(tree: Tree): Boolean = { + tree.parent.exists { + case t: Term.Try => t.catchp.exists(_ == tree) + case _ => false + } +} + private[this] def message(tree: Tree) = Message("Lower case pattern matching.") } From f3a558d285aa8bb109a71c5209a7a56679f564fb Mon Sep 17 00:00:00 2001 From: DMarinhoCodacy Date: Mon, 3 Aug 2026 12:28:23 +0100 Subject: [PATCH 3/6] remove irrelevant code --- docs/patterns.json | 310 ++++++++++++++++++ ...ustom_Scala_LowerCasePatternMatching.scala | 2 - 2 files changed, 310 insertions(+), 2 deletions(-) create mode 100644 docs/patterns.json diff --git a/docs/patterns.json b/docs/patterns.json new file mode 100644 index 0000000..a1289ea --- /dev/null +++ b/docs/patterns.json @@ -0,0 +1,310 @@ +{ + "patterns": [ + { + "patternId": "Custom_Scala_ActiveNames", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_BadTagPresenceCheck", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_CallByNameAsLastArguments", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_DefaultPatternMatching", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_DirectPromiseCreation", + "category": "ErrorProne", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_ElseIf", + "category": "CodeStyle", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_EnforceMinimumVisibility", + "category": "CodeStyle", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_ExplicitMutableNamespace", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_ExtendsError", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_FieldNamesChecker", + "category": "CodeStyle", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_GetCalls", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_GetInMethodName", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_GroupImports", + "category": "CodeStyle", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_ImportsAtBeginningOfPackage", + "category": "CodeStyle", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_ImportsSortedAlphabetically", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_IncompletePatternMatching", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_IndexOfPositive", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_IndexOfStartPosition", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_IsDefined", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_JavaThreads", + "category": "ErrorProne", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_LowerCasePatternMatching", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_NameResultsAndParameters", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_NonFatal", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_NotUsingNonEmpty", + "category": "CodeStyle", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_PatternMatchingInHigherOrderFunctions", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_PatternMatchingWhenDefaults", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_PreferImmutableCollections", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_ProhibitObjectName", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_ReservedKeywords", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_ReturnFinally", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_StructuralTypes", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_TypeParameterName", + "category": "CodeStyle", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_TypedEquality", + "category": "ErrorProne", + "level": "Error", + "enabled": false + }, + { + "patternId": "Custom_Scala_UnusedPrivateVariables", + "category": "UnusedCode", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_UsefulTypeAlias", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_UsingDateTimeNow", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_UtilTryForTryCatch", + "category": "ErrorProne", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_WildcardImportOnMany", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_WithNameCalls", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "MultipleStringLiteralsChecker", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_UselessComparison", + "category": "ErrorProne", + "level": "Error", + "enabled": false + }, + { + "patternId": "ObjectNamesChecker", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, + { + "patternId": "ClassNamesChecker", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, + { + "patternId": "MethodNamesChecker", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyIfBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyForBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyWhileBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyMethodBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyTryBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_DuplicatedCase", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_DuplicatedIfElseIf", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + } + ] +} diff --git a/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala b/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala index 15e3646..36d4ada 100644 --- a/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala +++ b/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala @@ -49,8 +49,6 @@ case object Custom_Scala_LowerCasePatternMatching extends Pattern { private[this] def isLowerCase(pat: Pat): Boolean = pat match { case Pat.Var(name) => name.value.headOption.exists(c => Character.isLowerCase(c)) - case Pat.Bind(inner, _) => - isLowerCase(inner) case _ => false } From 3cdb6e40ec67c784ad2740d2565996862e561718 Mon Sep 17 00:00:00 2001 From: DMarinhoCodacy Date: Mon, 3 Aug 2026 12:28:42 +0100 Subject: [PATCH 4/6] remove irrelevant code --- docs/patterns.json | 310 --------------------------------------------- 1 file changed, 310 deletions(-) delete mode 100644 docs/patterns.json diff --git a/docs/patterns.json b/docs/patterns.json deleted file mode 100644 index a1289ea..0000000 --- a/docs/patterns.json +++ /dev/null @@ -1,310 +0,0 @@ -{ - "patterns": [ - { - "patternId": "Custom_Scala_ActiveNames", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_BadTagPresenceCheck", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_CallByNameAsLastArguments", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_DefaultPatternMatching", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_DirectPromiseCreation", - "category": "ErrorProne", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_ElseIf", - "category": "CodeStyle", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_EnforceMinimumVisibility", - "category": "CodeStyle", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_ExplicitMutableNamespace", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_ExtendsError", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_FieldNamesChecker", - "category": "CodeStyle", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_GetCalls", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_GetInMethodName", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_GroupImports", - "category": "CodeStyle", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_ImportsAtBeginningOfPackage", - "category": "CodeStyle", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_ImportsSortedAlphabetically", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_IncompletePatternMatching", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_IndexOfPositive", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_IndexOfStartPosition", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_IsDefined", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_JavaThreads", - "category": "ErrorProne", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_LowerCasePatternMatching", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_NameResultsAndParameters", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_NonFatal", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_NotUsingNonEmpty", - "category": "CodeStyle", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_PatternMatchingInHigherOrderFunctions", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_PatternMatchingWhenDefaults", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_PreferImmutableCollections", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_ProhibitObjectName", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_ReservedKeywords", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_ReturnFinally", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_StructuralTypes", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_TypeParameterName", - "category": "CodeStyle", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_TypedEquality", - "category": "ErrorProne", - "level": "Error", - "enabled": false - }, - { - "patternId": "Custom_Scala_UnusedPrivateVariables", - "category": "UnusedCode", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_UsefulTypeAlias", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_UsingDateTimeNow", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_UtilTryForTryCatch", - "category": "ErrorProne", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_WildcardImportOnMany", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_WithNameCalls", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "MultipleStringLiteralsChecker", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_UselessComparison", - "category": "ErrorProne", - "level": "Error", - "enabled": false - }, - { - "patternId": "ObjectNamesChecker", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "ClassNamesChecker", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "MethodNamesChecker", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyIfBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyForBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyWhileBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyMethodBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyTryBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_DuplicatedCase", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_DuplicatedIfElseIf", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - } - ] -} From 0b7751f86dd3de07ce9a958af8745454af2b5cee Mon Sep 17 00:00:00 2001 From: DMarinhoCodacy Date: Mon, 3 Aug 2026 12:33:41 +0100 Subject: [PATCH 5/6] revert isLowerCase old method --- docs/patterns.json | 310 ++++++++++++++++++ ...ustom_Scala_LowerCasePatternMatching.scala | 12 +- 2 files changed, 317 insertions(+), 5 deletions(-) create mode 100644 docs/patterns.json diff --git a/docs/patterns.json b/docs/patterns.json new file mode 100644 index 0000000..a1289ea --- /dev/null +++ b/docs/patterns.json @@ -0,0 +1,310 @@ +{ + "patterns": [ + { + "patternId": "Custom_Scala_ActiveNames", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_BadTagPresenceCheck", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_CallByNameAsLastArguments", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_DefaultPatternMatching", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_DirectPromiseCreation", + "category": "ErrorProne", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_ElseIf", + "category": "CodeStyle", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_EnforceMinimumVisibility", + "category": "CodeStyle", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_ExplicitMutableNamespace", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_ExtendsError", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_FieldNamesChecker", + "category": "CodeStyle", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_GetCalls", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_GetInMethodName", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_GroupImports", + "category": "CodeStyle", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_ImportsAtBeginningOfPackage", + "category": "CodeStyle", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_ImportsSortedAlphabetically", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_IncompletePatternMatching", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_IndexOfPositive", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_IndexOfStartPosition", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_IsDefined", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_JavaThreads", + "category": "ErrorProne", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_LowerCasePatternMatching", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_NameResultsAndParameters", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_NonFatal", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_NotUsingNonEmpty", + "category": "CodeStyle", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_PatternMatchingInHigherOrderFunctions", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_PatternMatchingWhenDefaults", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_PreferImmutableCollections", + "category": "ErrorProne", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_ProhibitObjectName", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_ReservedKeywords", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_ReturnFinally", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_StructuralTypes", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_TypeParameterName", + "category": "CodeStyle", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_TypedEquality", + "category": "ErrorProne", + "level": "Error", + "enabled": false + }, + { + "patternId": "Custom_Scala_UnusedPrivateVariables", + "category": "UnusedCode", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_UsefulTypeAlias", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_UsingDateTimeNow", + "category": "ErrorProne", + "level": "Warning", + "enabled": false + }, + { + "patternId": "Custom_Scala_UtilTryForTryCatch", + "category": "ErrorProne", + "level": "Info", + "enabled": true + }, + { + "patternId": "Custom_Scala_WildcardImportOnMany", + "category": "CodeStyle", + "level": "Warning", + "enabled": true + }, + { + "patternId": "Custom_Scala_WithNameCalls", + "category": "ErrorProne", + "level": "Warning", + "enabled": true + }, + { + "patternId": "MultipleStringLiteralsChecker", + "category": "CodeStyle", + "level": "Info", + "enabled": false + }, + { + "patternId": "Custom_Scala_UselessComparison", + "category": "ErrorProne", + "level": "Error", + "enabled": false + }, + { + "patternId": "ObjectNamesChecker", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, + { + "patternId": "ClassNamesChecker", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, + { + "patternId": "MethodNamesChecker", + "level": "Info", + "category": "CodeStyle", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyIfBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyForBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyWhileBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyMethodBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_EmptyTryBlock", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_DuplicatedCase", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + }, + { + "patternId": "Custom_Scala_DuplicatedIfElseIf", + "level": "Warning", + "category": "ErrorProne", + "enabled": false + } + ] +} diff --git a/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala b/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala index 36d4ada..6e46c62 100644 --- a/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala +++ b/patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala @@ -46,11 +46,13 @@ case object Custom_Scala_LowerCasePatternMatching extends Pattern { } } - private[this] def isLowerCase(pat: Pat): Boolean = pat match { - case Pat.Var(name) => - name.value.headOption.exists(c => Character.isLowerCase(c)) - case _ => - false + private[this] def isLowerCase(pat: Pat) = { + pat match { + case q"${name: Pat.Var}" => + name.name.value.headOption.exists(Character.isLowerCase) + case _ => + false + } } private[this] def hasDeclaredType(pat: Pat) = { From 751beaee2e90963111bb92384cb758515fa64130 Mon Sep 17 00:00:00 2001 From: DMarinhoCodacy Date: Mon, 3 Aug 2026 12:34:03 +0100 Subject: [PATCH 6/6] remove unused code --- docs/patterns.json | 310 --------------------------------------------- 1 file changed, 310 deletions(-) delete mode 100644 docs/patterns.json diff --git a/docs/patterns.json b/docs/patterns.json deleted file mode 100644 index a1289ea..0000000 --- a/docs/patterns.json +++ /dev/null @@ -1,310 +0,0 @@ -{ - "patterns": [ - { - "patternId": "Custom_Scala_ActiveNames", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_BadTagPresenceCheck", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_CallByNameAsLastArguments", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_DefaultPatternMatching", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_DirectPromiseCreation", - "category": "ErrorProne", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_ElseIf", - "category": "CodeStyle", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_EnforceMinimumVisibility", - "category": "CodeStyle", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_ExplicitMutableNamespace", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_ExtendsError", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_FieldNamesChecker", - "category": "CodeStyle", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_GetCalls", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_GetInMethodName", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_GroupImports", - "category": "CodeStyle", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_ImportsAtBeginningOfPackage", - "category": "CodeStyle", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_ImportsSortedAlphabetically", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_IncompletePatternMatching", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_IndexOfPositive", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_IndexOfStartPosition", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_IsDefined", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_JavaThreads", - "category": "ErrorProne", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_LowerCasePatternMatching", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_NameResultsAndParameters", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_NonFatal", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_NotUsingNonEmpty", - "category": "CodeStyle", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_PatternMatchingInHigherOrderFunctions", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_PatternMatchingWhenDefaults", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_PreferImmutableCollections", - "category": "ErrorProne", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_ProhibitObjectName", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_ReservedKeywords", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_ReturnFinally", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_StructuralTypes", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_TypeParameterName", - "category": "CodeStyle", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_TypedEquality", - "category": "ErrorProne", - "level": "Error", - "enabled": false - }, - { - "patternId": "Custom_Scala_UnusedPrivateVariables", - "category": "UnusedCode", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_UsefulTypeAlias", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_UsingDateTimeNow", - "category": "ErrorProne", - "level": "Warning", - "enabled": false - }, - { - "patternId": "Custom_Scala_UtilTryForTryCatch", - "category": "ErrorProne", - "level": "Info", - "enabled": true - }, - { - "patternId": "Custom_Scala_WildcardImportOnMany", - "category": "CodeStyle", - "level": "Warning", - "enabled": true - }, - { - "patternId": "Custom_Scala_WithNameCalls", - "category": "ErrorProne", - "level": "Warning", - "enabled": true - }, - { - "patternId": "MultipleStringLiteralsChecker", - "category": "CodeStyle", - "level": "Info", - "enabled": false - }, - { - "patternId": "Custom_Scala_UselessComparison", - "category": "ErrorProne", - "level": "Error", - "enabled": false - }, - { - "patternId": "ObjectNamesChecker", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "ClassNamesChecker", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "MethodNamesChecker", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyIfBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyForBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyWhileBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyMethodBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_EmptyTryBlock", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_DuplicatedCase", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - }, - { - "patternId": "Custom_Scala_DuplicatedIfElseIf", - "level": "Warning", - "category": "ErrorProne", - "enabled": false - } - ] -}