iranianpep/code-jetter

View on GitHub
core/security/Validator.php

Summary

Maintainability
F
4 days
Test Coverage

Function validate has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate()
    {
        $output = new Output();
        if ($this->isAlreadyValidated()) {
            // return the current output is already validated
Severity: Minor
Found in core/security/Validator.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

File Validator.php has 507 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CodeJetter\core\security;

use CodeJetter\core\FormHandler;
Severity: Major
Found in core/security/Validator.php - About 1 day to fix

    Validator has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Validator
    {
        /**
         * @var array
         */
    Severity: Minor
    Found in core/security/Validator.php - About 5 hrs to fix

      The class Validator has an overall complexity of 123 which is very high. The configured complexity threshold is 50.
      Open

      class Validator
      {
          /**
           * @var array
           */
      Severity: Minor
      Found in core/security/Validator.php by phpmd

      Method validate has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function validate()
          {
              $output = new Output();
              if ($this->isAlreadyValidated()) {
                  // return the current output is already validated
      Severity: Major
      Found in core/security/Validator.php - About 2 hrs to fix

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

            public function getFilteredInputs()
            {
                if (!isset($this->filteredInputs)) {
                    $this->filteredInputs = [];
                    if (!empty($this->getDefinedInputs())) {
        Severity: Minor
        Found in core/security/Validator.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 validateWhitelist has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private function validateWhitelist(array $args)
            {
                $output = new Output();
        
                if (!isset($args['whitelist']) || !is_array($args['whitelist'])) {
        Severity: Minor
        Found in core/security/Validator.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 validatePassword has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function validatePassword(array $args)
            {
                $output = new Output();
                if (empty($args['toBeCheckedInput'])) {
                    $output->setSuccess(false);
        Severity: Minor
        Found in core/security/Validator.php - About 1 hr to fix

          Method validateWhitelist has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function validateWhitelist(array $args)
              {
                  $output = new Output();
          
                  if (!isset($args['whitelist']) || !is_array($args['whitelist'])) {
          Severity: Minor
          Found in core/security/Validator.php - About 1 hr to fix

            Function validatePassword has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private function validatePassword(array $args)
                {
                    $output = new Output();
                    if (empty($args['toBeCheckedInput'])) {
                        $output->setSuccess(false);
            Severity: Minor
            Found in core/security/Validator.php - About 55 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 addRequiredRule has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private function addRequiredRule()
                {
                    $inputs = $this->getDefinedInputs();
                    if (!empty($inputs)) {
                        foreach ($inputs as $input) {
            Severity: Minor
            Found in core/security/Validator.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 $output;
            Severity: Major
            Found in core/security/Validator.php - About 30 mins to fix

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

                  private function validateId(array $args)
                  {
                      $output = new Output();
                      if (!isset($args['toBeCheckedInput'])) {
                          $output->setSuccess(false);
              Severity: Minor
              Found in core/security/Validator.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

              The method validate() has 103 lines of code. Current threshold is set to 100. Avoid really long methods.
              Open

                  public function validate()
                  {
                      $output = new Output();
                      if ($this->isAlreadyValidated()) {
                          // return the current output is already validated
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              The method validate() has an NPath complexity of 520. The configured NPath complexity threshold is 200.
              Open

                  public function validate()
                  {
                      $output = new Output();
                      if ($this->isAlreadyValidated()) {
                          // return the current output is already validated
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              NPathComplexity

              Since: 0.1

              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

              Example

              class Foo {
                  function bar() {
                      // lots of complicated code
                  }
              }

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

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

                  public function validate()
                  {
                      $output = new Output();
                      if ($this->isAlreadyValidated()) {
                          // return the current output is already validated
              Severity: Minor
              Found in core/security/Validator.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 validateWhitelist() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
              Open

                  private function validateWhitelist(array $args)
                  {
                      $output = new Output();
              
                      if (!isset($args['whitelist']) || !is_array($args['whitelist'])) {
              Severity: Minor
              Found in core/security/Validator.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

              Missing class import via use statement (line '881', column '23').
              Open

                          throw new \Exception('whitelist must be specified and must be an array in validateWhiteList');
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '764', column '23').
              Open

                          throw new \Exception('form name must be specified in validateSize');
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '367', column '23').
              Open

                          throw new \Exception("Function '{$function}' does not exist in Validator.php");
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '385', column '23').
              Open

                          throw new \Exception("There is no such a rule: {$rule} in rules functions list");
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '433', column '23').
              Open

                          throw new \Exception('alreadyValidated must be boolean');
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '389', column '23').
              Open

                          throw new \Exception("There is no defined regex for the rule: {$rule}");
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '637', column '23').
              Open

                          throw new \Exception('size must be specified in validateSize');
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '411', column '23').
              Open

                          throw new \Exception('stopAtFirstError must be boolean');
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '246', column '27').
              Open

                              throw new \Exception('defined input is not instance of Input');
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '505', column '23').
              Open

                          throw new \Exception("{$success} is not a valid boolean");
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              The method validate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                                      } else {
                                          $errors[] = "{$definedInput->getTitle()} is required.";
                                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method validateRequired uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                      } else {
                          $toBeChecked = $args['toBeCheckedInput'];
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method setAllRequired uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                      } else {
                          $this->allRequired = false;
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method validate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                              } else {
                                  // $toBeCheckedInputs misses the defined input
                                  // check to see if the missing input is required
                                  //if (isset($rules['required']) || array_key_exists('required', $rules)) {
                                  if (isset($rules['required'])) {
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method validateWhitelist uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                      } else {
                          $flag = false;
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method getFunctionByRule uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                      } else {
                          // overwrite the normal way
                          $function = $rulesConfigs[$rule]['function'];
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method validateSize uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                      } else {
                          $result = strlen(trim($args['toBeCheckedInput'])) === $args['size'];
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method validateToken uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                      } else {
                          $finalOutput->setSuccess(false);
                          $finalOutput->setMessage('Token is not valid.');
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method validateId uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                      } else {
                          $minRange = 1;
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              The method validateUsername uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
              Open

                      } else {
                          $output->setSuccess(false);
                          $output->setMessage("'{$args['toBeCheckedInput']}' is not a valid username.");
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              ElseExpression

              Since: 1.4.0

              An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($flag) {
                          // one branch
                      } else {
                          // another branch
                      }
                  }
              }

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

              Avoid unused private methods such as 'validateNumber'.
              Open

                  private function validateNumber(array $args)
                  {
                      $output = new Output();
                      if (is_numeric($args['toBeCheckedInput'])) {
                          $output->setSuccess(true);
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateToken'.
              Open

                  private function validateToken(array $args)
                  {
                      if (!isset($args['formName'])) {
                          throw new \Exception('form name must be specified in validateSize');
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateEmail'.
              Open

                  private function validateEmail(array $args)
                  {
                      $output = new Output();
                      if (filter_var($args['toBeCheckedInput'], FILTER_VALIDATE_EMAIL)) {
                          $output->setSuccess(true);
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateId'.
              Open

                  private function validateId(array $args)
                  {
                      $output = new Output();
                      if (!isset($args['toBeCheckedInput'])) {
                          $output->setSuccess(false);
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validatePassword'.
              Open

                  private function validatePassword(array $args)
                  {
                      $output = new Output();
                      if (empty($args['toBeCheckedInput'])) {
                          $output->setSuccess(false);
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateMoney'.
              Open

                  private function validateMoney(array $args)
                  {
                      $output = new Output();
                      if (preg_match("/^-?[0-9]+(?:\.[0-9]{1,2})?$/", $args['toBeCheckedInput'])) {
                          $output->setSuccess(true);
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateSize'.
              Open

                  private function validateSize(array $args)
                  {
                      if (!isset($args['size'])) {
                          throw new \Exception('size must be specified in validateSize');
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateWhitelist'.
              Open

                  private function validateWhitelist(array $args)
                  {
                      $output = new Output();
              
                      if (!isset($args['whitelist']) || !is_array($args['whitelist'])) {
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateUsername'.
              Open

                  private function validateUsername(array $args)
                  {
                      $output = new Output();
                      if (empty($args['toBeCheckedInput'])) {
                          $output->setSuccess(false);
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateRequired'.
              Open

                  private function validateRequired(array $args)
                  {
                      if (isset($args['toBeCheckedInput']) && is_string($args['toBeCheckedInput'])) {
                          $toBeChecked = trim($args['toBeCheckedInput']);
                      } else {
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              Avoid unused private methods such as 'validateUrl'.
              Open

                  private function validateUrl(array $args)
                  {
                      $output = new Output();
                      // FILTER_VALIDATE_URL is not sophisticated enough, so use the next regex:
                      // https://gist.github.com/dperini/729294
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              UnusedPrivateMethod

              Since: 0.2

              Unused Private Method detects when a private method is declared but is unused.

              Example

              class Something
              {
                  private function foo() {} // unused
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

              The 'getDataByKey()' method which returns a boolean should be named 'is...()' or 'has...()'
              Open

                  public function getDataByKey($ruleKey)
                  {
                      if (empty($ruleKey)) {
                          return false;
                      }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              BooleanGetMethodName

              Since: 0.2

              Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

              Example

              class Foo {
                  /**
                   * @return boolean
                   */
                  public function getFoo() {} // bad
                  /**
                   * @return bool
                   */
                  public function isFoo(); // ok
                  /**
                   * @return boolean
                   */
                  public function getFoo($bar); // ok, unless checkParameterizedMethods=true
              }

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

              The 'getSuccess()' method which returns a boolean should be named 'is...()' or 'has...()'
              Open

                  public function getSuccess()
                  {
                      return $this->success;
                  }
              Severity: Minor
              Found in core/security/Validator.php by phpmd

              BooleanGetMethodName

              Since: 0.2

              Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

              Example

              class Foo {
                  /**
                   * @return boolean
                   */
                  public function getFoo() {} // bad
                  /**
                   * @return bool
                   */
                  public function isFoo(); // ok
                  /**
                   * @return boolean
                   */
                  public function getFoo($bar); // ok, unless checkParameterizedMethods=true
              }

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

              There are no issues that match your filters.

              Category
              Status