deeplearning4j/deeplearning4j

View on GitHub
datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java

Summary

Maintainability
F
3 days
Test Coverage

Method validateUTF8 has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    public static void validateUTF8(byte[] utf8, int start, int len) throws MalformedInputException {
        int count = start;
        int leadByte = 0;
        int length = 0;
        int state = LEAD_BYTE;
Severity: Minor
Found in datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.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

File Text.java has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 *  ******************************************************************************
 *  *
 *  *
 *  * This program and the accompanying materials are made available under the
Severity: Minor
Found in datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java - About 5 hrs to fix

    Text has 38 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Text extends BinaryComparable implements WritableComparable<BinaryComparable> {
    
        private static ThreadLocal<CharsetEncoder> ENCODER_FACTORY = new ThreadLocal<CharsetEncoder>() {
            protected CharsetEncoder initialValue() {
                return StandardCharsets.UTF_8.newEncoder().onMalformedInput(CodingErrorAction.REPORT)
    Severity: Minor
    Found in datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java - About 5 hrs to fix

      Method find has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public int find(String what, int start) {
              try {
                  ByteBuffer src = ByteBuffer.wrap(this.bytes, 0, this.length);
                  ByteBuffer tgt = encode(what);
                  byte b = tgt.get();
      Severity: Minor
      Found in datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.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 validateUTF8 has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static void validateUTF8(byte[] utf8, int start, int len) throws MalformedInputException {
              int count = start;
              int leadByte = 0;
              int length = 0;
              int state = LEAD_BYTE;
      Severity: Major
      Found in datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java - About 2 hrs to fix

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

            public static int utf8Length(String string) {
                CharacterIterator iter = new StringCharacterIterator(string);
                char ch = iter.first();
                int size = 0;
                while (ch != CharacterIterator.DONE) {

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

            public int find(String what, int start) {
                try {
                    ByteBuffer src = ByteBuffer.wrap(this.bytes, 0, this.length);
                    ByteBuffer tgt = encode(what);
                    byte b = tgt.get();

          Method bytesToCodePoint has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static int bytesToCodePoint(ByteBuffer bytes) {
                  bytes.mark();
                  byte b = bytes.get();
                  bytes.reset();
                  int extraBytesToRead = bytesFromUTF8[(b & 0xFF)];

            Method compare has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
            Severity: Minor
            Found in datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status