speedworks/speedy

View on GitHub
Core/Classes/System.php

Summary

Maintainability
D
1 day
Test Coverage

Crypto accesses the super-global variable $_ENV.
Open

    public static function Crypto($inData, $opt="D")
    {
        $outData="";
        $iv = "r@nD0mKey#osekj%^876ghjkjb5dDdf8";
        if($opt=='E')
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

GenerateHash accesses the super-global variable $_ENV.
Open

    public static function GenerateHash($plainPassword, $saltKey=null)
    {
        $salt = isset($_ENV['app_key'])?$_ENV['app_key']:"$#@kT!@p!7ram3w0rk";
        $salt = $saltKey == null ? $salt : $saltKey;
        $hash = hash_hmac('sha256', $plainPassword, $salt, false);
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

GenerateHash accesses the super-global variable $_ENV.
Open

    public static function GenerateHash($plainPassword, $saltKey=null)
    {
        $salt = isset($_ENV['app_key'])?$_ENV['app_key']:"$#@kT!@p!7ram3w0rk";
        $salt = $saltKey == null ? $salt : $saltKey;
        $hash = hash_hmac('sha256', $plainPassword, $salt, false);
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

GenerateSecret accesses the super-global variable $_ENV.
Open

    public static function GenerateSecret($digestString)
    {
        $digestString.='|'.$_ENV['app_key'].'|'.microtime(true);
        $hash = hash_hmac('crc32b', $digestString, microtime(true), false);
        return $hash;
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

GiveError accesses the super-global variable $_ENV.
Open

    public static function GiveError($errorCode, $errorMessage)
    {
        if($errorCode==400)
        {
            header("HTTP/1.0 400 Bad Request");
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

GiveError accesses the super-global variable $_ENV.
Open

    public static function GiveError($errorCode, $errorMessage)
    {
        if($errorCode==400)
        {
            header("HTTP/1.0 400 Bad Request");
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Crypto accesses the super-global variable $_ENV.
Open

    public static function Crypto($inData, $opt="D")
    {
        $outData="";
        $iv = "r@nD0mKey#osekj%^876ghjkjb5dDdf8";
        if($opt=='E')
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

GiveError accesses the super-global variable $_ENV.
Open

    public static function GiveError($errorCode, $errorMessage)
    {
        if($errorCode==400)
        {
            header("HTTP/1.0 400 Bad Request");
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

GenerateAPIKey accesses the super-global variable $_ENV.
Open

    public static function GenerateAPIKey($digestString)
    {
        $digestString.='|'.$_ENV['app_key'].'|'.microtime(true);
        $hash = hash_hmac('sha1', $digestString, microtime(true), false);
        return $hash;
Severity: Minor
Found in Core/Classes/System.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Function GiveError has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    public static function GiveError($errorCode, $errorMessage)
    {
        if($errorCode==400)
        {
            header("HTTP/1.0 400 Bad Request");
Severity: Minor
Found in Core/Classes/System.php - About 6 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

The class System has 12 public methods. Consider refactoring System to keep number of public methods under 10.
Open

class System
{
    /**
     * System constructor.
     */
Severity: Minor
Found in Core/Classes/System.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Function FilterInput has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public static function FilterInput($inData, $keepHTML=false)
    {
        if(is_array($inData))
        {
            $outData=array();
Severity: Minor
Found in Core/Classes/System.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 GiveError has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function GiveError($errorCode, $errorMessage)
    {
        if($errorCode==400)
        {
            header("HTTP/1.0 400 Bad Request");
Severity: Minor
Found in Core/Classes/System.php - About 1 hr to fix

    Method FilterInput has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function FilterInput($inData, $keepHTML=false)
        {
            if(is_array($inData))
            {
                $outData=array();
    Severity: Minor
    Found in Core/Classes/System.php - About 1 hr to fix

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

          public static function MakeLog($logdir, $filename, $logstr)
          {
              $logstr .= "\n";
              if(is_dir($logdir.date('Y')))
              {
      Severity: Minor
      Found in Core/Classes/System.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 DBD has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function DBD($inData, $die=false) //DEBUG AND DIE
          {
              if(is_array($inData))
              {
                  echo "<pre><br/>\n";
      Severity: Minor
      Found in Core/Classes/System.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

      The method GiveError() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
      Open

          public static function GiveError($errorCode, $errorMessage)
          {
              if($errorCode==400)
              {
                  header("HTTP/1.0 400 Bad Request");
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

      The method DBD has a boolean flag argument $die, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public static function DBD($inData, $die=false) //DEBUG AND DIE
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      The method FilterInput has a boolean flag argument $keepHTML, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public static function FilterInput($inData, $keepHTML=false)
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      The method GiveJSON() contains an exit expression.
      Open

              exit();
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      ExitExpression

      Since: 0.2

      An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

      Example

      class Foo {
          public function bar($param)  {
              if ($param === 42) {
                  exit(23);
              }
          }
      }

      Source https://phpmd.org/rules/design.html#exitexpression

      The method DBD() contains an exit expression.
      Open

                  die;
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      ExitExpression

      Since: 0.2

      An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

      Example

      class Foo {
          public function bar($param)  {
              if ($param === 42) {
                  exit(23);
              }
          }
      }

      Source https://phpmd.org/rules/design.html#exitexpression

      The method GiveResponse() contains an exit expression.
      Open

              exit();
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      ExitExpression

      Since: 0.2

      An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

      Example

      class Foo {
          public function bar($param)  {
              if ($param === 42) {
                  exit(23);
              }
          }
      }

      Source https://phpmd.org/rules/design.html#exitexpression

      The method GiveError() contains an exit expression.
      Open

              exit();
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      ExitExpression

      Since: 0.2

      An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

      Example

      class Foo {
          public function bar($param)  {
              if ($param === 42) {
                  exit(23);
              }
          }
      }

      Source https://phpmd.org/rules/design.html#exitexpression

      Avoid variables with short names like $iv. Configured minimum length is 3.
      Open

              $iv = "r@nD0mKey#osekj%^876ghjkjb5dDdf8";
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      The method Crypto is not named in camelCase.
      Open

          public static function Crypto($inData, $opt="D")
          {
              $outData="";
              $iv = "r@nD0mKey#osekj%^876ghjkjb5dDdf8";
              if($opt=='E')
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method FilterInput is not named in camelCase.
      Open

          public static function FilterInput($inData, $keepHTML=false)
          {
              if(is_array($inData))
              {
                  $outData=array();
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method GenerateHash is not named in camelCase.
      Open

          public static function GenerateHash($plainPassword, $saltKey=null)
          {
              $salt = isset($_ENV['app_key'])?$_ENV['app_key']:"$#@kT!@p!7ram3w0rk";
              $salt = $saltKey == null ? $salt : $saltKey;
              $hash = hash_hmac('sha256', $plainPassword, $salt, false);
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method GiveError is not named in camelCase.
      Open

          public static function GiveError($errorCode, $errorMessage)
          {
              if($errorCode==400)
              {
                  header("HTTP/1.0 400 Bad Request");
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method MakeLog is not named in camelCase.
      Open

          public static function MakeLog($logdir, $filename, $logstr)
          {
              $logstr .= "\n";
              if(is_dir($logdir.date('Y')))
              {
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method DBD is not named in camelCase.
      Open

          public static function DBD($inData, $die=false) //DEBUG AND DIE
          {
              if(is_array($inData))
              {
                  echo "<pre><br/>\n";
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method GiveResponse is not named in camelCase.
      Open

          public static function GiveResponse($inData)
          {
              header('Content-Type: application/json');
              $outData=array('errStatus' =>0,
                  'code'=>200,
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method GenerateSecret is not named in camelCase.
      Open

          public static function GenerateSecret($digestString)
          {
              $digestString.='|'.$_ENV['app_key'].'|'.microtime(true);
              $hash = hash_hmac('crc32b', $digestString, microtime(true), false);
              return $hash;
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method GenerateAPIKey is not named in camelCase.
      Open

          public static function GenerateAPIKey($digestString)
          {
              $digestString.='|'.$_ENV['app_key'].'|'.microtime(true);
              $hash = hash_hmac('sha1', $digestString, microtime(true), false);
              return $hash;
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method GiveJSON is not named in camelCase.
      Open

          public static function GiveJSON($inData)
          {
              header('Content-Type: application/json');
              $outData=json_encode($inData);
              echo $outData;
      Severity: Minor
      Found in Core/Classes/System.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status