fhteam/laravel-validator

View on GitHub

Showing 17 of 17 total issues

ArrayDataStorage has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

class ArrayDataStorage implements ArrayAccess, IteratorAggregate
{
    const KEY_CASE_NO_CHANGE = 0;

    const KEY_CASE_SNAKE = 1;
Severity: Minor
Found in src/Utility/ArrayDataStorage.php - About 3 hrs to fix

    AbstractValidator has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class AbstractValidator implements MessageProvider, ArrayAccess, IteratorAggregate
    {
        /**
         * @var null|bool Null if validation never ran, false if failed, true if passed
         */
    Severity: Minor
    Found in src/Validator/AbstractValidator.php - About 3 hrs to fix

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

          public function postProcessRules(array &$rules)
          {
              $postProcessors = [];
              $hasArrayRule = false;
              foreach ($rules as $attribute => &$attributeRules) {
      Severity: Minor
      Found in src/Engine/RulePostProcessors/ArrayRulePostProcessor.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          protected function fillParameters(array $routeParams)
          {
              foreach ($routeParams as $key => $value) {
                  if (strlen($value) < 2) {
                      continue;
      Severity: Minor
      Found in src/Validator/Input/AbstractRedirectingInputValidator.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 getRedirect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getRedirect()
          {
              $currentRouteMethod = $this->currentRouteMethod();
      
              if (!isset($this->errorRedirects[$currentRouteMethod])) {
      Severity: Minor
      Found in src/Validator/Input/AbstractRedirectingInputValidator.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 isThisValid has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function isThisValid($object = null)
          {
              $objectData = $this->getObjectData($object);
              $this->lastState = $this->getState($object);
              $rules = Arr::mergeByCondition($this->rules, $this->lastState);
      Severity: Minor
      Found in src/Validator/AbstractValidator.php - About 1 hr to fix

        Method getRedirect has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getRedirect()
            {
                $currentRouteMethod = $this->currentRouteMethod();
        
                if (!isset($this->errorRedirects[$currentRouteMethod])) {
        Severity: Minor
        Found in src/Validator/Input/AbstractRedirectingInputValidator.php - About 1 hr to fix

          Method postProcessRules has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function postProcessRules(array &$rules)
              {
                  $postProcessors = [];
                  $hasArrayRule = false;
                  foreach ($rules as $attribute => &$attributeRules) {
          Severity: Minor
          Found in src/Engine/RulePostProcessors/ArrayRulePostProcessor.php - About 1 hr to fix

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

                public static function mergeByCondition(array $data, $condition = null, $allowEmpty = false)
                {
                    if (null == $condition) {
                        return $data;
                    }
            Severity: Minor
            Found in src/Utility/Arr.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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function validate($attribute, $value, array $parameters = [])
                {
                    if (count($parameters) < 1) {
                        throw new Exception("ImageDimensionValidationRule requires at least one parameter");
                    }
            Severity: Minor
            Found in src/Rule/Image/ImageDimensionValidationRule.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 setKeyNormalizer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function setKeyNormalizer($keyCase)
                {
                    if (null !== $this->data) {
                        throw new Exception("Cannot change key normalizer if data was already filled in");
                    }
            Severity: Minor
            Found in src/Utility/ArrayDataStorage.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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function validate($attribute, $value, array $parameters = [])
                {
                    if (count($parameters) !== 2) {
                        throw new Exception("ImageRatioRule requires two parameters to be passed: min and max ratio");
                    }
            Severity: Minor
            Found in src/Rule/Image/ImageRatioValidationRule.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 true;
            Severity: Major
            Found in src/Rule/Image/ImageDimensionValidationRule.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return true;
              Severity: Major
              Found in src/Rule/Json/JsonArrayValidationRule.php - About 30 mins to fix

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

                    public function validate($attribute, $value, array $parameters = [])
                    {
                        $result = json_decode($value, true);
                        if (json_last_error() !== JSON_ERROR_NONE) {
                            return false;
                Severity: Minor
                Found in src/Rule/Json/JsonArrayValidationRule.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 collectData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function collectData()
                    {
                        $data = [];
                
                        if ($this->inputTypes & self::VALIDATE_INPUT) {
                Severity: Minor
                Found in src/Validator/Input/AbstractInputValidator.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function validate($attribute, $value, array $parameters = [])
                    {
                        if (!is_array($value)) {
                            return false;
                        }
                Severity: Minor
                Found in src/Rule/Arrays/ArrayOfUIntValidationRule.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