werneckbh/qr-code

View on GitHub

Showing 100 of 100 total issues

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

    public function encodePNG (string $inText, $outfile = false, $saveAndPrint = false) : void
    {
        try {

            ob_start();
Severity: Major
Found in src/QR_Code/Encoder/Encoder.php and 1 other location - About 5 hrs to fix
src/QR_Code/Encoder/Encoder.php on lines 192..212

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 201.

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 function encodeSVG (string $inText, $outfile = false, $saveAndPrint = false) : void
    {
        try {

            ob_start();
Severity: Major
Found in src/QR_Code/Encoder/Encoder.php and 1 other location - About 5 hrs to fix
src/QR_Code/Encoder/Encoder.php on lines 138..158

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 201.

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 evaluateSymbol has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public function evaluateSymbol (int $width, array $frame)
    {
        $head = 0;
        $demerit = 0;
Severity: Minor
Found in src/QR_Code/Encoder/Mask.php - About 5 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

Function eat8 has a Cognitive Complexity of 25 (exceeds 5 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 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

Specifications has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class Specifications
{
    public static $capacity = [
        [0, 0, 0, [0, 0, 0, 0]],
        [21, 26, 0, [7, 10, 13, 17]], // 1
Severity: Minor
Found in src/QR_Code/Config/Specifications.php - About 3 hrs to fix

    Input has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Input
    {
        public $items;
    
        private $version;
    Severity: Minor
    Found in src/QR_Code/Encoder/Input.php - About 3 hrs to fix

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

              for ($i = 0; $i < Specifications::rsBlockNum2($spec); $i++) {
                  $ecc = array_slice($this->eccCode, $eccPos);
                  $this->rsBlocks[$blockNo] = new RsBlock($dl, array_slice($this->dataCode, $dataPos), $el, $ecc, $rs);
                  $this->eccCode = array_merge(array_slice($this->eccCode, 0, $eccPos), $ecc);
      
      Severity: Major
      Found in src/QR_Code/Encoder/RawCode.php and 1 other location - About 2 hrs to fix
      src/QR_Code/Encoder/RawCode.php on lines 77..85

      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 141.

      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

              for ($i = 0; $i < Specifications::rsBlockNum1($spec); $i++) {
                  $ecc = array_slice($this->eccCode, $eccPos);
                  $this->rsBlocks[$blockNo] = new RsBlock($dl, array_slice($this->dataCode, $dataPos), $el, $ecc, $rs);
                  $this->eccCode = array_merge(array_slice($this->eccCode, 0, $eccPos), $ecc);
      
      Severity: Major
      Found in src/QR_Code/Encoder/RawCode.php and 1 other location - About 2 hrs to fix
      src/QR_Code/Encoder/RawCode.php on lines 96..104

      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 141.

      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 calcN1N3 has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public function calcN1N3 ($length)
          {
              $demerit = 0;
      
              for ($i = 0; $i < $length; $i++) {
      Severity: Minor
      Found in src/QR_Code/Encoder/Mask.php - 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

      Function init_rs_char has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function init_rs_char ($symsize, $gfpoly, $fcr, $prim, $nroots, $pad)
          {
              // Common code for intializing a Reed-Solomon control block (char or int symbols)
              // Copyright 2004 Phil Karn, KA9Q
              // May be used under the terms of the GNU Lesser General Public License (LGPL)
      Severity: Minor
      Found in src/QR_Code/Encoder/ErrorCorrection/RsItem.php - 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

      Function init_rs has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function init_rs ($symsize, $gfpoly, $fcr, $prim, $nroots, $pad)
          {
              foreach (self::$items as $rs) {
                  if ($rs->pad != $pad) continue;
                  if ($rs->nroots != $nroots) continue;
      Severity: Minor
      Found in src/QR_Code/Encoder/ErrorCorrection/Rs.php - 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 debug has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function debug ($frame, $binary_mode = false)
          {
              if ($binary_mode) {
      
                  foreach ($frame as &$frameLine) {
      Severity: Major
      Found in src/QR_Code/Config/Specifications.php - About 2 hrs to fix

        Function next has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function next ()
            {
                do {
        
                    if ($this->bit == -1) {
        Severity: Minor
        Found in src/QR_Code/Util/FrameFiller.php - 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 init_rs_char has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function init_rs_char ($symsize, $gfpoly, $fcr, $prim, $nroots, $pad)
            {
                // Common code for intializing a Reed-Solomon control block (char or int symbols)
                // Copyright 2004 Phil Karn, KA9Q
                // May be used under the terms of the GNU Lesser General Public License (LGPL)
        Severity: Major
        Found in src/QR_Code/Encoder/ErrorCorrection/RsItem.php - About 2 hrs to fix

          Function eatAn has a Cognitive Complexity of 16 (exceeds 5 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 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 evaluateSymbol has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function evaluateSymbol (int $width, array $frame)
              {
                  $head = 0;
                  $demerit = 0;
          
          Severity: Major
          Found in src/QR_Code/Encoder/Mask.php - About 2 hrs to fix

            Method encodeMask has 51 lines of code (exceeds 25 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: Major
            Found in src/QR_Code/QR_Code.php - About 2 hrs to fix

              Method vectEPS has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function vectEPS ($frame, int $pixelPerPoint = 4, int $outerFrame = 4, int $backColor = 0xFFFFFF, int $foreColor = 0x000000, bool $cmyk = false) : string
                  {
                      $h = count($frame);
                      $w = strlen($frame[0]);
              
              Severity: Major
              Found in src/QR_Code/Encoder/Vector.php - About 2 hrs to fix

                Method createFrame has 49 lines of code (exceeds 25 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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language