fujaba/NetworkParser

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

Summary

Maintainability
F
3 days
Test Coverage

File FileBuffer.java has 519 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.uniks.networkparser.ext.io;

/*
NetworkParser
The MIT License
Severity: Major
Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.java - About 1 day to fix

    FileBuffer has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class FileBuffer extends Buffer {
        public static final int BUFFER = 4096;
        private BufferedReader reader;
        private File file;
        private CharacterBuffer lookAHead = new CharacterBuffer();
    Severity: Minor
    Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.java - About 5 hrs to fix

      Method parsingBuffer has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          private static BaseItem parsingBuffer(CharacterBuffer buffer, BaseItem container) {
              if (buffer != null && buffer.length() > 0) {
                  char startCharacter = buffer.nextClean(true);
                  if (startCharacter == '{') {
                      JsonObject result;
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.java - About 3 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 parsingBuffer has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static BaseItem parsingBuffer(CharacterBuffer buffer, BaseItem container) {
              if (buffer != null && buffer.length() > 0) {
                  char startCharacter = buffer.nextClean(true);
                  if (startCharacter == '{') {
                      JsonObject result;
      Severity: Minor
      Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.java - About 1 hr to fix

        Method writeFile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public static final int writeFile(String fileName, byte[] data, byte flag) {
                if (fileName == null || fileName.length() < 1) {
                    return -1;
                }
                if (data == null || data.length < 1 || (data.length == 1 && data[0] == 0)) {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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 readBinaryResource has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public static ByteBuffer readBinaryResource(String file) {
                if (file == null) {
                    return null;
                }
                InputStream is = IdMap.class.getResourceAsStream(file);
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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 readFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public static final CharacterBuffer readFile(File file) {
                CharacterBuffer sb = new CharacterBuffer();
                if (file == null) {
                    return sb;
                }
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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 readBinaryFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public static final ByteBuffer readBinaryFile(String file) {
                if (file == null) {
                    return null;
                }
                File content = new File(file);
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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 readResource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public static CharacterBuffer readResource(InputStream is) {
                CharacterBuffer sb = new CharacterBuffer();
                if (is != null) {
                    final byte[] buffer = new byte[BUFFER];
                    try {
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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 readBinaryFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static final ByteBuffer readBinaryFile(String file) {
                if (file == null) {
                    return null;
                }
                File content = new File(file);
        Severity: Minor
        Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.java - About 1 hr to fix

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

              public static long skip(InputStream input, long numToSkip) {
                  if (input == null) {
                      return -1;
                  }
                  long available = numToSkip;
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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 write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public int write(byte flag, byte... data) {
                  if (this.file == null || data == null) {
                      return -1;
                  }
                  if (data.length == 1 && data[0] == 0) {
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.java - About 45 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 getChar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              public char getChar() {
                  char value = 0;
                  if (this.reader == null) {
                      return value;
          Severity: Minor
          Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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 container;
          Severity: Major
          Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

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

              Avoid too many return statements within this method.
              Open

                      return buffer.write(flag, data);
              Severity: Major
              Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

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

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

                      @Override
                      public String toString() {
                          char[] values = new char[remaining()];
                          int len = lookAHead.length();
                          if (len > 0) {
                  Severity: Minor
                  Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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

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

                      public static int readFully(final InputStream input, final byte[] b, final int offset, final int len) {
                          if (b == null || input == null || len < 0 || offset < 0 || len + offset > b.length) {
                              return -1;
                          }
                          int count = 0, x = 0;
                  Severity: Minor
                  Found in src/main/java/de/uniks/networkparser/ext/io/FileBuffer.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