CORE-POS/IS4C

View on GitHub
pos/is4c-nf/lib/Bitmap.php

Summary

Maintainability
F
1 wk
Test Coverage
F
30%

File Bitmap.php has 593 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace COREPOS\pos\lib;
use \Exception;

Severity: Major
Found in pos/is4c-nf/lib/Bitmap.php - About 1 day to fix

    Function load has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        public function load($filename, $filedata=null) 
        {
            $data = "";
            if ($filename === true) {
                $data = $filedata;
    Severity: Minor
    Found in pos/is4c-nf/lib/Bitmap.php - About 1 day 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 load has 168 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function load($filename, $filedata=null) 
        {
            $data = "";
            if ($filename === true) {
                $data = $filedata;
    Severity: Major
    Found in pos/is4c-nf/lib/Bitmap.php - About 6 hrs to fix

      Bitmap has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Bitmap 
      {
          private $DIB1 = 12;
          private $DIB2 = 64;
          private $DIB3 = 40;
      Severity: Minor
      Found in pos/is4c-nf/lib/Bitmap.php - About 2 hrs to fix

        Method save has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function save($filename) {
                // prepare the image
                $rowBytes = (int)((($this->width * $this->bpp) + 7) / 8);
                $rowDataSize = (int)((($this->width * $this->bpp) + 31) / 32) * 4;
                if ($rowBytes > $rowDataSize) {
        Severity: Major
        Found in pos/is4c-nf/lib/Bitmap.php - About 2 hrs to fix

          Method setPixelValue has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function setPixelValue($x, $y, $val) 
              {
                  // validate coordinates
                  if ($x < 0) {
                      $x += $this->width;
          Severity: Minor
          Found in pos/is4c-nf/lib/Bitmap.php - About 1 hr to fix

            Method drawLine has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function drawLine($pt1, $pt2, $val) 
                {
                    // validate coordinates
                    try {
                        $pt1[0] = $this->validateCoord($pt1[0], $this->width);
            Severity: Minor
            Found in pos/is4c-nf/lib/Bitmap.php - About 1 hr to fix

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

                  public function drawLine($pt1, $pt2, $val) 
                  {
                      // validate coordinates
                      try {
                          $pt1[0] = $this->validateCoord($pt1[0], $this->width);
              Severity: Minor
              Found in pos/is4c-nf/lib/Bitmap.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 getPixelValue has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getPixelValue($x, $y) 
                  {
                      // validate coordinates
                      if ($x < 0) {
                          $x += $this->width;
              Severity: Minor
              Found in pos/is4c-nf/lib/Bitmap.php - About 1 hr to fix

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

                    private function parseInt($data, $left=0, $right=-1, $signed=false, $bigEndian=false) 
                    {
                        if (is_string($data)) {
                            $isarray = false;
                            if ($right < 0) {
                Severity: Minor
                Found in pos/is4c-nf/lib/Bitmap.php - About 1 hr to fix

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

                      private function parseInt($data, $left=0, $right=-1, $signed=false, $bigEndian=false) 
                      {
                          if (is_string($data)) {
                              $isarray = false;
                              if ($right < 0) {
                  Severity: Minor
                  Found in pos/is4c-nf/lib/Bitmap.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 renderBitmap has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      static private function renderBitmap($arg)
                      {
                          global $PRINT_OBJ;
                          $slip = "";
                  
                  
                  Severity: Minor
                  Found in pos/is4c-nf/lib/Bitmap.php - About 1 hr to fix

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

                        private function setPixelValue($x, $y, $val) 
                        {
                            // validate coordinates
                            if ($x < 0) {
                                $x += $this->width;
                    Severity: Minor
                    Found in pos/is4c-nf/lib/Bitmap.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 __construct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __construct($width=1, $height=1, $bpp=1, $dpi=72) 
                        {
                            $this->error = null;
                            
                            if (!is_numeric($width) || (int)$width < 1) {
                    Severity: Minor
                    Found in pos/is4c-nf/lib/Bitmap.php - About 1 hr to fix

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

                          public function save($filename) {
                              // prepare the image
                              $rowBytes = (int)((($this->width * $this->bpp) + 7) / 8);
                              $rowDataSize = (int)((($this->width * $this->bpp) + 31) / 32) * 4;
                              if ($rowBytes > $rowDataSize) {
                      Severity: Minor
                      Found in pos/is4c-nf/lib/Bitmap.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

                      Consider simplifying this complex logical expression.
                      Open

                              if ($bpp != 1 && $bpp != 4 && $bpp != 8 && $bpp != 16 && $bpp != 24 && $bpp != 32) {
                                  return $this->returnError("load(): invalid bits-per-pixel ".$bpp);
                              }
                      Severity: Major
                      Found in pos/is4c-nf/lib/Bitmap.php - About 40 mins to fix

                        Method parseInt has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            private function parseInt($data, $left=0, $right=-1, $signed=false, $bigEndian=false) 
                        Severity: Minor
                        Found in pos/is4c-nf/lib/Bitmap.php - About 35 mins to fix

                          Function renderBitmap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              static private function renderBitmap($arg)
                              {
                                  global $PRINT_OBJ;
                                  $slip = "";
                          
                          
                          Severity: Minor
                          Found in pos/is4c-nf/lib/Bitmap.php - 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

                          Avoid too many return statements within this method.
                          Open

                                              return $this->returnError("load(): ".$bpp." bits-per-pixel invalid in V1 header");
                          Severity: Major
                          Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return $this->returnError("save(): failed writing file \"".$filename."\" (".$bytes." of ".strlen($data)." bytes written)");
                            Severity: Major
                            Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return $this->returnError("load(): incomplete DIB header (file is ".$datasize." bytes)");
                              Severity: Major
                              Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return $this->returnError("load(): invalid image height ".$height);
                                Severity: Major
                                Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return $data;
                                  Severity: Major
                                  Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return $this->returnError("load(): invalid horizontal pixels-per-meter ".$hppm);
                                    Severity: Major
                                    Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return $this->parseInt($this->image, $byte, $byte + 1);
                                      Severity: Major
                                      Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return $this->returnError("load(): invalid image width ".$width);
                                        Severity: Major
                                        Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return $this->returnError("load(): invalid color plane count ".$colorPlanes);
                                          Severity: Major
                                          Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                        return $this->returnError("load(): invalid bits-per-pixel ".$bpp);
                                            Severity: Major
                                            Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                          return $this->returnError("load(): incomplete image (file is ".$datasize." bytes)");
                                              Severity: Major
                                              Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                        return true;
                                                Severity: Major
                                                Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return true;
                                                  Severity: Major
                                                  Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                    return ord($this->image[$byte]);
                                                    Severity: Major
                                                    Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return $this->returnError("load(): image data compression not supported");
                                                      Severity: Major
                                                      Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                    return $this->returnError("load(): consistency error (calculated byte width ".$rowBytes.", data width ".$rowDataSize.")");
                                                        Severity: Major
                                                        Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                      return $this->returnError("save(): consistency error (calculated DIB size ".$this->dibVersion.", prepared ".strlen($dibHead).")");
                                                          Severity: Major
                                                          Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                            return $this->returnError("load(): invalid compression code ".$compression);
                                                            Severity: Major
                                                            Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return $this->returnError("load(): incorrect image data size (".$imgDataSize." reported, ".(abs($height) * $rowDataSize)." expected)");
                                                              Severity: Major
                                                              Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                            return $this->returnError("load(): invalid vertical pixels-per-meter ".$hppm);
                                                                Severity: Major
                                                                Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                  return $this->returnError("load(): incomplete palette (file is ".$datasize." bytes)");
                                                                  Severity: Major
                                                                  Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                    return $this->returnError("load(): unknown DIB header size (".$headerSize." bytes)");
                                                                    Severity: Major
                                                                    Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                              return null;
                                                                      Severity: Major
                                                                      Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                        return true;
                                                                        Severity: Major
                                                                        Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                          return true;
                                                                          Severity: Major
                                                                          Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                    return null;
                                                                            Severity: Major
                                                                            Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                              return true;
                                                                              Severity: Major
                                                                              Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                return ((ord($this->image[$byte]) >> $shift) & 0x0F);
                                                                                Severity: Major
                                                                                Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                                  return ((ord($this->image[$byte]) >> $shift) & 0x01);
                                                                                  Severity: Major
                                                                                  Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                                    return true;
                                                                                    Severity: Major
                                                                                    Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                      return true;
                                                                                      Severity: Major
                                                                                      Found in pos/is4c-nf/lib/Bitmap.php - About 30 mins to fix

                                                                                        There are no issues that match your filters.

                                                                                        Category
                                                                                        Status