sleekbyte/tailor

View on GitHub

Showing 185 of 185 total issues

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

let many_strings = numbers.map {
    (number) -> String in
    var output = ""
    while number > 0 {
        output = digitNames[number % 10]! + output
src/test/swift/com/sleekbyte/tailor/grammar/Closures.swift on lines 23..31

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 76.

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

let strings = numbers.map {
    (number) -> String in
    var output = ""
    while number > 0 {
        output = digitNames[number % 10]! + output
Severity: Major
Found in src/test/swift/com/sleekbyte/tailor/grammar/Closures.swift and 1 other location - About 1 hr to fix
src/test/swift/com/sleekbyte/tailor/functional/ConstantNamingTest.swift on lines 56..64

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 76.

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 formattedColumnNumber has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private String formattedColumnNumber() {
        String res;
        if (columnNumber == 0) {
            if (columnNumberWidth > 0 && colorSettings.colorOutput) {
                res = String.format("%" + (columnNumberWidth + 1) + "s", "");
Severity: Minor
Found in src/main/java/com/sleekbyte/tailor/output/ViolationMessage.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 verify has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public void verify() throws IOException {
        int lineLength;
        int lineNumber;
        for (String line = this.reader.readLine(); line != null; line = this.reader.readLine()) {
            lineLength = line.length();
Severity: Minor
Found in src/main/java/com/sleekbyte/tailor/listeners/FileListener.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 addAllExpectedMsgs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    protected void addAllExpectedMsgs() {
        int start = 1;
        addExpectedMsg(start, 18, Severity.WARNING, Messages.STATEMENTS);
        addExpectedMsg(start + 5, 15, Severity.WARNING, Messages.STATEMENTS);
Severity: Minor
Found in src/test/java/com/sleekbyte/tailor/functional/SemicolonTest.java - About 1 hr to fix

    Method getFilesToAnalyze has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public Set<String> getFilesToAnalyze() throws IOException, CLIArgumentParserException {
            Optional<String> srcRoot = getSrcRoot();
            List<String> pathNames = new ArrayList<>();
            String[] cliPaths = cmd.getArgs();
    
    
    Severity: Minor
    Found in src/main/java/com/sleekbyte/tailor/utils/Configuration.java - About 1 hr to fix

      Method addAllExpectedMsgs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          protected void addAllExpectedMsgs() {
              addExpectedNameMsg(1, 7, Messages.CLASS + Messages.NAME, 23, 5);
              addExpectedNameMsg(4, 5, Messages.CONSTANT + Messages.NAME, 22, 5);
              addExpectedLineMsg(4, 41, Messages.LINE, 75, 40);

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

            private void addExpectedLineMsg(int line, int column, String msg, int length, int limit) {
                String lengthVersusLimit = " (" + length + "/" + limit + ")";
                msg += Messages.EXCEEDS_CHARACTER_LIMIT + lengthVersusLimit;
                expectedMessages.add(Printer.genOutputStringForTest(Rules.MAX_LINE_LENGTH, inputFile.getName(), line, column,
                    Severity.WARNING, msg));
        src/test/java/com/sleekbyte/tailor/functional/MaxNameLengthTest.java on lines 56..61

        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 74.

        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 void addExpectedNameMsg(int line, int column, String msg, int length, int limit) {
                String lengthVersusLimit = " (" + length + "/" + limit + ")";
                msg += Messages.EXCEEDS_CHARACTER_LIMIT + lengthVersusLimit;
                expectedMessages.add(Printer.genOutputStringForTest(Rules.MAX_NAME_LENGTH, inputFile.getName(), line, column,
                    Severity.WARNING, msg));
        src/test/java/com/sleekbyte/tailor/functional/MaxNameLengthTest.java on lines 63..68

        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 74.

        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 anotherPoint {
        case (let x, 0):
            print("on the x-axis with an x value of \(x)")
        case (0, let y):
            print("on the y-axis with a y value of \(y)")
        src/test/swift/com/sleekbyte/tailor/functional/ConstantNamingTest.swift on lines 37..44

        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 74.

        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 anotherPoint {
        case (let x, 0):
            println("on the x-axis with an x value of \(x)")
        case (0, let DrDrae):
            println("on the y-axis with a y value of \(y)")
        src/test/swift/com/sleekbyte/tailor/grammar/ControlFlow.swift on lines 98..105

        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 74.

        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 addAllExpectedMsgs has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            protected void addAllExpectedMsgs() {
                int start = 3;
                addExpectedMsg(start, 8, Severity.WARNING, Messages.CONDITION + Messages.ENCLOSED_PARENTHESES);
                addExpectedMsg(start + 3, 13, Severity.WARNING, Messages.CONDITION + Messages.ENCLOSED_PARENTHESES);

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

              @Test
              public void testWarn() throws IOException {
                  printer.warn(Rules.LOWER_CAMEL_CASE, WARNING_MSG, new Location(LINE_NUMBER, COLUMN_NUMBER));
                  ViolationMessage message = printer.getViolationMessages().get(0);
                  assertEquals(message.getSeverity(), Severity.WARNING);
          Severity: Minor
          Found in src/test/java/com/sleekbyte/tailor/output/PrinterTest.java and 1 other location - About 1 hr to fix
          src/test/java/com/sleekbyte/tailor/output/PrinterTest.java on lines 50..58

          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 69.

          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

              @Test
              public void testError() throws IOException {
                  printer.error(Rules.LOWER_CAMEL_CASE, ERROR_MSG, new Location(LINE_NUMBER, COLUMN_NUMBER));
                  ViolationMessage message = printer.getViolationMessages().get(0);
                  assertEquals(message.getSeverity(), Severity.ERROR);
          Severity: Minor
          Found in src/test/java/com/sleekbyte/tailor/output/PrinterTest.java and 1 other location - About 1 hr to fix
          src/test/java/com/sleekbyte/tailor/output/PrinterTest.java on lines 60..68

          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 69.

          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

          Function play has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              func play() {
                  square = 0
                  delegate?.gameDidStart(self)
                  gameLoop: while square != finalSquare {
                      let diceRoll = dice.roll()
          Severity: Minor
          Found in src/test/swift/com/sleekbyte/tailor/grammar/Protocols.swift - About 55 mins 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 numberOfFilesBeforePurge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public int numberOfFilesBeforePurge() throws CLIArgumentParserException {
                  if (CLIArgumentParser.shouldClearDFAs()) {
                      int purge = CLIArgumentParser.numberOfFilesBeforePurge();
                      if (purge >= 1) {
                          return purge;
          Severity: Minor
          Found in src/main/java/com/sleekbyte/tailor/utils/Configuration.java - About 55 mins 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 main has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public static void main(String[] args) {
                  Tailor tailor = new Tailor();
          
                  try {
                      tailor.configuration = new Configuration(args);
          Severity: Minor
          Found in src/main/java/com/sleekbyte/tailor/Tailor.java - About 55 mins 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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

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

          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

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

          func allItemsMatch<C1: Container, C2: Container>
              (someContainer: C1, _ anotherContainer: C2) -> Bool
              where C1.ItemType == C2.ItemType,
                  C1.ItemType: Equatable {
          }
          src/test/swift/com/sleekbyte/tailor/functional/CommaWhitespaceTest.swift on lines 81..84

          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 64.

          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

          func allItemsMatch<C1: Container, C2: Container>
              (someContainer: C1, _ anotherContainer: C2) -> Bool
              where C1.ItemType == C2.ItemType,C1.ItemType: Equatable {
          }
          src/test/swift/com/sleekbyte/tailor/functional/CommaWhitespaceTest.swift on lines 75..79

          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 64.

          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

          Severity
          Category
          Status
          Source
          Language