fujaba/NetworkParser

View on GitHub
src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java

Summary

Maintainability
F
1 wk
Test Coverage

Method searching has a Cognitive Complexity of 197 (exceeds 5 allowed). Consider refactoring.
Open

    public int searching(File file, PrintStream output) {
        if (file == null) {
            if (output != null) {
                output.println("NO FILES FOUND");
            }
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 4 days 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

File JarValidator.java has 600 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext.generic;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
Severity: Major
Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 1 day to fix

    Method analyseFile has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

        private boolean analyseFile(File file) {
            if (file == null || file.exists() == false) {
                return false;
            }
            JarClassLoader jarClassLoader = null;
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 7 hrs 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 mergePackages has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        public SimpleKeyValueList<String, JsonObject> mergePackages() {
            projects.clear();
            TreeSet<String> cache = new TreeSet<String>();
            cache.add("de.uniks");
            cache.add("de");
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 6 hrs 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 validate has 132 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public void validate() {
            if (ReflectionBlackBoxTester.isTester()) {
                return;
            }
    
    
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 5 hrs to fix

      Method searching has 114 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public int searching(File file, PrintStream output) {
              if (file == null) {
                  if (output != null) {
                      output.println("NO FILES FOUND");
                  }
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 4 hrs to fix

        Method analyseFile has 108 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private boolean analyseFile(File file) {
                if (file == null || file.exists() == false) {
                    return false;
                }
                JarClassLoader jarClassLoader = null;
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 4 hrs to fix

          Method validate has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              public void validate() {
                  if (ReflectionBlackBoxTester.isTester()) {
                      return;
                  }
          
          
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 2 hrs 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 mergePackages has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public SimpleKeyValueList<String, JsonObject> mergePackages() {
                  projects.clear();
                  TreeSet<String> cache = new TreeSet<String>();
                  cache.add("de.uniks");
                  cache.add("de");
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 1 hr to fix

            Method mergePacking has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public ArrayList<String> mergePacking(TreeSet<String> sources) {
                    ArrayList<String> dep = new ArrayList<String>();
                    dep.addAll(sources);
                    for (int i = dep.size() - 1; i > 0; i--) {
                        for (int z = i - 1; z >= 0; z--) {
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.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 getDependency has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                private TreeSet<String> getDependency(CharacterBuffer executeProcess, String search) {
                    int pos = executeProcess.indexOf("##" + search + "##");
                    TreeSet<String> packages = new TreeSet<String>();
                    if (pos > 0) {
                        logger.print(this, "FOUND DEPENDENCY:" + search);
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.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

            Avoid deeply nested control flow statements.
            Open

                                            if (pom != null) {
                                                XMLEntity body = pom.getBody();
                                                Entity nameTag = body.getElementBy(XMLEntity.PROPERTY_TAG, "name");
                                                if (nameTag != null) {
                                                    if (output != null) {
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                              if (output != null) {
                                                  output.print(projects.getKeyByIndex(i));
                                              }
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 45 mins to fix

                Method analyseReport has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public int analyseReport() {
                        File file = new File(rootPath + this.file);
                        if (file.exists()) {
                            CharacterBuffer content = FileBuffer.readFile(file);
                            String search = "<td class=\"ctr2\">";
                Severity: Minor
                Found in src/main/java/de/uniks/networkparser/ext/generic/JarValidator.java - About 35 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

                These nested if statements could be combined
                Open

                                                                if (output != null) {
                                                                    output.print(" - ");
                                                                    output.print(((XMLEntity) licence
                                                                            .getElementBy(XMLEntity.PROPERTY_TAG, "name")).getValue());
                                                                    output.print(" - ");

                CollapsibleIfStatements

                Since: PMD 3.1

                Priority: Medium

                Categories: Style

                Remediation Points: 50000

                Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.

                Example:

                void bar() {
                 if (x) { // original implementation
                 if (y) {
                 // do stuff
                 }
                 }
                }
                
                void bar() {
                 if (x && y) { // optimized implementation
                 // do stuff
                 }
                }

                These nested if statements could be combined
                Open

                                                        if (output != null) {
                                                            output.print(" - " + ((XMLEntity) nameTag).getValue());
                                                        }

                CollapsibleIfStatements

                Since: PMD 3.1

                Priority: Medium

                Categories: Style

                Remediation Points: 50000

                Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.

                Example:

                void bar() {
                 if (x) { // original implementation
                 if (y) {
                 // do stuff
                 }
                 }
                }
                
                void bar() {
                 if (x && y) { // optimized implementation
                 // do stuff
                 }
                }

                These nested if statements could be combined
                Open

                            if (dep.get(0).equalsIgnoreCase("de") || dep.get(0).equalsIgnoreCase("de.uniks")
                                    || dep.get(0).equalsIgnoreCase("de.uniks.networkparser")) {
                                copy = true;
                            }

                CollapsibleIfStatements

                Since: PMD 3.1

                Priority: Medium

                Categories: Style

                Remediation Points: 50000

                Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.

                Example:

                void bar() {
                 if (x) { // original implementation
                 if (y) {
                 // do stuff
                 }
                 }
                }
                
                void bar() {
                 if (x && y) { // optimized implementation
                 // do stuff
                 }
                }

                There are no issues that match your filters.

                Category
                Status