honeybee/trellis

View on GitHub
src/Runtime/Validator/Rule/Type/UrlRule.php

Summary

Maintainability
F
3 days
Test Coverage

Method execute has 212 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function execute($value, EntityInterface $entity = null)
    {
        if (!is_string($value)) {
            $this->throwError('non_string_value', [ 'value' => $value ], IncidentInterface::CRITICAL);
            return false;
Severity: Major
Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 1 day to fix

    Function execute has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function execute($value, EntityInterface $entity = null)
        {
            if (!is_string($value)) {
                $this->throwError('non_string_value', [ 'value' => $value ], IncidentInterface::CRITICAL);
                return false;
    Severity: Minor
    Found in src/Runtime/Validator/Rule/Type/UrlRule.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 UrlRule.php has 323 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Trellis\Runtime\Validator\Rule\Type;
    
    use Trellis\Common\Error\RuntimeException;
    Severity: Minor
    Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 3 hrs to fix

      Function getUrlFromArray has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getUrlFromArray(array $url_parts)
          {
              // generate the resulting URL
              $url = $url_parts['scheme'] . $this->getOption(self::OPTION_SCHEME_SEPARATOR, '://');
      
      
      Severity: Minor
      Found in src/Runtime/Validator/Rule/Type/UrlRule.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 getUrlFromArray has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getUrlFromArray(array $url_parts)
          {
              // generate the resulting URL
              $url = $url_parts['scheme'] . $this->getOption(self::OPTION_SCHEME_SEPARATOR, '://');
      
      
      Severity: Minor
      Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                    return false;
        Severity: Major
        Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return false;
          Severity: Major
          Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return false;
            Severity: Major
            Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return false;
              Severity: Major
              Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return false;
                Severity: Major
                Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return false;
                  Severity: Major
                  Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return true;
                    Severity: Major
                    Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return false;
                      Severity: Major
                      Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return false;
                        Severity: Major
                        Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return false;
                          Severity: Major
                          Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return false;
                            Severity: Major
                            Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return false;
                              Severity: Major
                              Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return false;
                                Severity: Major
                                Found in src/Runtime/Validator/Rule/Type/UrlRule.php - About 30 mins to fix

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

                                      public function __construct($name, array $options = [])
                                      {
                                          // use sensible default max length for URLs
                                          if (!array_key_exists(self::OPTION_MAX_LENGTH, $options)) {
                                              // http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
                                  Severity: Minor
                                  Found in src/Runtime/Validator/Rule/Type/UrlRule.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

                                  There are no issues that match your filters.

                                  Category
                                  Status