fujaba/NetworkParser

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

Summary

Maintainability
C
1 day
Test Coverage

SocketMessage has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

public class SocketMessage implements BaseItem {
    public static final String PROPERTY_FROM = "From: ";
    public static final String PROPERTY_TO = "To";
    public static final String PROPERTY_DATE = "Date: ";
    public static final String PROPERTY_ID = "Message-Id: ";
Severity: Minor
Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.java - About 2 hrs to fix

    File SocketMessage.java has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package de.uniks.networkparser.ext.io;
    
    /*
    The MIT License
    
    
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.java - About 2 hrs to fix

      Method getHeader has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public String getHeader(String key) {
              if (PROPERTY_FROM.equalsIgnoreCase(key)) {
                  return PROPERTY_FROM + from;
              }
              if (PROPERTY_TO.equalsIgnoreCase(key)) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.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 getHeader has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public String getHeader(String key) {
              if (PROPERTY_FROM.equalsIgnoreCase(key)) {
                  return PROPERTY_FROM + from;
              }
              if (PROPERTY_TO.equalsIgnoreCase(key)) {
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.java - About 1 hr to fix

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

            @Override
            public boolean add(Object... values) {
                if (values != null) {
                    for (Object item : values) {
                        if (item instanceof String && item != null) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.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 returnValue + ">";
        Severity: Major
        Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.java - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return PROPERTY_ID + id;
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return PROPERTY_BOUNDARY + "\"" + generateBoundaryValue() + "\"";
            Severity: Major
            Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return PROPERTY_SUBJECT + this.subject;
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return PROPERTY_CONTENTTYPE + this.getContentType();
                Severity: Major
                Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.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/io/SocketMessage.java - About 30 mins to fix

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

                        public XMLEntity toXML(String type) {
                            XMLEntity messageXML = XMLEntity.TAG("message");
                            if (type == MessageSession.TYPE_FCM) {
                                messageXML.add("id", "");
                                XMLEntity gcm = messageXML.createChild("gcm");
                    Severity: Minor
                    Found in src/main/java/de/uniks/networkparser/ext/io/SocketMessage.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

                    There are no issues that match your filters.

                    Category
                    Status