avalanche-development/swagger-validation-middleware

View on GitHub

Showing 7 of 14 total issues

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

    protected function checkParamValue(array $param)
    {
        if ($param['type'] === 'array') {
            $this->checkItems($param);

Severity: Minor
Found in src/Parameter/ParameterCheck.php - About 1 hr to fix

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

        public function check(array $param)
        {
            if (!is_string($param['value'])) {
                throw new ValidationException('Value is not a string');
            }
    Severity: Minor
    Found in src/Parameter/Format/StringCheck.php - About 1 hr to fix

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

          public function check(array $param)
          {
              if (!is_string($param['value'])) {
                  throw new ValidationException('Value is not a string');
              }
      Severity: Minor
      Found in src/Parameter/Format/StringCheck.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 check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function check(array $param)
          {
              if (!filter_var($param['value'], FILTER_VALIDATE_INT)) {
                  throw new ValidationException('Value is not an integer');
              }
      Severity: Minor
      Found in src/Parameter/Format/IntegerCheck.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

      Avoid too many return statements within this method.
      Open

                  return;
      Severity: Major
      Found in src/Parameter/ParameterCheck.php - About 30 mins to fix

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

            protected function checkRange(array $param)
            {
                if (isset($param['maximum']) && $param['value'] > $param['maximum']) {
                    throw new ValidationException('Value exceeds maximum');
                }
        Severity: Minor
        Found in src/Parameter/Format/NumberCheck.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

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

            protected function checkItems(array $param)
            {
                if (isset($param['maxItems']) && $param['maxItems'] < count($param['value'])) {
                    throw new ValidationException('Size of array exceeds maxItems');
                }
        Severity: Minor
        Found in src/Parameter/ParameterCheck.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

        Severity
        Category
        Status
        Source
        Language