sleekbyte/tailor

View on GitHub

Showing 185 of 185 total issues

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

            if (msg.getColumnNumber() != 0) {
                begin.put(Messages.LINE_KEY, msg.getLineNumber());
                begin.put(Messages.COLUMN_KEY, msg.getColumnNumber());
                end.put(Messages.LINE_KEY, msg.getLineNumber());
                end.put(Messages.COLUMN_KEY, msg.getColumnNumber());
Severity: Major
Found in src/main/java/com/sleekbyte/tailor/format/CCFormatter.java and 2 other locations - About 2 hrs to fix
src/test/java/com/sleekbyte/tailor/format/CCFormatterTest.java on lines 109..121
src/test/java/com/sleekbyte/tailor/functional/FormatTest.java on lines 339..351

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

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

struct AlternativeRect {
    var origin = Point()
    var size = Size()
    var center: Point {
        get {
src/test/swift/com/sleekbyte/tailor/grammar/ClassesAndStructures.swift on lines 65..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 143.

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

struct Rect {
    var origin = Point()
    var size = Size()
    var center: Point {
        get {
src/test/swift/com/sleekbyte/tailor/grammar/ClassesAndStructures.swift on lines 86..100

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

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

    @Test
    public void testIncludeOption() throws IOException {
        // Add expected output
        addExpectedMsg(3, 7,
            Rules.UPPER_CAMEL_CASE,

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

        @Override
        protected void addAllExpectedMsgs() {
            addExpectedBraceMsg(13, 54, Severity.WARNING, Messages.SWITCH_STATEMENT);
            addExpectedBraceMsg(17, 12, Severity.WARNING, Messages.CLASS);
            addExpectedEmptyConstructBodyMsg(24, 19, Severity.WARNING);

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

          @Override
          protected void addAllExpectedMsgs() {
              addExpectedMsg(Rules.CONSTANT_NAMING, 2, 5, Severity.WARNING, Messages.GLOBAL + Messages.CONSTANT
                  + Messages.GLOBAL_CONSTANT_NAMING);
              addExpectedMsg(Rules.CONSTANT_K_PREFIX, 2, 22, Severity.WARNING, Messages.CONSTANT + Messages.NAME

        Method testCliAndConfigFilePrecedence has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Test
            public void testCliAndConfigFilePrecedence() throws IOException {
        
                addExpectedMsg(12, 15,
                    Rules.TERMINATING_SEMICOLON,

          Function demo has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          func demo() {
              var x: Int
              if (x == 2) {
                  return (x < 2)
              }

            Method testPurge has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Test
                public void testPurge() throws IOException {
                    addExpectedMsg(12, 15,
                        Rules.TERMINATING_SEMICOLON,
                        Messages.STATEMENTS + Messages.SEMICOLON,

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

                  @Override
                  protected void addAllExpectedMsgs() {
                      // Whitespace before open braces
              
                      // functions

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

                    @Test
                    public void testDisplayMessages() throws IOException {
                        List<ViolationMessage> messages = new ArrayList<>();
                        messages.add(new ViolationMessage(Rules.LOWER_CAMEL_CASE, inputFile.getCanonicalPath(), 10, 12,
                            Severity.WARNING, WARNING_MSG));
                src/test/java/com/sleekbyte/tailor/format/JSONFormatterTest.java on lines 59..71

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

                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

                    @Test
                    public void testDisplayMessages() throws IOException {
                        List<ViolationMessage> messages = new ArrayList<>();
                        messages.add(new ViolationMessage(Rules.LOWER_CAMEL_CASE, inputFile.getCanonicalPath(), 10, 12,
                            Severity.WARNING, WARNING_MSG));
                src/test/java/com/sleekbyte/tailor/format/HTMLFormatterTest.java on lines 57..69

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

                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 testDisplayMessages() throws IOException {
                        List<ViolationMessage> messages = new ArrayList<>();
                        messages.add(new ViolationMessage(Rules.LOWER_CAMEL_CASE, inputFile.getCanonicalPath(), 10, 12,
                            Severity.WARNING, WARNING_MSG));
                src/test/java/com/sleekbyte/tailor/format/CCFormatterTest.java on lines 58..69

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

                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 testDisplayMessages() throws IOException {
                        List<ViolationMessage> messages = new ArrayList<>();
                        messages.add(new ViolationMessage(Rules.MULTIPLE_IMPORTS, inputFile.getCanonicalPath(), 1, 0,
                            Severity.WARNING, WARNING_MSG));
                src/test/java/com/sleekbyte/tailor/format/XcodeFormatterTest.java on lines 50..60

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

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

                    private void analyzeFiles(Set<String> fileNames) throws CLIArgumentParserException, IOException {
                        ColorSettings colorSettings =
                            new ColorSettings(configuration.shouldColorOutput(), configuration.shouldInvertColorOutput());
                        Formatter formatter = configuration.getFormatter(colorSettings);
                        Severity maxSeverity = configuration.getMaxSeverity();
                Severity: Minor
                Found in src/main/java/com/sleekbyte/tailor/Tailor.java - About 1 hr to fix

                  Method addOptions has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private void addOptions() {
                          options = new Options();
                  
                          options.addOption(createNoArgOpt(Messages.HELP_SHORT_OPT, Messages.HELP_LONG_OPT, Messages.HELP_DESC));
                          options.addOption(createNoArgOpt(Messages.VERSION_SHORT_OPT, Messages.VERSION_LONG_OPT, Messages.VERSION_DESC));
                  Severity: Minor
                  Found in src/main/java/com/sleekbyte/tailor/utils/CLIArgumentParser.java - About 1 hr to fix

                    Method main has 36 lines of code (exceeds 25 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 1 hr to fix

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

                          private String expectedOutput(List<ViolationMessage> list) throws IOException {
                              String violations = "";
                      
                              for (ViolationMessage msg : list) {
                                  Map<String, Object> violation = new HashMap<>();
                      Severity: Minor
                      Found in src/test/java/com/sleekbyte/tailor/format/CCFormatterTest.java - About 1 hr to fix

                        Method getCCMessages has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Function demo has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          func demo() {
                              var x: Int
                              if (x == 2) {
                                  return (x < 2)
                              }

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language