fujaba/NetworkParser

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

Summary

Maintainability
F
4 days
Test Coverage

Method getElement has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    private Object getElement(CharacterBuffer request, CharacterBuffer path, CharacterBuffer listID,
            boolean lastElement) {
        int pos = 0;
        SendableEntityCreator creator = this.creator;

Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 1 day 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 run has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public void run() {
        try {
            if (port == 0) {
                return;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.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

File RESTServiceTask.java has 364 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.Collection;
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 4 hrs to fix

    Method getElement has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private Object getElement(CharacterBuffer request, CharacterBuffer path, CharacterBuffer listID,
                boolean lastElement) {
            int pos = 0;
            SendableEntityCreator creator = this.creator;
    
    
    Severity: Major
    Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 3 hrs to fix

      Method run has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public void run() {
              try {
                  if (port == 0) {
                      return;
      Severity: Major
      Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 2 hrs to fix

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

            private String postExecute(SimpleEvent socketRequest) {
                if (socketRequest == null) {
                    return HTTPRequest.HTTP__NOTFOUND;
                }
                Object source = socketRequest.getSource();
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 1 hr to fix

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

              private String getExecute(SimpleEvent socketRequest) {
                  CharacterBuffer path = new CharacterBuffer();
                  CharacterBuffer listID = new CharacterBuffer();
                  CharacterBuffer request = new CharacterBuffer().with(socketRequest.getPropertyName());
                  Object element = getElement(request, path, listID, false);
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.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 getExecute has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private String getExecute(SimpleEvent socketRequest) {
                  CharacterBuffer path = new CharacterBuffer();
                  CharacterBuffer listID = new CharacterBuffer();
                  CharacterBuffer request = new CharacterBuffer().with(socketRequest.getPropertyName());
                  Object element = getElement(request, path, listID, false);
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 1 hr to fix

            Method postExecute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private String postExecute(SimpleEvent socketRequest) {
                    if (socketRequest == null) {
                        return HTTPRequest.HTTP__NOTFOUND;
                    }
                    Object source = socketRequest.getSource();
            Severity: Minor
            Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.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

            Avoid deeply nested control flow statements.
            Open

                                    if (id.length() > 0) {
                                        element = null;
                                        while (i.hasNext()) {
                                            item = i.next();
                                            if (id.equals(map.getId(item, true))) {
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 45 mins to fix

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

                  public String executeRequest(SimpleEvent socketRequest) {
                      if (socketRequest == null) {
                          return null;
                      }
                      String type = socketRequest.getType();
              Severity: Minor
              Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.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

              Avoid too many return statements within this method.
              Open

                          return this.patchExecute(socketRequest);
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return this.deleteExecute(socketRequest);
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return null;
                  Severity: Major
                  Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 30 mins to fix

                    Method stop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public void stop() {
                            if (serverSocket != null) {
                                try {
                                    ServerSocket socket = serverSocket;
                                    serverSocket = null;
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/ext/RESTServiceTask.java - About 25 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 (loginController.update(event) == false) {
                                            clientSocket.close();
                                            continue;
                                        }

                    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