tflori/verja

View on GitHub

Showing 16 of 26 total issues

Function validateTypes has a Cognitive Complexity of 23 (exceeds 9 allowed). Consider refactoring.
Open

    protected function validateTypes(string $number): bool
    {
        foreach ($this->types as $type) {
            // types that we can't validate are valid
            if (!isset(static::$cardTypes[$type])) {
Severity: Minor
Found in src/Validator/CreditCard.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 validate has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function validate($value, array $context = []): bool
    {
        $flags = 0;

        $ipName = 'ip address';
Severity: Major
Found in src/Validator/IpAddress.php - About 2 hrs to fix

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

        public function validate($value, array $context = []): bool
        {
            if (!is_string($value) || !$url = parse_url($value)) {
                // not a string or not a url
                $this->error = new Error(
    Severity: Major
    Found in src/Validator/Url.php - About 2 hrs to fix

      Function validate has a Cognitive Complexity of 21 (exceeds 9 allowed). Consider refactoring.
      Open

          public function validate($value, array $context = []): bool
          {
              if (!is_string($value) || !$url = parse_url($value)) {
                  // not a string or not a url
                  $this->error = new Error(
      Severity: Minor
      Found in src/Validator/Url.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 validate has a Cognitive Complexity of 19 (exceeds 9 allowed). Consider refactoring.
      Open

          public function validate($value, array $context = []): bool
          {
              $flags = 0;
      
              $ipName = 'ip address';
      Severity: Minor
      Found in src/Validator/IpAddress.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 getData has a Cognitive Complexity of 18 (exceeds 9 allowed). Consider refactoring.
      Open

          public function getData(string $key = null, $validate = true)
          {
              if ($key !== null) {
                  if (!isset($this->fields[$key])) {
                      return null;
      Severity: Minor
      Found in src/Gate.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 assert has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function assert($field, $value, array $context = [])
          {
              if (!$field instanceof Field) {
                  $definitions = [];
                  if (is_array($field)) {
      Severity: Minor
      Found in src/Gate.php - About 1 hr to fix

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

            public function validate($value, array $context = []): bool
            {
                if (!is_int($value) && !is_double($value)) {
                    $this->error = new Error('NO_NUMBER', $value, 'value should be a number');
                    return false;
        Severity: Minor
        Found in src/Validator/Between.php - About 1 hr to fix

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

              public function getData(string $key = null, $validate = true)
              {
                  if ($key !== null) {
                      if (!isset($this->fields[$key])) {
                          return null;
          Severity: Minor
          Found in src/Gate.php - About 1 hr to fix

            Avoid too many return statements within this method.
            Open

                                return false;
            Severity: Major
            Found in src/Validator/Url.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return true;
              Severity: Major
              Found in src/Validator/Url.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return false;
                Severity: Major
                Found in src/Validator/Url.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return true;
                  Severity: Major
                  Found in src/Validator/IpAddress.php - About 30 mins to fix

                    Function assert has a Cognitive Complexity of 10 (exceeds 9 allowed). Consider refactoring.
                    Open

                        public static function assert($field, $value, array $context = [])
                        {
                            if (!$field instanceof Field) {
                                $definitions = [];
                                if (is_array($field)) {
                    Severity: Minor
                    Found in src/Gate.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 10 (exceeds 9 allowed). Consider refactoring.
                    Open

                        public function validate($value, array $context = [])
                        {
                            $filtered = $this->filter($value, $context);
                    
                            if ($this->filterFailed) {
                    Severity: Minor
                    Found in src/Field.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 addFilterOrValidator has a Cognitive Complexity of 10 (exceeds 9 allowed). Consider refactoring.
                    Open

                        public function addFilterOrValidator($definition)
                        {
                            if ($definition instanceof FilterInterface) {
                                $this->addFilter($definition);
                            } elseif ($definition instanceof ValidatorInterface) {
                    Severity: Minor
                    Found in src/Field.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