werneckbh/qr-code

View on GitHub

Showing 100 of 100 total issues

Function splitString has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function splitString () : int
    {
        while (strlen($this->dataStr) > 0) {
            if ($this->dataStr == '')
                return 0;
Severity: Minor
Found in src/QR_Code/Util/Split.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

Method eat8 has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function eat8 () : int
    {
        $la = Specifications::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
        $ln = Specifications::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
Severity: Minor
Found in src/QR_Code/Util/Split.php - About 1 hr to fix

    Function createFrame has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function createFrame ($version)
        {
            $width = self::$capacity[$version][QRCAP_WIDTH];
            $frameLine = str_repeat("\0", $width);
            $frame = array_fill(0, $width, $frameLine);
    Severity: Minor
    Found in src/QR_Code/Config/Specifications.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 encodeMask has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function encodeMask (Input $input, $mask)
        {
            if ($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
                throw new \Exception('wrong version');
            }
    Severity: Minor
    Found in src/QR_Code/QR_Code.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 writeFormatInformation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function writeFormatInformation (int $width, array &$frame, int $mask, int $level) : int
        {
            $blacks = 0;
            $format = Specifications::getFormatInfo($mask, $level);
    
    Severity: Minor
    Found in src/QR_Code/Encoder/Mask.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

    Method next has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function next ()
        {
            do {
    
                if ($this->bit == -1) {
    Severity: Minor
    Found in src/QR_Code/Util/FrameFiller.php - About 1 hr to fix

      Method encodeBitStream has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function encodeBitStream (int $version) : int
          {
              try {
                  unset($this->bitStream);
                  $words = Specifications::maximumWords($this->mode, $version);
      Severity: Minor
      Found in src/QR_Code/Encoder/InputItem.php - About 1 hr to fix

        Method lengthOfCode has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function lengthOfCode (int $mode, int $version, $bits)
            {
                $payload = $bits - 4 - Specifications::lengthIndicator($mode, $version);
                switch ($mode) {
                    case QR_MODE_NUM:
        Severity: Minor
        Found in src/QR_Code/Encoder/Input.php - About 1 hr to fix

          Function encodeBitStream has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function encodeBitStream (int $version) : int
              {
                  try {
                      unset($this->bitStream);
                      $words = Specifications::maximumWords($this->mode, $version);
          Severity: Minor
          Found in src/QR_Code/Encoder/InputItem.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 lengthOfCode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function lengthOfCode (int $mode, int $version, $bits)
              {
                  $payload = $bits - 4 - Specifications::lengthIndicator($mode, $version);
                  switch ($mode) {
                      case QR_MODE_NUM:
          Severity: Minor
          Found in src/QR_Code/Encoder/Input.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 identifyMode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function identifyMode (int $pos) : int
              {
                  if ($pos >= strlen($this->dataStr))
                      return QR_MODE_NUL;
          
          Severity: Minor
          Found in src/QR_Code/Util/Split.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

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

              public function eatAn () : int
              {
                  $la = Specifications::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
                  $ln = Specifications::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
          
          Severity: Minor
          Found in src/QR_Code/Util/Split.php - About 1 hr to fix

            Method writeFormatInformation has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function writeFormatInformation (int $width, array &$frame, int $mask, int $level) : int
                {
                    $blacks = 0;
                    $format = Specifications::getFormatInfo($mask, $level);
            
            Severity: Minor
            Found in src/QR_Code/Encoder/Mask.php - About 1 hr to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  public static function png (string $text, $outfile = false, $level = QR_ECLEVEL_L, int $size = 3, int $margin = 4, bool $saveAndPrint = false, int $back_color = QR_WHITE, int $fore_color = QR_BLACK) : void
                  {
                      $enc = Encoder::factory($level, $size, $margin, $back_color, $fore_color);
                      $enc->encodePNG($text, $outfile, $saveAndPrint);
                  }
              Severity: Major
              Found in src/QR_Code/QR_Code.php and 1 other location - About 1 hr to fix
              src/QR_Code/QR_Code.php on lines 233..237

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 106.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  public static function svg (string $text, $outfile = false, $level = QR_ECLEVEL_L, int $size = 3, int $margin = 4, bool $saveAndPrint = false, int $back_color = QR_WHITE, int $fore_color = QR_BLACK) : void
                  {
                      $enc = Encoder::factory($level, $size, $margin, $back_color, $fore_color);
                      $enc->encodeSVG($text, $outfile, $saveAndPrint);
                  }
              Severity: Major
              Found in src/QR_Code/QR_Code.php and 1 other location - About 1 hr to fix
              src/QR_Code/QR_Code.php on lines 185..189

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 106.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function newFrame has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function newFrame ($version)
                  {
                      if ($version < 1 || $version > QRSPEC_VERSION_MAX)
                          return null;
              
              Severity: Minor
              Found in src/QR_Code/Config/Specifications.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

              Method factory has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function factory ($level = QR_ECLEVEL_L, int $size = 3, int $margin = 4, int $backColor = QR_WHITE, int $foreColor = QR_BLACK, bool $cmyk = false) : Encoder
                  {
                      $enc = new self();
                      $enc->size = $size;
                      $enc->margin = $margin;
              Severity: Minor
              Found in src/QR_Code/Encoder/Encoder.php - About 1 hr to fix

                Method vectSVG has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function vectSVG ($frame, int $pixelPerPoint = 4, int $outerFrame = 4, int $backColor = 0xFFFFFF, int $foreColor = 0x000000) : string
                    {
                        $h = count($frame);
                        $w = strlen($frame[0]);
                
                Severity: Minor
                Found in src/QR_Code/Encoder/Vector.php - About 1 hr to fix

                  Method init has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function init (array $spec) : int
                      {
                          $dl = Specifications::rsDataCodes1($spec);
                          $el = Specifications::rsEccCodes1($spec);
                          $rs = Rs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
                  Severity: Minor
                  Found in src/QR_Code/Encoder/RawCode.php - About 1 hr to fix

                    Method putAlignmentPattern has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function putAlignmentPattern ($version, &$frame, $width)
                        {
                            if ($version < 2)
                                return;
                    
                    Severity: Minor
                    Found in src/QR_Code/Config/Specifications.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language