From 954e79d88e251379537f5bccc21a196f51f4ec41 Mon Sep 17 00:00:00 2001 From: "lijindong (C)" Date: Wed, 17 Jul 2024 17:19:28 +0800 Subject: [PATCH] add java standard --- .../devkit/code/inspector/MetricsTest.java | 75 +++++++ .../code/inspector/MiscellaneousTest.java | 121 +++++++++++ .../devkit/code/inspector/ModifiersTest.java | 30 +++ .../code/inspector/NamingConventionsTest.java | 198 ++++++++++++++++++ .../BooleanExpressionComplexityCase.java | 17 ++ .../ClassDataAbstractionCouplingCase.java | 7 + .../metrics/ClassFanOutComplexityCase.java | 18 ++ .../metrics/CyclomaticComplexityCase.java | 35 ++++ .../resources/case/metrics/JavaNCSSCase.java | 56 +++++ .../case/metrics/NPathComplexityCase.java | 54 +++++ .../miscellaneous/ArrayTypeStyleCase.java | 12 ++ .../AvoidEscapedUnicodeCharactersCase.java | 19 ++ .../CommentsIndentationCase.java | 19 ++ .../miscellaneous/DescendantTokenCase.java | 71 +++++++ .../case/miscellaneous/IndentationCase.java | 27 +++ .../miscellaneous/NewlineAtEndOfFileCase.java | 3 + .../case/miscellaneous/NoCodeInFileCase.java | 3 + .../miscellaneous/OuterTypeFilenameCase.java | 2 + .../case/miscellaneous/TodoCommentCase.java | 10 + .../case/miscellaneous/UpperEllCase.java | 5 + .../case/modifiers/ModifierOrderCase.java | 6 + .../case/modifiers/RedundantModifierCase.java | 18 ++ .../AbbreviationAsWordInNameCase.java | 20 ++ .../ClassTypeParameterNameCase.java | 4 + .../naming_conventions/ConstantNameCase.java | 11 + .../IllegalIdentifierNameCase.java | 3 + .../InterfaceTypeParameterNameCase.java | 15 ++ .../LocalFinalVariableNameCase.java | 11 + .../LocalVariableNameCase.java | 8 + .../naming_conventions/MemberNameCase.java | 17 ++ .../naming_conventions/MethodNameCase.java | 4 + .../MethodTypeParameterNameCase.java | 6 + .../naming_conventions/PackageNameCase.java | 11 + .../naming_conventions/ParameterNameCase.java | 4 + .../PatternVariableNameCase.java | 8 + .../RecordComponentNameCase.java | 11 + .../RecordTypeParameterNameCase.java | 6 + .../StaticVariableNameCase.java | 12 ++ .../case/naming_conventions/TypeNameCase.java | 6 + .../metrics/BooleanExpressionComplexity.xml | 18 ++ .../metrics/ClassDataAbstractionCoupling.xml | 18 ++ .../metrics/ClassFanOutComplexity.xml | 18 ++ .../metrics/CyclomaticComplexity.xml | 18 ++ .../single_rules/metrics/JavaNCSS.xml | 18 ++ .../single_rules/metrics/NPathComplexity.xml | 18 ++ .../miscellaneous/ArrayTypeStyle.xml | 18 ++ .../AvoidEscapedUnicodeCharacters.xml | 16 ++ .../miscellaneous/CommentsIndentation.xml | 16 ++ .../miscellaneous/DescendantToken.xml | 40 ++++ .../miscellaneous/FinalParameters.xml | 15 ++ .../miscellaneous/Indentation.xml | 24 +++ .../miscellaneous/NewlineAtEndOfFile.xml | 16 ++ .../miscellaneous/NoCodeInFile.xml | 16 ++ .../miscellaneous/OuterTypeFilename.xml | 16 ++ .../miscellaneous/TodoComment.xml | 16 ++ .../single_rules/miscellaneous/UpperEll.xml | 16 ++ .../single_rules/modifiers/ModifierOrder.xml | 16 ++ .../modifiers/RedundantModifier.xml | 16 ++ .../AbbreviationAsWordInName.xml | 16 ++ .../ClassTypeParameterName.xml | 18 ++ .../naming_conventions/ConstantName.xml | 16 ++ .../IllegalIdentifierName.xml | 19 ++ .../InterfaceTypeParameterName.xml | 18 ++ .../LocalFinalVariableName.xml | 18 ++ .../naming_conventions/LocalVariableName.xml | 16 ++ .../naming_conventions/MemberName.xml | 16 ++ .../naming_conventions/MethodName.xml | 16 ++ .../MethodTypeParameterName.xml | 16 ++ .../naming_conventions/PackageName.xml | 16 ++ .../naming_conventions/ParameterName.xml | 16 ++ .../PatternVariableName.xml | 16 ++ .../RecordComponentName.xml | 16 ++ .../RecordTypeParameterName.xml | 16 ++ .../naming_conventions/StaticVariableName.xml | 18 ++ .../naming_conventions/TypeName.xml | 19 ++ 75 files changed, 1598 insertions(+) create mode 100644 component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/MetricsTest.java create mode 100644 component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/MiscellaneousTest.java create mode 100644 component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/ModifiersTest.java create mode 100644 component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/NamingConventionsTest.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/metrics/BooleanExpressionComplexityCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/metrics/ClassDataAbstractionCouplingCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/metrics/ClassFanOutComplexityCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/metrics/CyclomaticComplexityCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/metrics/JavaNCSSCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/metrics/NPathComplexityCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/ArrayTypeStyleCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/AvoidEscapedUnicodeCharactersCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/CommentsIndentationCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/DescendantTokenCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/IndentationCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/NewlineAtEndOfFileCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/NoCodeInFileCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/OuterTypeFilenameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/TodoCommentCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/UpperEllCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/modifiers/ModifierOrderCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/modifiers/RedundantModifierCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/AbbreviationAsWordInNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ClassTypeParameterNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ConstantNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/IllegalIdentifierNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/InterfaceTypeParameterNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/LocalFinalVariableNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/LocalVariableNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MemberNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MethodNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MethodTypeParameterNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/PackageNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ParameterNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/PatternVariableNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/RecordComponentNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/RecordTypeParameterNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/StaticVariableNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/TypeNameCase.java create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/BooleanExpressionComplexity.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/ClassDataAbstractionCoupling.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/ClassFanOutComplexity.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/CyclomaticComplexity.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/JavaNCSS.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/NPathComplexity.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/ArrayTypeStyle.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/AvoidEscapedUnicodeCharacters.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/CommentsIndentation.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/DescendantToken.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/FinalParameters.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/Indentation.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/NewlineAtEndOfFile.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/NoCodeInFile.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/OuterTypeFilename.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/TodoComment.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/UpperEll.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/modifiers/ModifierOrder.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/modifiers/RedundantModifier.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/AbbreviationAsWordInName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ClassTypeParameterName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ConstantName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/IllegalIdentifierName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/InterfaceTypeParameterName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/LocalFinalVariableName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/LocalVariableName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MemberName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MethodName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MethodTypeParameterName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/PackageName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ParameterName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/PatternVariableName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/RecordComponentName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/RecordTypeParameterName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/StaticVariableName.xml create mode 100644 component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/TypeName.xml diff --git a/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/MetricsTest.java b/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/MetricsTest.java new file mode 100644 index 0000000..1134716 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/MetricsTest.java @@ -0,0 +1,75 @@ +package com.huawei.devkit.code.inspector; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Objects; + +public class MetricsTest { + @Test + void testBooleanExpressionComplexity() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/metrics/BooleanExpressionComplexityCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/metrics/BooleanExpressionComplexity.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testBooleanExpressionComplexity.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testClassDataAbstractionCouplingCase() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/metrics/ClassDataAbstractionCouplingCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/metrics/ClassDataAbstractionCoupling.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testClassDataAbstractionCoupling.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + + @Test + void testClassFanOutComplexityCase() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/metrics/ClassFanOutComplexityCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/metrics/ClassFanOutComplexity.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testClassFanOutComplexity.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testCyclomaticComplexityCase() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/metrics/CyclomaticComplexityCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/metrics/CyclomaticComplexity.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testCyclomaticComplexity.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testJavaNCSSCase() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/metrics/JavaNCSSCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/metrics/JavaNCSS.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testJavaNCSSCase.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testNPathComplexity() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/metrics/NPathComplexityCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/metrics/NPathComplexity.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testNPathComplexity.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } +} diff --git a/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/MiscellaneousTest.java b/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/MiscellaneousTest.java new file mode 100644 index 0000000..9096945 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/MiscellaneousTest.java @@ -0,0 +1,121 @@ +package com.huawei.devkit.code.inspector; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Objects; + +public class MiscellaneousTest { + + @Test + void testArrayTypeStyle() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/ArrayTypeStyleCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/ArrayTypeStyle.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testArrayTypeStyle.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testAvoidEscapedUnicodeCharacters() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/AvoidEscapedUnicodeCharactersCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/AvoidEscapedUnicodeCharacters.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testAvoidEscapedUnicodeCharacters.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testCommentsIndentation() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/CommentsIndentationCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/CommentsIndentation.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testCommentsIndentation.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testDescendantToken() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/DescendantTokenCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/DescendantToken.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testDescendantToken.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testIndentation() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/IndentationCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/Indentation.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testIndentation.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testNewlineAtEndOfFile() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/NewlineAtEndOfFileCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/NewlineAtEndOfFile.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testNewlineAtEndOfFile.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testNoCodeInFile() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/NoCodeInFileCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/NoCodeInFile.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testNoCodeInFile.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testOuterTypeFilename() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/OuterTypeFilenameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/OuterTypeFilename.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testOuterTypeFilename.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testTodoComment() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/TodoCommentCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/TodoComment.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testTodoComment.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testUpperEll() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/miscellaneous/UpperEllCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/miscellaneous/UpperEll.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testUpperEll.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + +} diff --git a/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/ModifiersTest.java b/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/ModifiersTest.java new file mode 100644 index 0000000..364dd91 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/ModifiersTest.java @@ -0,0 +1,30 @@ +package com.huawei.devkit.code.inspector; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Objects; + +public class ModifiersTest { + @Test + void testModifierOrder() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/modifiers/ModifierOrderCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/modifiers/ModifierOrder.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testModifierOrder.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testRedundantModifier() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/modifiers/RedundantModifierCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/modifiers/RedundantModifier.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testRedundantModifier.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } +} diff --git a/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/NamingConventionsTest.java b/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/NamingConventionsTest.java new file mode 100644 index 0000000..28ea2bd --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/java/com/huawei/devkit/code/inspector/NamingConventionsTest.java @@ -0,0 +1,198 @@ +package com.huawei.devkit.code.inspector; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Objects; + +public class NamingConventionsTest { + + @Test + void testRedundantModifier() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/AbbreviationAsWordInNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/AbbreviationAsWordInName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testAbbreviationAsWordInName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testClassTypeParameterName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/ClassTypeParameterNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/ClassTypeParameterName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testClassTypeParameterName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testConstantName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/ConstantNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/ConstantName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testConstantName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testIllegalIdentifierName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/IllegalIdentifierNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/IllegalIdentifierName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testIllegalIdentifierName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testInterfaceTypeParameterName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/InterfaceTypeParameterNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/InterfaceTypeParameterName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testInterfaceTypeParameterName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testLocalFinalVariableName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/LocalFinalVariableNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/LocalFinalVariableName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testLocalFinalVariableName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testLocalVariableName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/LocalVariableNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/LocalVariableName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testLocalVariableName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testMemberName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/MemberNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/MemberName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testMemberName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testMethodName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/MethodNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/MethodName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testMethodName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testMethodTypeParameterName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/MethodTypeParameterNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/MethodTypeParameterName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testMethodTypeParameterName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testPackageName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/PackageNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/PackageName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testPackageName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testParameterName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/ParameterNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/ParameterName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testParameterName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testPatternVariableName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/PatternVariableNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/PatternVariableName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testPatternVariableName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testRecordComponentName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/RecordComponentNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/RecordComponentName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testRecordComponentName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testRecordTypeParameterName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/RecordTypeParameterNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/RecordTypeParameterName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testRecordTypeParameterName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testStaticVariableName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/StaticVariableNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/StaticVariableName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testStaticVariableName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + @Test + void testTypeName() { + String root = System.getProperty("user.dir"); + String filePath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("case/naming_conventions/TypeNameCase.java")).getPath(); + String configPath = Objects.requireNonNull(this.getClass().getClassLoader() + .getResource("single_rules/naming_conventions/TypeName.xml")).getPath(); + String[] args = new String[]{"-c", configPath, "-o", root + "/testTypeName.out", "-f", "sarif", filePath}; + Assertions.assertDoesNotThrow(() -> CodeInspector.main(args)); + } + + +} diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/metrics/BooleanExpressionComplexityCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/BooleanExpressionComplexityCase.java new file mode 100644 index 0000000..eacc9e4 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/BooleanExpressionComplexityCase.java @@ -0,0 +1,17 @@ +public class BooleanExpressionComplexityCase +{ + public static void main(String ... args) + { + boolean a = true; + boolean b = false; + + boolean c = (a & b) | (b ^ a); // OK, 1(&) + 1(|) + 1(^) = 3 (max allowed 5) + + boolean d = (a & b) | (b ^ a) | (a ^ b); + // OK above, 1(&) + 1(|) + 1(^) + 1(|) + 1(^) = 5 + + boolean e = a ^ (a || b) ^ (b || a) & (a | b); + // violation above, 'Boolean expression complexity is 6 (max allowed is 5)' + // 1(^) + 1(||) + 1(^) + 1(||) + 1(&) + 1(|) = 6 + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/metrics/ClassDataAbstractionCouplingCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/ClassDataAbstractionCouplingCase.java new file mode 100644 index 0000000..2adba87 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/ClassDataAbstractionCouplingCase.java @@ -0,0 +1,7 @@ +public class ClassDataAbstractionCouplingCase { + Set set = new HashSet(); // HashSet ignored due to default excludedClasses property + Map map = new HashMap(); // HashMap ignored due to default excludedClasses property + Date date = new Date(); // Counted, 1 + Time time = new Time(); // Counted, 2 + Place place = new Place(); // Counted, 3 +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/metrics/ClassFanOutComplexityCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/ClassFanOutComplexityCase.java new file mode 100644 index 0000000..0ddf1f5 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/ClassFanOutComplexityCase.java @@ -0,0 +1,18 @@ +import java.sql.Time; + +public class ClassFanOutComplexityCase { + Set set = new HashSet(); // Set, HashSet ignored due to default excludedClasses property + Map map = new HashMap(); // Map, HashMap ignored due to default excludedClasses property + Date date = new Date(); // Counted, 1 + Time time = new Time(); // Counted, 2 + Place place = new Place(); // Counted, 3 + int value = 10; // int is ignored due to default excludedClasses property + + void method() { + var result = "result"; // var is ignored due to default excludedClasses property + } + + public void setTime() { + Time time1 = new Time(); + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/metrics/CyclomaticComplexityCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/CyclomaticComplexityCase.java new file mode 100644 index 0000000..700d33e --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/CyclomaticComplexityCase.java @@ -0,0 +1,35 @@ +public class CyclomaticComplexityCase +{ + // Cyclomatic Complexity = 11 + int a, b, c, d, n; + public void foo() { // 1, function declaration + if (a == 1) { // 2, if + fun1(); + } else if (a == b // 3, if + && a == c) { // 4, && operator + if (c == 2) { // 5, if + fun2(); + } + } else if (a == d) { // 6, if + try { + fun4(); + } catch (Exception e) { // 7, catch + } + } else { + switch(n) { + case 1: // 8, case + fun1(); + break; + case 2: // 9, case + fun2(); + break; + case 3: // 10, case + fun3(); + break; + default: + break; + } + } + d = a < 0 ? -1 : 1; // 11, ternary operator + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/metrics/JavaNCSSCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/JavaNCSSCase.java new file mode 100644 index 0000000..f80877a --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/JavaNCSSCase.java @@ -0,0 +1,56 @@ +public class JavaNCSSCase { + public static void main(String[] args) { + System.out.println("Line 1"); + System.out.println("Line 2"); + System.out.println("Line 3"); + System.out.println("Line 4"); + System.out.println("Line 5"); + System.out.println("Line 6"); + // it's line 7 + System.out.println("Line 7"); + System.out.println("Line 8"); + System.out.println("Line 9"); + System.out.println("Line 10"); + System.out.println("Line 11"); + System.out.println("Line 12"); + System.out.println("Line 13"); + System.out.println("Line 14"); + System.out.println("Line 15"); + System.out.println("Line 16"); + System.out.println("Line 17"); + System.out.println("Line 18"); + System.out.println("Line 19"); + System.out.println("Line 20"); + System.out.println("Line 21"); + System.out.println("Line 22"); + System.out.println("Line 23"); + System.out.println("Line 24"); + System.out.println("Line 25"); + System.out.println("Line 26"); + System.out.println("Line 27"); + System.out.println("Line 28"); + System.out.println("Line 29"); + System.out.println("Line 30"); + System.out.println("Line 31"); + System.out.println("Line 32"); + System.out.println("Line 33"); + System.out.println("Line 34"); + System.out.println("Line 35"); + System.out.println("Line 36"); + System.out.println("Line 37"); + System.out.println("Line 38"); + System.out.println("Line 39"); + System.out.println("Line 40"); + System.out.println("Line 41"); + System.out.println("Line 42"); + System.out.println("Line 43"); + System.out.println("Line 44"); + System.out.println("Line 45"); + System.out.println("Line 46"); + System.out.println("Line 47"); + System.out.println("Line 48"); + System.out.println("Line 49"); + System.out.println("Line 50"); // OK + System.out.println("Line 51"); // violation, the method crosses 50 non commented lines + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/metrics/NPathComplexityCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/NPathComplexityCase.java new file mode 100644 index 0000000..5125b23 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/metrics/NPathComplexityCase.java @@ -0,0 +1,54 @@ +public class NPathComplexityCase { + + final int a = 0; + int b = 0; + + public void foo() { // OK, NPath complexity is less than default threshold + // function consists of one if-else block with an NPath Complexity of 3 + if (a > 10) { + if (a > b) { // nested if-else decision tree adds 2 to the complexity count + buzz(); + } else { + fizz(); + } + } else { // last possible outcome of the main if-else block, adds 1 to complexity + buzz(); + } + } + + public void boo() { // violation, NPath complexity is 217 (max allowed is 200) + // looping through 3 switch statements produces 6^3 + 1 (217) possible outcomes + for (int i = 0; i < b; i++) { // for statement adds 1 to final complexity + switch (i) { // each independent switch statement multiplies complexity by 6 + case a: + // ternary with && adds 3 to switch's complexity + print(f(i) && g(i) ? fizz() : buzz()); + default: + // ternary with || adds 3 to switch's complexity + print(f(i) || g(i) ? fizz() : buzz()); + } + switch (i - 1) { // multiplies complexity by 6 + case a: + print(f(i) && g(i) ? fizz() : buzz()); + default: + print(f(i) || g(i) ? fizz() : buzz()); + } + switch (i + 1) { // multiplies complexity by 6 + case a: + print(f(i) && g(i) ? fizz() : buzz()); + default: + print(f(i) || g(i) ? fizz() : buzz()); + } + } + } + + public abstract boolean f(int x); + + public abstract boolean g(int x); + + public abstract String fizz(); + + public abstract String buzz(); + + public abstract void print(String str); +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/ArrayTypeStyleCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/ArrayTypeStyleCase.java new file mode 100644 index 0000000..ff545bc --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/ArrayTypeStyleCase.java @@ -0,0 +1,12 @@ +public class ArrayTypeStyleCase { + int[] nums; // violation, 'Array brackets at illegal position' + String strings[]; // OK as follows C style since 'javaStyle' set to false + + char[] toCharArray() { // OK + return null; + } + + byte getData()[] { // violation, 'Array brackets at illegal position' + return null; + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/AvoidEscapedUnicodeCharactersCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/AvoidEscapedUnicodeCharactersCase.java new file mode 100644 index 0000000..ef37334 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/AvoidEscapedUnicodeCharactersCase.java @@ -0,0 +1,19 @@ +public class AvoidEscapedUnicodeCharactersCase { + // OK, perfectly clear even without a comment. + String unitAbbrev = "μs"; + // violation below, the reader has no idea what this is. 'should be avoided.' + String unitAbbrev1 = "\u03bcs"; + // violation below + String unitAbbrev2 = "\u03bc\u03bc\u03bc"; + // violation below + String unitAbbrev3 = "\u03bcs"; // it is μs + // violation below + String unitAbbrev4 = "\u03bc\u03bcs"; + + public static int content() { + char content = 'r'; + // violation below + return '\ufeff' + content; + } + +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/CommentsIndentationCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/CommentsIndentationCase.java new file mode 100644 index 0000000..8716c12 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/CommentsIndentationCase.java @@ -0,0 +1,19 @@ +public class CommentsIndentationCase { + boolean bool = true; + double d = 3.14; + + public void foo43() { + try { + int a; + if (a > 0) { + System.out.println("a > 0"); + // a < 0 + } else if (a < 0) { + System.out.println("a < 0"); + } + // 为什么我们要在这里捕获异常? + } catch (IOException e) { + + } + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/DescendantTokenCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/DescendantTokenCase.java new file mode 100644 index 0000000..dcec0e8 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/DescendantTokenCase.java @@ -0,0 +1,71 @@ +public class DescendantTokenCase { + + public void foo1() { + int x = 1; + int y = 2; + switch (x) { // ok + case 1: + System.out.println("xyz"); + break; + } + switch (y) { // violation + case 1: + switch (y) { + case 2: + System.out.println("xyz"); + break; + } + break; + } + } + + public void foo2() { + try { + // Some code + } catch (Exception e) { // ok + System.out.println("xyz"); + return; + } finally { // ok + System.out.println("xyz"); + } + try { + // Some code + } catch (Exception e) { + try { // violation + // Some code + } catch (Exception ex) { + // handle exception + } + } finally { + try { // violation + // Some code + } catch (Exception e) { + // handle exception + } + } + } + + public void foo3() { + int[] array = new int[]{1, 2, 3, 4, 5}; + + for (int i = 0; i != array.length; i++) { // ok + System.out.println(i); + } + + int j = 0; + for (; j != array.length; ) { // violation + System.out.println(j); + j++; + } + } + + public void foo4() { + for (int i = 0; i != 10; i++) { // ok + System.out.println(i); + } + int k = 0; + for (; ; ) { // violation + System.out.println(k); + } + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/IndentationCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/IndentationCase.java new file mode 100644 index 0000000..73ca711 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/IndentationCase.java @@ -0,0 +1,27 @@ +public class IndentationCase { + String field; // basicOffset + int[] arr = { // basicOffset + 5, // arrayInitIndent + 6 }; // arrayInitIndent + void bar() throws Exception // basicOffset + { // braceAdjustment + foo(); // basicOffset + } // braceAdjustment + void foo() { // basicOffset + if ((cond1 && cond2) // basicOffset + || (cond3 && cond4) // lineWrappingIndentation, forceStrictCondition + ||!(cond5 && cond6)) { // lineWrappingIndentation, forceStrictCondition + field.doSomething() // basicOffset + .doSomething() // lineWrappingIndentation and forceStrictCondition + .doSomething( c -> { // lineWrappingIndentation and forceStrictCondition + return c.doSome(); // basicOffset + }); + } + } + void fooCase() // basicOffset + throws Exception { // throwsIndent + switch (field) { // basicOffset + case "value" : bar(); // caseIndent + } + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/NewlineAtEndOfFileCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/NewlineAtEndOfFileCase.java new file mode 100644 index 0000000..809e69e --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/NewlineAtEndOfFileCase.java @@ -0,0 +1,3 @@ +public class NewlineAtEndOfFileCase { // +// +} // no below it is violation diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/NoCodeInFileCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/NoCodeInFileCase.java new file mode 100644 index 0000000..e6fc693 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/NoCodeInFileCase.java @@ -0,0 +1,3 @@ +//public class NoCodeInFileCase { +// signal +//} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/OuterTypeFilenameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/OuterTypeFilenameCase.java new file mode 100644 index 0000000..6815c84 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/OuterTypeFilenameCase.java @@ -0,0 +1,2 @@ +public class Outer2TypeFilenameCase { +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/TodoCommentCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/TodoCommentCase.java new file mode 100644 index 0000000..6a98108 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/TodoCommentCase.java @@ -0,0 +1,10 @@ +public class TodoCommentCase { + int i; + int x; + public void test() { + i++; // TODO: do differently in future // violation + i++; // todo: do differently in future + i=i/x; // FIXME: handle x = 0 case + i=i/x; // FIX : handle x = 0 case + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/UpperEllCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/UpperEllCase.java new file mode 100644 index 0000000..9ce6001 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/miscellaneous/UpperEllCase.java @@ -0,0 +1,5 @@ +public class UpperEllCase { + long var1 = 508987; // OK + long var2 = 508987l; // violation + long var3 = 508987L; // OK +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/modifiers/ModifierOrderCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/modifiers/ModifierOrderCase.java new file mode 100644 index 0000000..2c83fa2 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/modifiers/ModifierOrderCase.java @@ -0,0 +1,6 @@ +public class ModifierOrderCase { + + public final static foo() { + + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/modifiers/RedundantModifierCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/modifiers/RedundantModifierCase.java new file mode 100644 index 0000000..24c23ea --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/modifiers/RedundantModifierCase.java @@ -0,0 +1,18 @@ +public class RedundantModifierCase { + +} + +class PackagePrivateClass { + public PackagePrivateClass() {} // violation expected +} + +public enum EnumClass { + FIELD_1, + FIELD_2 { + @Override + public final void method1() {} // violation expected + }; + + public void method1() {} + public final void method2() {} // no violation expected +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/AbbreviationAsWordInNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/AbbreviationAsWordInNameCase.java new file mode 100644 index 0000000..3c6f44b --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/AbbreviationAsWordInNameCase.java @@ -0,0 +1,20 @@ +public class AbbreviationAsWordInNameCase { + int CURRENT_COUNTER; // violation 'no more than '4' consecutive capital letters' + static int GLOBAL_COUNTER; // OK, static is ignored + final Set stringsFOUND = new HashSet<>(); // OK, final is ignored + + @Override + public void printCOUNTER() { // OK, overridden method is ignored + System.out.println(CURRENT_COUNTER); + } + + // violation below 'no more than '4' consecutive capital letters' + void incrementCOUNTER() { + CURRENT_COUNTER++; // OK, only definitions are checked + } + + // violation below 'no more than '4' consecutive capital letters' + static void incrementGLOBAL() { + GLOBAL_COUNTER++; // OK, only definitions are checked + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ClassTypeParameterNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ClassTypeParameterNameCase.java new file mode 100644 index 0000000..0888ea6 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ClassTypeParameterNameCase.java @@ -0,0 +1,4 @@ +public class ClassTypeParameterNameCase { + class MyClass1 {} + class MyClass2 {} // violation +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ConstantNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ConstantNameCase.java new file mode 100644 index 0000000..2472f08 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ConstantNameCase.java @@ -0,0 +1,11 @@ +public class ConstantNameCase { + public final static int FIRST_CONSTANT1 = 10; + protected final static int SECOND_CONSTANT2 = 100; + final static int third_Constant3 = 1000; // violation 'must match pattern' + private final static int fourth_Const4 = 50; // violation 'must match pattern' + public final static int log = 10; + protected final static int logger = 50; + final static int loggerMYSELF = 5; // violation 'must match pattern' + final static int MYSELF = 100; + protected final static int myselfConstant = 1; // violation 'must match pattern' +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/IllegalIdentifierNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/IllegalIdentifierNameCase.java new file mode 100644 index 0000000..39cc403 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/IllegalIdentifierNameCase.java @@ -0,0 +1,3 @@ +public class IllegalIdentifierNameCase { + Integer _ = 4; // violation, 'Name '_' must match pattern' +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/InterfaceTypeParameterNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/InterfaceTypeParameterNameCase.java new file mode 100644 index 0000000..e835153 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/InterfaceTypeParameterNameCase.java @@ -0,0 +1,15 @@ +public class InterfaceTypeParameterNameCase { + + interface FirstInterface { + } + + interface SecondInterface { + } + + interface ThirdInterface { + } // violation + + interface ThirdInterface { + } // violation + +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/LocalFinalVariableNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/LocalFinalVariableNameCase.java new file mode 100644 index 0000000..9b69149 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/LocalFinalVariableNameCase.java @@ -0,0 +1,11 @@ +public class LocalFinalVariableNameCase { + void MyMethod() { + try { + final int VAR1 = 5; // violation + final int var1 = 10; + } catch (Exception ex) { + final int VAR2 = 15; // violation + final int dataName = 20; + } + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/LocalVariableNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/LocalVariableNameCase.java new file mode 100644 index 0000000..4feece9 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/LocalVariableNameCase.java @@ -0,0 +1,8 @@ +public class LocalVariableNameCase { + void MyMethod() { + for (int var = 1; var < 10; var++) {} + for (int VAR = 1; VAR < 10; VAR++) {} // violation + for (int i = 1; i < 10; i++) {} + for (int var_1 = 0; var_1 < 10; var_1++) {} // violation + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MemberNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MemberNameCase.java new file mode 100644 index 0000000..ebed111 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MemberNameCase.java @@ -0,0 +1,17 @@ +public class MemberNameCase { + public int num1; + protected int num2; + final int num3 = 3; + private int num4; + + static int num5; + public static final int CONSTANT = 1; + + public int NUM1; // violation + + protected int NUM2; // violation + + int NUM3; // violation + + private int NUM4; // violation +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MethodNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MethodNameCase.java new file mode 100644 index 0000000..966b142 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MethodNameCase.java @@ -0,0 +1,4 @@ +public class MethodNameCase { + public void method1() {} + public void Method2() {} // violation +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MethodTypeParameterNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MethodTypeParameterNameCase.java new file mode 100644 index 0000000..1ef7cde --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/MethodTypeParameterNameCase.java @@ -0,0 +1,6 @@ +public class MethodTypeParameterNameCase { + public void method1() {} + public void method2() {} // violation + public void method3() {} + public void method4() {} // violation +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/PackageNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/PackageNameCase.java new file mode 100644 index 0000000..e6061ef --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/PackageNameCase.java @@ -0,0 +1,11 @@ +package com; // OK +package COM; // violation, name 'COM' must match pattern '^[a-z]+(\.[a-zA-Z_]\w*)*$' +package com.checkstyle.checks; // OK +package com.A.checkstyle.checks; // OK +package com.checkstyle1.checks; // OK +package com.checkSTYLE.checks; // OK +package com._checkstyle.checks_; // OK + +public class PackageNameCase { + +} diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ParameterNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ParameterNameCase.java new file mode 100644 index 0000000..15c1145 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/ParameterNameCase.java @@ -0,0 +1,4 @@ +public class ParameterNameCase { + void method1(int v1) {} + void method2(int V2) {} // violation +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/PatternVariableNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/PatternVariableNameCase.java new file mode 100644 index 0000000..698b315 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/PatternVariableNameCase.java @@ -0,0 +1,8 @@ +public class PatternVariableNameCase { + void foo(Object o1){ + if (o1 instanceof String STRING) {} // violation + if (o1 instanceof Integer num) {} + if (o1 instanceof Integer num_1) {} // violation + if (o1 instanceof Integer n) {} + } +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/RecordComponentNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/RecordComponentNameCase.java new file mode 100644 index 0000000..6b4c7c5 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/RecordComponentNameCase.java @@ -0,0 +1,11 @@ +public class RecordComponentNameCase { + record MyRecord1(String value, int otherComponentName) {} // OK + record MyRecord2(String... Values) {} // violation, the record component name + // should match the regular expression "^[a-z][a-zA-Z0-9]*$" + record MyRecord3(double my_number) {} // violation, the record component name + // should match the regular expression "^[a-z][a-zA-Z0-9]*$" + record MyRecord1(String value, int other) {} // OK + record MyRecord2(String... strings) {} // OK + record MyRecord3(double myNumber) {} // violation, the record component name + // should match the regular expression "^[a-z]+$" +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/RecordTypeParameterNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/RecordTypeParameterNameCase.java new file mode 100644 index 0000000..700b693 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/RecordTypeParameterNameCase.java @@ -0,0 +1,6 @@ +public class RecordTypeParameterNameCase { + record MyRecord1 {} // OK + record MyRecord2 {} // OK + record MyRecord3 {} // violation, the record type parameter + // name should match the regular expression "^[a-zA-Z]$" +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/StaticVariableNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/StaticVariableNameCase.java new file mode 100644 index 0000000..5bdcf2b --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/StaticVariableNameCase.java @@ -0,0 +1,12 @@ +public class StaticVariableNameCase { + public static int goodStatic = 2; + private static int badStatic = 2; + public static int ItStatic1 = 2; // violation, 'must match pattern' + protected static int ItStatic2 = 2; // violation, 'must match pattern' + private static int ItStatic = 2; // violation, 'must match pattern' + public static int it_static = 2; // violation, 'must match pattern' + public static int It_Static = 2; // violation, 'must match pattern' + private static int It_Static1 = 2; // violation, 'must match pattern' + static int It_Static2 = 2; // violation, 'must match pattern' + public static final int IT_STATIC = 2; +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/TypeNameCase.java b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/TypeNameCase.java new file mode 100644 index 0000000..7fd849a --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/case/naming_conventions/TypeNameCase.java @@ -0,0 +1,6 @@ +public class TypeNameCase { + public interface FirstName {} + protected class SecondName {} + enum Third_Name {} // violation + private class FourthName_ {} // violation +} \ No newline at end of file diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/BooleanExpressionComplexity.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/BooleanExpressionComplexity.xml new file mode 100644 index 0000000..e15df01 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/BooleanExpressionComplexity.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/ClassDataAbstractionCoupling.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/ClassDataAbstractionCoupling.xml new file mode 100644 index 0000000..725c400 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/ClassDataAbstractionCoupling.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/ClassFanOutComplexity.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/ClassFanOutComplexity.xml new file mode 100644 index 0000000..12bb1e4 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/ClassFanOutComplexity.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/CyclomaticComplexity.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/CyclomaticComplexity.xml new file mode 100644 index 0000000..10f0e2c --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/CyclomaticComplexity.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/JavaNCSS.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/JavaNCSS.xml new file mode 100644 index 0000000..97ace2d --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/JavaNCSS.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/NPathComplexity.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/NPathComplexity.xml new file mode 100644 index 0000000..520be8a --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/metrics/NPathComplexity.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/ArrayTypeStyle.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/ArrayTypeStyle.xml new file mode 100644 index 0000000..b41357d --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/ArrayTypeStyle.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/AvoidEscapedUnicodeCharacters.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/AvoidEscapedUnicodeCharacters.xml new file mode 100644 index 0000000..53c6825 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/AvoidEscapedUnicodeCharacters.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/CommentsIndentation.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/CommentsIndentation.xml new file mode 100644 index 0000000..52dc5cd --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/CommentsIndentation.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/DescendantToken.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/DescendantToken.xml new file mode 100644 index 0000000..ae49835 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/DescendantToken.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/FinalParameters.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/FinalParameters.xml new file mode 100644 index 0000000..2a67a58 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/FinalParameters.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/Indentation.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/Indentation.xml new file mode 100644 index 0000000..e29af54 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/Indentation.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/NewlineAtEndOfFile.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/NewlineAtEndOfFile.xml new file mode 100644 index 0000000..921da91 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/NewlineAtEndOfFile.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/NoCodeInFile.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/NoCodeInFile.xml new file mode 100644 index 0000000..ae3ffca --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/NoCodeInFile.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/OuterTypeFilename.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/OuterTypeFilename.xml new file mode 100644 index 0000000..a5fa53f --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/OuterTypeFilename.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/TodoComment.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/TodoComment.xml new file mode 100644 index 0000000..543fa99 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/TodoComment.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/UpperEll.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/UpperEll.xml new file mode 100644 index 0000000..207735d --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/miscellaneous/UpperEll.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/modifiers/ModifierOrder.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/modifiers/ModifierOrder.xml new file mode 100644 index 0000000..cd7eedf --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/modifiers/ModifierOrder.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/modifiers/RedundantModifier.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/modifiers/RedundantModifier.xml new file mode 100644 index 0000000..c176c1c --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/modifiers/RedundantModifier.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/AbbreviationAsWordInName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/AbbreviationAsWordInName.xml new file mode 100644 index 0000000..52f5aaa --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/AbbreviationAsWordInName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ClassTypeParameterName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ClassTypeParameterName.xml new file mode 100644 index 0000000..2592f3c --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ClassTypeParameterName.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ConstantName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ConstantName.xml new file mode 100644 index 0000000..047f635 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ConstantName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/IllegalIdentifierName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/IllegalIdentifierName.xml new file mode 100644 index 0000000..7149643 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/IllegalIdentifierName.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/InterfaceTypeParameterName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/InterfaceTypeParameterName.xml new file mode 100644 index 0000000..123c939 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/InterfaceTypeParameterName.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/LocalFinalVariableName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/LocalFinalVariableName.xml new file mode 100644 index 0000000..0862e17 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/LocalFinalVariableName.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/LocalVariableName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/LocalVariableName.xml new file mode 100644 index 0000000..aa59897 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/LocalVariableName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MemberName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MemberName.xml new file mode 100644 index 0000000..d574a52 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MemberName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MethodName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MethodName.xml new file mode 100644 index 0000000..b30b534 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MethodName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MethodTypeParameterName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MethodTypeParameterName.xml new file mode 100644 index 0000000..055b8b6 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/MethodTypeParameterName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/PackageName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/PackageName.xml new file mode 100644 index 0000000..46656c7 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/PackageName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ParameterName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ParameterName.xml new file mode 100644 index 0000000..7f0362c --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/ParameterName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/PatternVariableName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/PatternVariableName.xml new file mode 100644 index 0000000..0b046a0 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/PatternVariableName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/RecordComponentName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/RecordComponentName.xml new file mode 100644 index 0000000..768d04d --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/RecordComponentName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/RecordTypeParameterName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/RecordTypeParameterName.xml new file mode 100644 index 0000000..4869b49 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/RecordTypeParameterName.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/StaticVariableName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/StaticVariableName.xml new file mode 100644 index 0000000..7aed2ab --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/StaticVariableName.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/TypeName.xml b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/TypeName.xml new file mode 100644 index 0000000..1ef0b70 --- /dev/null +++ b/component/CodeInspector/code_inspector/src/test/resources/single_rules/naming_conventions/TypeName.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + -- Gitee