sleekbyte/tailor

View on GitHub

Showing 185 of 185 total issues

Method getHTMLMessages has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private Map<String, Object> getHTMLMessages() throws IOException {
        List<Map<String, Object>> violations = new ArrayList<>();
        for (ViolationMessage msg : getExpectedMsgs()) {
            Map<String, Object> violation = new HashMap<>();
            Map<String, Object> location = new HashMap<>();
Severity: Minor
Found in src/test/java/com/sleekbyte/tailor/functional/FormatTest.java - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private File invalidPurgeConfig(String fileName) throws IOException {
            File configFile = folder.newFile(fileName);
            Writer streamWriter = new OutputStreamWriter(new FileOutputStream(configFile), Charset.forName("UTF-8"));
            PrintWriter printWriter = new PrintWriter(streamWriter);
            printWriter.println("purge: -1");
    src/test/java/com/sleekbyte/tailor/functional/yaml/YamlConfigurationTest.java on lines 458..468

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 92.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private File purgeConfig(String fileName) throws IOException {
            File configFile = folder.newFile(fileName);
            Writer streamWriter = new OutputStreamWriter(new FileOutputStream(configFile), Charset.forName("UTF-8"));
            PrintWriter printWriter = new PrintWriter(streamWriter);
            printWriter.println("purge: 1");
    src/test/java/com/sleekbyte/tailor/functional/yaml/YamlConfigurationTest.java on lines 470..480

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 92.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method displayViolationMessages has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public void displayViolationMessages(List<ViolationMessage> violationMessages, File inputFile) throws IOException {
            for (ViolationMessage msg : violationMessages) {
                Map<String, Object> violation = new HashMap<>();
                Map<String, Object> location = new HashMap<>();
    Severity: Minor
    Found in src/main/java/com/sleekbyte/tailor/format/CCFormatter.java - About 1 hr to fix

      Method testExceptOption has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Test
          public void testExceptOption() throws IOException {
              // Add expected output
              addExpectedMsg(8, 33,
                  Rules.TERMINATING_SEMICOLON,

        Method analyze has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public void analyze() {
                Stack<Integer> ignoreBlockBeginStack = new Stack<>();
                Token lastSuppressViolationComment = null;
        
        
        Severity: Minor
        Found in src/main/java/com/sleekbyte/tailor/output/ViolationSuppressor.java - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method createListeners has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            private List<SwiftBaseListener> createListeners(Set<Rules> enabledRules,
                                                            Printer printer,
                                                            CommonTokenStream tokenStream,
                                                            ConstructLengths constructLengths,
                                                            CommentExtractor commentExtractor)
        Severity: Minor
        Found in src/main/java/com/sleekbyte/tailor/Tailor.java - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method enterFunctionCallExpression has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public void enterFunctionCallExpression(FunctionCallExpressionContext ctx) {
                FunctionCallArgumentListContext argumentList =
                    ctx.functionCallArgumentClause().functionCallArgumentList();
        
        

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              @Override
              public void enterTopLevel(SwiftParser.TopLevelContext topLevelCtx) {
                  List<IdentifierContext> constants = DeclarationListener.getConstantNames(topLevelCtx);
                  constants.forEach(ctx ->
                      verifyNameLength(Messages.CONSTANT + Messages.NAME, constructLengths.minNameLength, ctx));
          src/main/java/com/sleekbyte/tailor/listeners/lengths/MaxLengthListener.java on lines 34..43

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 84.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              @Override
              public void enterTopLevel(SwiftParser.TopLevelContext topLevelCtx) {
                  List<IdentifierContext> constants = DeclarationListener.getConstantNames(topLevelCtx);
                  constants.forEach(ctx ->
                      verifyNameLength(Messages.CONSTANT + Messages.NAME, constructLengths.maxNameLength, ctx));
          src/main/java/com/sleekbyte/tailor/listeners/lengths/MinLengthListener.java on lines 47..56

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 84.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          switch yetAnotherPoint {
          case let (x, y) where x == y:
              print("(\(x), \(y)) is on the line x == y")
          case let (x, y) where x == -y:
              print("(\(x), \(y)) is on the line x == -y")
          src/test/swift/com/sleekbyte/tailor/functional/ConstantNamingTest.swift on lines 47..54

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 84.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          switch yetAnotherPoint {
          case let (x, y) where x == ThisShouldNotMatter:
              println("(\(x), \(y)) is on the line x == y")
          case let (DrDrae, y) where DrDrae == -y:
              println("(\(x), \(y)) is on the line x == -y")
          src/test/swift/com/sleekbyte/tailor/grammar/ControlFlow.swift on lines 108..115

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 84.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method expectedOutput has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private List<Object> expectedOutput(List<ViolationMessage> list) throws IOException {
                  Map<String, Object> output = new HashMap<>();
                  output.put(Messages.PATH_KEY, inputFile.getCanonicalPath());
                  output.put(Messages.PARSED_KEY, true);
          
          
          Severity: Minor
          Found in src/test/java/com/sleekbyte/tailor/format/HTMLFormatterTest.java - About 1 hr to fix

            Method createListeners has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private List<SwiftBaseListener> createListeners(Set<Rules> enabledRules,
                                                                Printer printer,
                                                                CommonTokenStream tokenStream,
                                                                ConstructLengths constructLengths,
                                                                CommentExtractor commentExtractor)
            Severity: Minor
            Found in src/main/java/com/sleekbyte/tailor/Tailor.java - About 1 hr to fix

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  init(center: Point, size: Size) {
                      let originX = center.x - (size.width / 2)
                      let originY = center.y - (size.height / 2)
                      self.init(origin: Point(x: originX, y: originY), size: size)
                  }
              src/test/swift/com/sleekbyte/tailor/grammar/Initialization.swift on lines 81..85

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 80.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  init(center: Point, size: Size) {
                      let originX = center.x - (size.width / 2)
                      let originY = center.y - (size.height / 2)
                      self.init(origin: Point(x: originX, y: originY), size: size)
                  }
              src/test/swift/com/sleekbyte/tailor/grammar/Extensions.swift on lines 19..23

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 80.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (lineNumberWidth > 0 && colorSettings.colorOutput) {
                          res = String.format("%0" + lineNumberWidth + "d:", lineNumber);
                          res = "@|bg_blue," + textColor + " " + res + "|@";
                      } else {
                          res = String.format("%d:", lineNumber);
              src/main/java/com/sleekbyte/tailor/output/ViolationMessage.java on lines 227..232

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 78.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                          if (columnNumberWidth > 0 && colorSettings.colorOutput) {
                              res = String.format("%0" + columnNumberWidth + "d:", columnNumber);
                              res = "@|bg_blue," + textColor + " " + res + "|@";
                          } else {
                              res = String.format("%d:", columnNumber);
              src/main/java/com/sleekbyte/tailor/output/ViolationMessage.java on lines 208..213

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 78.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Method analyzeFile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private void analyzeFile(File inputFile,
                                           Optional<CommonTokenStream> optTokenStream,
                                           Optional<TopLevelContext> optTree,
                                           Formatter formatter,
                                           Severity maxSeverity,
              Severity: Minor
              Found in src/main/java/com/sleekbyte/tailor/Tailor.java - About 1 hr to fix

                Method testHTMLFormat has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @Test
                    public void testHTMLFormat() throws IOException {
                        Format format = Format.HTML;
                
                        final String[] command = new String[] {
                Severity: Minor
                Found in src/test/java/com/sleekbyte/tailor/functional/FormatTest.java - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language