diff --git a/build.sbt b/build.sbt index c05d2ec..82be2a3 100644 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,7 @@ name := "codacy-checkstyle" scalaVersion := "2.13.3" -lazy val checkstyleVersion = "10.17.0" +lazy val checkstyleVersion = "10.18.2" Compile / sourceGenerators += Def.task { val file = (Compile / sourceManaged).value / "codacy" / "checkstyle" / "Versions.scala" diff --git a/docs/description/AbbreviationAsWordInName.md b/docs/description/AbbreviationAsWordInName.md index 773eb37..2fb5c43 100644 --- a/docs/description/AbbreviationAsWordInName.md +++ b/docs/description/AbbreviationAsWordInName.md @@ -1,7 +1,7 @@ Validates abbreviations (consecutive capital letters) length in identifier name, it also allows to enforce camel case naming. Please read more at [Google Style -Guide](https://checkstyle.org/styleguides/google-java-style-20180523/javaguide.html#s5.3-camel-case) +Guide](../../styleguides/google-java-style-20220203/javaguide.html#s5.3-camel-case) to get to know how to avoid long abbreviations in names. '\_' is considered as word separator in identifier name. diff --git a/docs/description/CatchParameterName.md b/docs/description/CatchParameterName.md index 3008d0d..db721a4 100644 --- a/docs/description/CatchParameterName.md +++ b/docs/description/CatchParameterName.md @@ -7,6 +7,7 @@ Default pattern has the following characteristic: - allows `e` abbreviation (suitable for exceptions end errors) - allows `ex` abbreviation (suitable for exceptions) - allows `t` abbreviation (suitable for throwables) +- allows `_` for unnamed catch parameters - prohibits numbered abbreviations like `e1` or `t2` - prohibits one letter prefixes like `pException` - prohibits two letter abbreviations like `ie` or `ee` diff --git a/docs/description/ClassDataAbstractionCoupling.md b/docs/description/ClassDataAbstractionCoupling.md index 320e46e..cf64fac 100644 --- a/docs/description/ClassDataAbstractionCoupling.md +++ b/docs/description/ClassDataAbstractionCoupling.md @@ -1,9 +1,9 @@ -Measures the number of instantiations of other classes within the given -class or record. This type of coupling is not caused by inheritance or -the object-oriented paradigm. Generally speaking, any data type with -other data types as members or local variable that is an instantiation -(object) of another class has data abstraction coupling (DAC). The -higher the DAC, the more complex the structure of the class. +Measures the number of distinct classes that are instantiated within the +given class or record. This type of coupling is not caused by +inheritance or the object-oriented paradigm. Generally speaking, any +data type with other data types as members or local variable that is an +instantiation (object) of another class has data abstraction coupling +(DAC). The higher the DAC, the more complex the structure of the class. This check processes files in the following way: diff --git a/docs/description/CommentsIndentation.md b/docs/description/CommentsIndentation.md index a6d2f97..7c48cd3 100644 --- a/docs/description/CommentsIndentation.md +++ b/docs/description/CommentsIndentation.md @@ -1,4 +1,4 @@ Controls the indentation between comments and surrounding code. Comments are indented at the same level as the surrounding code. Detailed info about such convention can be found -[here](../../styleguides/google-java-style-20180523/javaguide.html#s4.8.6.1-block-comment-style) +[here](../../styleguides/google-java-style-20220203/javaguide.html#s4.8.6.1-block-comment-style) diff --git a/docs/description/CyclomaticComplexity.md b/docs/description/CyclomaticComplexity.md index f82d740..b41b52e 100644 --- a/docs/description/CyclomaticComplexity.md +++ b/docs/description/CyclomaticComplexity.md @@ -4,9 +4,13 @@ the number of required tests, it is not about quality of code! It is only applied to methods, c-tors, [static initializers and instance initializers](https://docs.oracle.com/javase/tutorial/java/javaOO/initial.html). -The complexity is equal to the number of decision points ` + 1`. -Decision points: `if`, `while` , `do`, `for`, `?:`, `catch` , `switch`, -`case` statements and operators `&&` and `||` in the body of target. +The complexity is equal to the number of decision points `+ 1`. Decision +points: + +- `if`, `while`, `do`, `for`, `?:`, `catch`, `switch`, `case` + statements. +- Operators `&&` and `||` in the body of target. +- `when` expression in case labels, also known as guards. By pure theory level 1-4 is considered easy to test, 5-7 OK, 8-10 consider re-factoring to ease testing, and 11+ re-factor now as testing diff --git a/docs/description/DeclarationOrder.md b/docs/description/DeclarationOrder.md index 40b98cf..5523290 100644 --- a/docs/description/DeclarationOrder.md +++ b/docs/description/DeclarationOrder.md @@ -1,7 +1,7 @@ Checks that the parts of a class, record, or interface declaration appear in the order suggested by the [Code Conventions for the Java Programming -Language](https://checkstyle.org/styleguides/sun-code-conventions-19990420/CodeConventions.doc2.html#a1852). +Language](../../styleguides/sun-code-conventions-19990420/CodeConventions.doc2.html#a1852). According to [Code Conventions for the Java Programming Language](../../styleguides/sun-code-conventions-19990420/CodeConventions.doc2.html#a1852) diff --git a/docs/description/FallThrough.md b/docs/description/FallThrough.md index a7d52d8..868a2cd 100644 --- a/docs/description/FallThrough.md +++ b/docs/description/FallThrough.md @@ -8,6 +8,6 @@ through", "fall-through" "fallsthrough", "falls through", "falls-through" (case-sensitive). The comment containing these words must be all on one line, and must be on the last non-empty line before the `case` triggering the warning or on the same line before the `case` -(ugly, but possible). +(ugly, but possible). Any other comment may follow on the same line. Note: The check assumes that there is no unreachable code in the `case`. diff --git a/docs/description/IllegalIdentifierName.md b/docs/description/IllegalIdentifierName.md index 7dc8152..2eb01a5 100644 --- a/docs/description/IllegalIdentifierName.md +++ b/docs/description/IllegalIdentifierName.md @@ -1,7 +1,7 @@ Checks identifiers with a pattern for a set of illegal names, such as those that are restricted or contextual keywords. Examples include -"yield", "record", "\_", and "var". Please read more at [Java Language -Specification](https://docs.oracle.com/javase/specs/jls/se14/html/jls-3.html#jls-3.9) +"yield", "record", and "var". Please read more at [Java Language +Specification](https://docs.oracle.com/javase/specs/jls/se22/html/jls-3.html#jls-3.9) to get to know more about restricted keywords. Since this check uses a pattern to specify valid identifiers, users can also prohibit the usage of certain symbols, such as "$", or any non-ascii character. diff --git a/docs/description/JavadocLeadingAsteriskAlign.md b/docs/description/JavadocLeadingAsteriskAlign.md new file mode 100644 index 0000000..70ac834 --- /dev/null +++ b/docs/description/JavadocLeadingAsteriskAlign.md @@ -0,0 +1,12 @@ +Checks the alignment of [leading +asterisks](https://docs.oracle.com/en/java/javase/14/docs/specs/javadoc/doc-comment-spec.html#leading-asterisks) +in a Javadoc comment. The Check ensures that leading asterisks are +aligned vertically under the first asterisk ( \* ) of opening Javadoc +tag. The alignment of closing Javadoc tag ( \*/ ) is also checked. If a +closing Javadoc tag contains non-whitespace character before it then +it's alignment will be ignored. If the ending javadoc line contains a +leading asterisk, then that leading asterisk's alignment will be +considered, the closing Javadoc tag will be ignored. + +If you're using tabs then specify the the tab width in the +[tabWidth](../../config.html#tabWidth) property. diff --git a/docs/description/LocalFinalVariableName.md b/docs/description/LocalFinalVariableName.md index 4628465..6621111 100644 --- a/docs/description/LocalFinalVariableName.md +++ b/docs/description/LocalFinalVariableName.md @@ -1,3 +1,6 @@ Checks that local final variable names conform to a specified pattern. A catch parameter and resources in try statements are considered to be a local, final variables. + +This check does not support final pattern variables. Instead, use +[PatternVariableName](https://checkstyle.org/patternvariablename.html#PatternVariableName). diff --git a/docs/description/LocalVariableName.md b/docs/description/LocalVariableName.md index 8957d02..a90bc71 100644 --- a/docs/description/LocalVariableName.md +++ b/docs/description/LocalVariableName.md @@ -1,2 +1,5 @@ Checks that local, non-`final` variable names conform to a specified pattern. A catch parameter is considered to be a local variable. + +This check does not support pattern variables. Instead, use +[PatternVariableName](https://checkstyle.org/patternvariablename.html#PatternVariableName). diff --git a/docs/description/MethodParamPad.md b/docs/description/MethodParamPad.md index c281bba..d72a4b6 100644 --- a/docs/description/MethodParamPad.md +++ b/docs/description/MethodParamPad.md @@ -1,8 +1,8 @@ Checks the padding between the identifier of a method definition, -constructor definition, method call, or constructor invocation; and the -left parenthesis of the parameter list. That is, if the identifier and -left parenthesis are on the same line, checks whether a space is -required immediately after the identifier or such a space is forbidden. -If they are not on the same line, reports a violation, unless configured -to allow line breaks. To allow linebreaks after the identifier, set -property `allowLineBreaks` to ` true`. +constructor definition, method call, constructor invocation, record, or +record pattern; and the left parenthesis of the parameter list. That is, +if the identifier and left parenthesis are on the same line, checks +whether a space is required immediately after the identifier or such a +space is forbidden. If they are not on the same line, reports a +violation, unless configured to allow line breaks. To allow linebreaks +after the identifier, set property `allowLineBreaks` to ` true`. diff --git a/docs/description/MissingNullCaseInSwitch.md b/docs/description/MissingNullCaseInSwitch.md new file mode 100644 index 0000000..318a222 --- /dev/null +++ b/docs/description/MissingNullCaseInSwitch.md @@ -0,0 +1,23 @@ +Checks that a given switch statement or expression that use a reference +type in its selector expression has a `null` case label. + +Rationale: switch statements and expressions in Java throw a +`NullPointerException` if the selector expression evaluates to `null`. +As of Java 21, it is now possible to integrate a null check within the +switch, eliminating the risk of `NullPointerException` and simplifies +the code as there is no need for an external null check before entering +the switch. + +See the [Java Language +Specification](https://docs.oracle.com/javase/specs/jls/se22/html/jls-15.html#jls-15.28) +for more information about switch statements and expressions. + +Specifically, this check validates switch statement or expression that +use patterns or strings in their case labels. + +Due to Checkstyle not being type-aware, this check cannot validate other +reference types, such as enums; syntactically, these are no different +from other constants. + +**Attention**: this Check should be activated only on source code that +is compiled by jdk21 or above. diff --git a/docs/description/MissingSwitchDefault.md b/docs/description/MissingSwitchDefault.md index fe01df9..8cd0652 100644 --- a/docs/description/MissingSwitchDefault.md +++ b/docs/description/MissingSwitchDefault.md @@ -17,5 +17,9 @@ checked by the compiler for exhaustiveness. This means that all possible inputs must be covered. See the [Java Language -Specification](https://docs.oracle.com/javase/specs/jls/se17/html/jls-15.html#jls-15.28) +Specification](https://docs.oracle.com/javase/specs/jls/se22/html/jls-15.html#jls-15.28) for more information about switch statements and expressions. + +See the [Java Language +Specification](https://docs.oracle.com/javase/specs/jls/se22/html/jls-14.html#jls-14.30) +for more information about patterns. diff --git a/docs/description/NPathComplexity.md b/docs/description/NPathComplexity.md index 1529d07..599956c 100644 --- a/docs/description/NPathComplexity.md +++ b/docs/description/NPathComplexity.md @@ -40,75 +40,79 @@ Here is some quotes: - + - + - + - + - + - + - + - + + + + + - + - + - + - + - + - + - + - + - + diff --git a/docs/description/OperatorWrap.md b/docs/description/OperatorWrap.md index 214bb64..73bcda6 100644 --- a/docs/description/OperatorWrap.md +++ b/docs/description/OperatorWrap.md @@ -1 +1,6 @@ -Checks the policy on how to wrap lines on operators. +Checks the policy on how to wrap lines on +[operators](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html). + +See the [Java Language +Specification](https://docs.oracle.com/javase/specs/jls/se22/html/jls-15.html#jls-15.20.2) +for more information about {@code instanceof} operator. diff --git a/docs/description/RedundantModifier.md b/docs/description/RedundantModifier.md index 1d15c35..7faeff6 100644 --- a/docs/description/RedundantModifier.md +++ b/docs/description/RedundantModifier.md @@ -14,6 +14,9 @@ The check validates: 5. Nested `enum` definitions that are declared as `static`. 6. `record` definitions that are declared as `final` and nested `record` definitions that are declared as `static`. +7. `strictfp` modifier when using JDK 17 or later. See reason at [JEP + 306](https://openjdk.org/jeps/306) +8. `final` modifier on unnamed variables when using JDK 22 or later. interfaces by definition are abstract so the `abstract` modifier is redundant on them. diff --git a/docs/description/SealedShouldHavePermitsList.md b/docs/description/SealedShouldHavePermitsList.md new file mode 100644 index 0000000..21f1903 --- /dev/null +++ b/docs/description/SealedShouldHavePermitsList.md @@ -0,0 +1,13 @@ +Checks that sealed classes and interfaces have a permits list. + +Rationale: When a permits clause is omitted from a sealed class, any +class within the same compilation unit can extend it. This differs from +other sealed classes where permitted subclasses are explicitly declared, +making them readily visible to the reader. Without a permits clause, +identifying potential subclasses requires searching the entire +compilation unit, which can be challenging, especially in large files +with complex class hierarchies. + +See the [Java Language +Specification](https://docs.oracle.com/javase/specs/jls/se22/html/jls-13.html#jls-13.4.2) +for more information about sealed classes. diff --git a/docs/description/SimplifyBooleanReturn.md b/docs/description/SimplifyBooleanReturn.md index b2b1ab0..e71311f 100644 --- a/docs/description/SimplifyBooleanReturn.md +++ b/docs/description/SimplifyBooleanReturn.md @@ -1,5 +1,5 @@ -Checks for over-complicated boolean return statements. For example the -following code +Checks for over-complicated boolean return or yield statements. For +example the following code if (valid()) return false; diff --git a/docs/description/UnusedCatchParameterShouldBeUnnamed.md b/docs/description/UnusedCatchParameterShouldBeUnnamed.md new file mode 100644 index 0000000..9149e1b --- /dev/null +++ b/docs/description/UnusedCatchParameterShouldBeUnnamed.md @@ -0,0 +1,17 @@ +Ensures that catch parameters that are not used are declared as an +unnamed variable. + +Rationale: + +- Improves code readability by clearly indicating which parameters are + unused. +- Follows Java conventions for denoting unused parameters with an + underscore (`_`). + +See the [Java Language +Specification](https://docs.oracle.com/en/java/javase/21/docs/specs/unnamed-jls.html) +for more information about unnamed variables. + +**Attention**: This check should be activated only on source code that +is compiled by jdk21 or higher; unnamed catch parameters came out as the +first preview in Java 21. diff --git a/docs/description/UnusedLambdaParameterShouldBeUnnamed.md b/docs/description/UnusedLambdaParameterShouldBeUnnamed.md new file mode 100644 index 0000000..7c7771c --- /dev/null +++ b/docs/description/UnusedLambdaParameterShouldBeUnnamed.md @@ -0,0 +1,18 @@ +Ensures that lambda parameters that are not used are declared as an +unnamed variable. + +Rationale: + +- Improves code readability by clearly indicating which parameters are + unused. +- Follows Java conventions for denoting unused parameters with an + underscore (`_`). + +See the [Java Language +Specification](https://docs.oracle.com/en/java/javase/21/docs/specs/unnamed-jls.html) +for more information about unnamed variables. + +**Attention**: Unnamed variables are available as a preview feature in +Java 21, and became an official part of the language in Java 22. This +check should be activated only on source code which meets those +requirements. diff --git a/docs/description/WhenShouldBeUsed.md b/docs/description/WhenShouldBeUsed.md new file mode 100644 index 0000000..4722c2d --- /dev/null +++ b/docs/description/WhenShouldBeUsed.md @@ -0,0 +1,16 @@ +Ensures that `when` is used instead of a single `if` statement inside a +case block. + +Rationale: Java 21 has introduced enhancements for switch statements and +expressions that allow the use of patterns in case labels. The `when` +keyword is used to specify condition for a case label, also called as +guarded case labels. This syntax is more readable and concise than the +single `if` statement inside the pattern match block. + +See the [Java Language +Specification](https://docs.oracle.com/javase/specs/jls/se22/html/jls-14.html#jls-Guard) +for more information about guarded case labels. + +See the [Java Language +Specification](https://docs.oracle.com/javase/specs/jls/se22/html/jls-14.html#jls-14.30) +for more information about patterns. diff --git a/docs/description/description.json b/docs/description/description.json index 1d9ecba..c58366e 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -482,6 +482,9 @@ }, { "name" : "validateEnhancedForLoopVariable", "description" : "Control whether to check enhanced for-loop variable." + }, { + "name" : "validateUnnamedVariables", + "description" : "Control whether to check unnamed variables." } ] }, { "patternId" : "FinalParameters", @@ -489,6 +492,9 @@ "parameters" : [ { "name" : "ignorePrimitiveTypes", "description" : "Ignore primitive types as parameters." + }, { + "name" : "ignoreUnnamedParameters", + "description" : "Ignore unnamed parameters." }, { "name" : "tokens", "description" : "tokens to check" @@ -787,6 +793,13 @@ "name" : "location", "description" : "Specify the policy on placement of the Javadoc content." } ] +}, { + "patternId" : "JavadocLeadingAsteriskAlign", + "title" : "JavadocLeadingAsteriskAlign", + "parameters" : [ { + "name" : "violateExecutionOnNonTightHtml", + "description" : "Control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules." + } ] }, { "patternId" : "JavadocMethod", "title" : "JavadocMethod", @@ -1166,6 +1179,10 @@ "name" : "tokens", "description" : "tokens to check" } ] +}, { + "patternId" : "MissingNullCaseInSwitch", + "title" : "MissingNullCaseInSwitch", + "parameters" : [ ] }, { "patternId" : "MissingOverride", "title" : "MissingOverride", @@ -1470,6 +1487,9 @@ "patternId" : "RedundantModifier", "title" : "RedundantModifier", "parameters" : [ { + "name" : "jdkVersion", + "description" : "jdkVersion" + }, { "name" : "tokens", "description" : "tokens to check" } ] @@ -1645,6 +1665,10 @@ "name" : "tokens", "description" : "tokens to check" } ] +}, { + "patternId" : "SealedShouldHavePermitsList", + "title" : "SealedShouldHavePermitsList", + "parameters" : [ ] }, { "patternId" : "SeparatorWrap", "title" : "SeparatorWrap", @@ -1714,7 +1738,7 @@ "description" : "Specify the regexp for forbidden summary fragments." }, { "name" : "period", - "description" : "Specify the period symbol at the end of first javadoc sentence." + "description" : "period" }, { "name" : "violateExecutionOnNonTightHtml", "description" : "Control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules." @@ -1859,6 +1883,10 @@ "name" : "allowWhenNoBraceAfterSemicolon", "description" : "Allow unnecessary semicolon if closing paren is not on the same line." } ] +}, { + "patternId" : "UnusedCatchParameterShouldBeUnnamed", + "title" : "UnusedCatchParameterShouldBeUnnamed", + "parameters" : [ ] }, { "patternId" : "UnusedImports", "title" : "UnusedImports", @@ -1866,10 +1894,17 @@ "name" : "processJavadoc", "description" : "Control whether to process Javadoc comments." } ] +}, { + "patternId" : "UnusedLambdaParameterShouldBeUnnamed", + "title" : "UnusedLambdaParameterShouldBeUnnamed", + "parameters" : [ ] }, { "patternId" : "UnusedLocalVariable", "title" : "UnusedLocalVariable", - "parameters" : [ ] + "parameters" : [ { + "name" : "allowUnnamedVariables", + "description" : "Allow variables named with a single underscore (known as unnamed variables in Java 21+)." + } ] }, { "patternId" : "UpperEll", "title" : "UpperEll", @@ -1915,6 +1950,10 @@ "name" : "publicMemberPattern", "description" : "Specify pattern for public members that should be ignored." } ] +}, { + "patternId" : "WhenShouldBeUsed", + "title" : "WhenShouldBeUsed", + "parameters" : [ ] }, { "patternId" : "WhitespaceAfter", "title" : "WhitespaceAfter", diff --git a/docs/patterns.json b/docs/patterns.json index 12cd926..d1f60d5 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,6 +1,6 @@ { "name" : "checkstyle", - "version" : "10.17.0", + "version" : "10.18.2", "patterns" : [ { "patternId" : "AbbreviationAsWordInName", "level" : "Info", @@ -231,7 +231,7 @@ "category" : "CodeStyle", "parameters" : [ { "name" : "format", - "default" : "^(e|t|ex|[a-z][a-z][a-zA-Z]+)$" + "default" : "^(e|t|ex|[a-z][a-z][a-zA-Z]+|_)$" } ], "languages" : [ ], "enabled" : false @@ -382,7 +382,7 @@ "default" : false }, { "name" : "tokens", - "default" : "LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_SWITCH, LITERAL_CASE, LITERAL_CATCH, QUESTION, LAND, LOR" + "default" : "LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_SWITCH, LITERAL_CASE, LITERAL_CATCH, QUESTION, LAND, LOR, LITERAL_WHEN" } ], "languages" : [ ], "enabled" : false @@ -624,6 +624,9 @@ }, { "name" : "validateEnhancedForLoopVariable", "default" : false + }, { + "name" : "validateUnnamedVariables", + "default" : false } ], "languages" : [ ], "enabled" : false @@ -634,6 +637,9 @@ "parameters" : [ { "name" : "ignorePrimitiveTypes", "default" : false + }, { + "name" : "ignoreUnnamedParameters", + "default" : true }, { "name" : "tokens", "default" : "METHOD_DEF, CTOR_DEF" @@ -714,7 +720,7 @@ "category" : "CodeStyle", "parameters" : [ { "name" : "format", - "default" : "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$" + "default" : "(?i)^(?!(record|yield|var|permits|sealed)$).+$" }, { "name" : "tokens", "default" : "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, ENUM_CONSTANT_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, RECORD_COMPONENT_DEF, LAMBDA" @@ -813,7 +819,7 @@ "default" : "" }, { "name" : "tokens", - "default" : "ANNOTATION_FIELD_DEF, CLASS_DEF, INTERFACE_DEF, METHOD_CALL, METHOD_DEF, METHOD_REF, PARAMETER_DEF, VARIABLE_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, RECORD_COMPONENT_DEF" + "default" : "ANNOTATION_FIELD_DEF, CLASS_DEF, INTERFACE_DEF, METHOD_CALL, METHOD_DEF, METHOD_REF, PARAMETER_DEF, VARIABLE_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, RECORD_COMPONENT_DEF, RECORD_PATTERN_DEF" }, { "name" : "validateAbstractClassNames", "default" : false @@ -1006,6 +1012,16 @@ } ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "JavadocLeadingAsteriskAlign", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ { + "name" : "violateExecutionOnNonTightHtml", + "default" : false + } ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "JavadocMethod", "level" : "Info", @@ -1184,7 +1200,7 @@ "category" : "CodeStyle", "parameters" : [ { "name" : "format", - "default" : "^[a-z][a-zA-Z0-9]*$" + "default" : "^([a-z][a-zA-Z0-9]*|_)$" } ], "languages" : [ ], "enabled" : false @@ -1226,7 +1242,7 @@ "category" : "CodeStyle", "parameters" : [ { "name" : "format", - "default" : "^[a-z][a-zA-Z0-9]*$" + "default" : "^([a-z][a-zA-Z0-9]*|_)$" }, { "name" : "tokens", "default" : "VARIABLE_DEF, PARAMETER_DEF, RESOURCE" @@ -1242,7 +1258,7 @@ "default" : false }, { "name" : "format", - "default" : "^[a-z][a-zA-Z0-9]*$" + "default" : "^([a-z][a-zA-Z0-9]*|_)$" } ], "languages" : [ ], "enabled" : false @@ -1384,7 +1400,7 @@ "default" : "nospace" }, { "name" : "tokens", - "default" : "CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF, SUPER_CTOR_CALL, ENUM_CONSTANT_DEF, RECORD_DEF" + "default" : "CTOR_DEF, CTOR_CALL, LITERAL_NEW, METHOD_CALL, METHOD_DEF, SUPER_CTOR_CALL, ENUM_CONSTANT_DEF, RECORD_DEF, RECORD_PATTERN_DEF" } ], "languages" : [ ], "enabled" : false @@ -1469,6 +1485,13 @@ } ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "MissingNullCaseInSwitch", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "MissingOverride", "level" : "Info", @@ -1841,7 +1864,7 @@ "default" : "nospace" }, { "name" : "tokens", - "default" : "ANNOTATION, ANNOTATION_FIELD_DEF, CTOR_CALL, CTOR_DEF, DOT, ENUM_CONSTANT_DEF, EXPR, LITERAL_CATCH, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_NEW, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, METHOD_CALL, METHOD_DEF, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA, RECORD_DEF" + "default" : "ANNOTATION, ANNOTATION_FIELD_DEF, CTOR_CALL, CTOR_DEF, DOT, ENUM_CONSTANT_DEF, EXPR, LITERAL_CATCH, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_NEW, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, METHOD_CALL, METHOD_DEF, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA, RECORD_DEF, RECORD_PATTERN_DEF" } ], "languages" : [ ], "enabled" : false @@ -1851,7 +1874,7 @@ "category" : "CodeStyle", "parameters" : [ { "name" : "format", - "default" : "^[a-z][a-zA-Z0-9]*$" + "default" : "^([a-z][a-zA-Z0-9]*|_)$" } ], "languages" : [ ], "enabled" : false @@ -1900,8 +1923,11 @@ "level" : "Info", "category" : "CodeStyle", "parameters" : [ { + "name" : "jdkVersion", + "default" : "22" + }, { "name" : "tokens", - "default" : "METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CTOR_DEF, CLASS_DEF, ENUM_DEF, RESOURCE, ANNOTATION_DEF, RECORD_DEF" + "default" : "METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF, CTOR_DEF, CLASS_DEF, ENUM_DEF, RESOURCE, ANNOTATION_DEF, RECORD_DEF, PATTERN_VARIABLE_DEF, LITERAL_CATCH, LAMBDA" } ], "languages" : [ ], "enabled" : false @@ -2107,6 +2133,13 @@ } ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "SealedShouldHavePermitsList", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "SeparatorWrap", "level" : "Info", @@ -2228,7 +2261,7 @@ "default" : "^\\s*+$" }, { "name" : "tokens", - "default" : "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF, PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, CTOR_DEF, COMPACT_CTOR_DEF, RECORD_DEF" + "default" : "CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF, PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, CTOR_DEF, COMPACT_CTOR_DEF, RECORD_DEF, PATTERN_VARIABLE_DEF" } ], "languages" : [ ], "enabled" : false @@ -2396,6 +2429,13 @@ } ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "UnusedCatchParameterShouldBeUnnamed", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "UnusedImports", "level" : "Info", @@ -2407,12 +2447,22 @@ "languages" : [ ], "enabled" : true }, { - "patternId" : "UnusedLocalVariable", + "patternId" : "UnusedLambdaParameterShouldBeUnnamed", "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "UnusedLocalVariable", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ { + "name" : "allowUnnamedVariables", + "default" : true + } ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "UpperEll", "level" : "Info", @@ -2467,13 +2517,20 @@ } ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "WhenShouldBeUsed", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "WhitespaceAfter", "level" : "Info", "category" : "CodeStyle", "parameters" : [ { "name" : "tokens", - "default" : "COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE, LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, LITERAL_FINALLY, LITERAL_RETURN, LITERAL_YIELD, LITERAL_CATCH, DO_WHILE, ELLIPSIS, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_CASE, LAMBDA" + "default" : "COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE, LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, LITERAL_FINALLY, LITERAL_RETURN, LITERAL_YIELD, LITERAL_CATCH, DO_WHILE, ELLIPSIS, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_CASE, LAMBDA, LITERAL_WHEN" } ], "languages" : [ ], "enabled" : false @@ -2504,7 +2561,7 @@ "default" : true }, { "name" : "tokens", - "default" : "ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND" + "default" : "ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND, LITERAL_WHEN" } ], "languages" : [ ], "enabled" : false
Examples
Structure Complexity expression
if ([expr]) { [if-range] } NP(if-range) + 1 + NP(expr)
if ([expr]) { [if-range] } else { [else-range] } NP(if-range) + NP(else-range) + NP(expr)
while ([expr]) { [while-range] } NP(while-range) + NP(expr) + 1
do { [do-range] } while ([expr]) NP(do-range) + NP(expr) + 1
for([expr1]; [expr2]; [expr3]) { [for-range] } NP(for-range) + NP(expr1) + NP(expr2) + NP(expr3) + 1
switch ([expr]) { case : [case-range] default: [default-range] } S(i=1:i=n)NP(case-range[i]) + NP(default-range) + NP(expr)
when[expr]NP(expr) + 1
[expr1] ? [expr2] : [expr3] NP(expr1) + NP(expr2) + NP(expr3) + 2
goto label 1
break 1
Expressions Number of && and || operators in expression. No operators - 0
continue 1
return 1
Statement (even sequential statements) 1
Empty block {} 1
Function call 1
Function(Method) declaration or Block P(i=1:i=N)NP(Statement[i])