chdemko/php-bitarray

View on GitHub

Showing 8 of 8 total issues

File BitArray.php has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * chdemko\BitArray\BitArray class
 *
Severity: Minor
Found in src/BitArray/BitArray.php - About 3 hrs to fix

    BitArray has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BitArray implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSerializable
    {
        /**
         * @var integer[]  Number of bits for each value between 0 and 255
         */
    Severity: Minor
    Found in src/BitArray/BitArray.php - About 3 hrs to fix

      Function shift has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function shift($size = 1, $value = false)
          {
              $size = (int) $size;
      
              if ($size > 0) {
      Severity: Minor
      Found in src/BitArray/BitArray.php - 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

      Function getRealSize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getRealSize($offset, $size)
          {
              if ($size === null) {
                  $size = $this->size - $offset;
              } else {
      Severity: Minor
      Found in src/BitArray/BitArray.php - 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

      Function directCopy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function directCopy(BitArray $bits, $index = 0, $offset = 0, $size = 0)
          {
              if ($offset > $index) {
                  for ($i = 0; $i < $size; $i++) {
                      $this[$i + $index] = $bits[$i + $offset];
      Severity: Minor
      Found in src/BitArray/BitArray.php - 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

      Function fromTraversable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function fromTraversable($traversable)
          {
              $bits = new BitArray(count($traversable));
              $offset = 0;
              $ord = 0;
      Severity: Minor
      Found in src/BitArray/BitArray.php - 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

      Function fromDecimal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function fromDecimal($size, $values = 0)
          {
              $php_bit_size = PHP_INT_SIZE * 8;
              $size = min((int) $size, $php_bit_size);
              $values <<= ($php_bit_size - $size);
      Severity: Minor
      Found in src/BitArray/BitArray.php - 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

      Function fromString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function fromString($string)
          {
              $bits = new BitArray(strlen($string));
              $ord = 0;
      
      
      Severity: Minor
      Found in src/BitArray/BitArray.php - 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