patrickfav/bytes-java

View on GitHub

Showing 24 of 54 total issues

File Util.java has 497 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright 2017 Patrick Favre-Bulle
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
Severity: Minor
Found in src/main/java/at/favre/lib/bytes/Util.java - About 7 hrs to fix

    Method decode has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        static byte[] decode(CharSequence in) {
            // Ignore trailing '=' padding and whitespace from the input.
            int limit = in.length();
            for (; limit > 0; limit--) {
                char c = in.charAt(limit - 1);
    Severity: Minor
    Found in src/main/java/at/favre/lib/bytes/Base64.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 shiftRight has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

            static byte[] shiftRight(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder) {
                final int shiftMod = shiftBitCount % 8;
                final byte carryMask = (byte) (0xFF << (8 - shiftMod));
                final int offsetBytes = (shiftBitCount / 8);
    
    
    Severity: Minor
    Found in src/main/java/at/favre/lib/bytes/Util.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 shiftLeft has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

            static byte[] shiftLeft(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder) {
                final int shiftMod = shiftBitCount % 8;
                final byte carryMask = (byte) ((1 << shiftMod) - 1);
                final int offsetBytes = (shiftBitCount / 8);
    
    
    Severity: Minor
    Found in src/main/java/at/favre/lib/bytes/Util.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 decode has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

            @Override
            public byte[] decode(CharSequence hexString) {
    
                int start;
                if (Objects.requireNonNull(hexString).length() > 2 &&
    Severity: Minor
    Found in src/main/java/at/favre/lib/bytes/BinaryToTextEncoding.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 decode has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static byte[] decode(CharSequence in) {
            // Ignore trailing '=' padding and whitespace from the input.
            int limit = in.length();
            for (; limit > 0; limit--) {
                char c = in.charAt(limit - 1);
    Severity: Minor
    Found in src/main/java/at/favre/lib/bytes/Base64.java - About 2 hrs to fix

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

              static int countByteArray(byte[] array, byte[] pattern) {
                  Objects.requireNonNull(pattern, "pattern must not be null");
                  if (pattern.length == 0 || array.length == 0) {
                      return 0;
                  }
      Severity: Minor
      Found in src/main/java/at/favre/lib/bytes/Util.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 indexOf has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              static int indexOf(byte[] array, byte[] target, int start, int end) {
                  Objects.requireNonNull(array, "array must not be null");
                  Objects.requireNonNull(target, "target must not be null");
                  if (target.length == 0 || start < 0) {
                      return -1;
      Severity: Minor
      Found in src/main/java/at/favre/lib/bytes/Util.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 shiftLeft has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              static byte[] shiftLeft(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder) {
                  final int shiftMod = shiftBitCount % 8;
                  final byte carryMask = (byte) ((1 << shiftMod) - 1);
                  final int offsetBytes = (shiftBitCount / 8);
      
      
      Severity: Minor
      Found in src/main/java/at/favre/lib/bytes/Util.java - About 1 hr to fix

        Method shiftRight has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                static byte[] shiftRight(byte[] byteArray, int shiftBitCount, ByteOrder byteOrder) {
                    final int shiftMod = shiftBitCount % 8;
                    final byte carryMask = (byte) (0xFF << (8 - shiftMod));
                    final int offsetBytes = (shiftBitCount / 8);
        
        
        Severity: Minor
        Found in src/main/java/at/favre/lib/bytes/Util.java - About 1 hr to fix

          Method decode has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  @Override
                  public byte[] decode(CharSequence hexString) {
          
                      int start;
                      if (Objects.requireNonNull(hexString).length() > 2 &&
          Severity: Minor
          Found in src/main/java/at/favre/lib/bytes/BinaryToTextEncoding.java - About 1 hr to fix

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

                    @Override
                    public boolean validate(byte[] byteArrayToValidate) {
                        for (byte b : byteArrayToValidate) {
                            if (mode == Mode.NONE_OF && b == refByte) {
                                return false;
            Severity: Minor
            Found in src/main/java/at/favre/lib/bytes/BytesValidator.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 encode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static byte[] encode(byte[] in, byte[] map, boolean usePadding) {
                    int length = outLength(in.length, usePadding);
                    byte[] out = new byte[length];
                    int index = 0, end = in.length - in.length % 3;
                    for (int i = 0; i < end; i += 3) {
            Severity: Minor
            Found in src/main/java/at/favre/lib/bytes/Base64.java - About 1 hr to fix

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

                      static byte[] charToByteArray(char[] charArray, Charset charset, int offset, int length) {
                          if (offset < 0 || offset > charArray.length)
                              throw new IllegalArgumentException("offset must be gt 0 and smaller than array length");
                          if (length < 0 || length > charArray.length)
                              throw new IllegalArgumentException("length must be at least 1 and less than array length");
              Severity: Minor
              Found in src/main/java/at/favre/lib/bytes/Util.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 readFromStream has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      static byte[] readFromStream(InputStream inputStream, final int maxLengthToRead) {
                          final boolean readWholeStream = maxLengthToRead == -1;
                          int remaining = maxLengthToRead;
                          try {
                              ByteArrayOutputStream out = new ByteArrayOutputStream(readWholeStream ? 32 : maxLengthToRead);
              Severity: Minor
              Found in src/main/java/at/favre/lib/bytes/Util.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 transform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      @Override
                      public byte[] transform(byte[] currentArray, boolean inPlace) {
                          if (currentArray.length == newSize) {
                              return currentArray;
                          }
              Severity: Minor
              Found in src/main/java/at/favre/lib/bytes/BytesTransformer.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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      @Override
                      public boolean validate(byte[] byteArrayToValidate) {
                          if (pfix.length > byteArrayToValidate.length) {
                              return false;
                          }
              Severity: Minor
              Found in src/main/java/at/favre/lib/bytes/BytesValidator.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 decodeTo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private int decodeTo(byte[] target, CharSequence chars) {
                      Objects.requireNonNull(target);
                      chars = trimTrailingPadding(chars);
                      int bytesWritten = 0;
                      for (int charIdx = 0; charIdx < chars.length(); charIdx += alphabet.charsPerChunk) {
              Severity: Minor
              Found in src/main/java/at/favre/lib/bytes/BaseEncoding.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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      @Override
                      public boolean validate(byte[] byteArrayToValidate) {
                          if (operator == NOT) {
                              return !validatorList.get(0).validate(byteArrayToValidate);
                          }
              Severity: Minor
              Found in src/main/java/at/favre/lib/bytes/BytesValidator.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

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

                      static double entropy(byte[] array) {
                          final int[] buffer = new int[256];
                          Arrays.fill(buffer, -1);
              
                          for (byte element : array) {
              Severity: Minor
              Found in src/main/java/at/favre/lib/bytes/Util.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

              Severity
              Category
              Status
              Source
              Language