thunderer/Shortcode

View on GitHub

Showing 22 of 22 total issues

Function shortcode has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    private function shortcode(array &$names)
    {
        if(!$this->match(self::TOKEN_OPEN, false)) { return false; }
        $offset = $this->tokens[$this->position - 1][2];
        $this->match(self::TOKEN_WS, false);
Severity: Minor
Found in src/Parser/RegularParser.php - About 4 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 shortcode has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function shortcode(array &$names)
    {
        if(!$this->match(self::TOKEN_OPEN, false)) { return false; }
        $offset = $this->tokens[$this->position - 1][2];
        $this->match(self::TOKEN_WS, false);
Severity: Major
Found in src/Parser/RegularParser.php - About 2 hrs to fix

    File RegularParser.php has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    namespace Thunder\Shortcode\Parser;
    
    use Thunder\Shortcode\Shortcode\ParsedShortcode;
    use Thunder\Shortcode\Shortcode\Shortcode;
    Severity: Minor
    Found in src/Parser/RegularParser.php - About 2 hrs to fix

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

          private static function parseParameters($text)
          {
              $text = preg_replace('/[\x{00a0}\x{200b}]+/u', ' ', $text);
      
              if(!preg_match_all(static::$argumentsRegex, $text, $matches, PREG_SET_ORDER)) {
      Severity: Minor
      Found in src/Parser/WordpressParser.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 parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parse($text)
          {
              $nestingLevel = ini_set('xdebug.max_nesting_level', '-1');
              $this->tokens = $this->tokenize($text);
              $this->backtracks = array();
      Severity: Minor
      Found in src/Parser/RegularParser.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 parameters has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          private function parameters()
          {
              $parameters = array();
      
              while(true) {
      Severity: Minor
      Found in src/Parser/RegularParser.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 tokenize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          private function tokenize($text)
          {
              $count = preg_match_all($this->lexerRegex, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
              if(false === $count || preg_last_error() !== PREG_NO_ERROR) {
                  throw new \RuntimeException(sprintf('PCRE failure `%s`.', preg_last_error()));
      Severity: Minor
      Found in src/Parser/RegularParser.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 processIteration has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function processIteration($text, ProcessorContext $context, ProcessedShortcode $parent = null)
          {
              if (null !== $this->recursionDepth && $context->recursionLevel > $this->recursionDepth) {
                  return $text;
              }
      Severity: Minor
      Found in src/Processor/Processor.php - About 1 hr to fix

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

            public function parse($text)
            {
                $nestingLevel = ini_set('xdebug.max_nesting_level', '-1');
                $this->tokens = $this->tokenize($text);
                $this->backtracks = array();
        Severity: Minor
        Found in src/Parser/RegularParser.php - About 1 hr to fix

          Method getObject has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private function getObject($name, $parameters, $bbCode, $offset, $content, $text)
          Severity: Minor
          Found in src/Parser/RegularParser.php - About 45 mins to fix

            Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    $openingTag = null,
                    $closingTag = null,
                    $closingTagMarker = null,
                    $parameterValueSeparator = null,
                    $parameterValueDelimiter = null
            Severity: Minor
            Found in src/Syntax/Syntax.php - About 35 mins to fix

              Function value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function value()
                  {
                      $value = '';
              
                      if($this->match(self::TOKEN_DELIMITER, false)) {
              Severity: Minor
              Found in src/Parser/RegularParser.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 array($this->getObject($name, $parameters, $bbCode, $offset, null, $this->getBacktrack()));
              Severity: Major
              Found in src/Parser/RegularParser.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        if(false === $bbCode) { return false; }
                Severity: Major
                Found in src/Parser/RegularParser.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $closingName;
                  Severity: Major
                  Found in src/Parser/RegularParser.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            if(false === ($parameters = $this->parameters())) { return false; }
                    Severity: Major
                    Found in src/Parser/RegularParser.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              if(!$this->match(self::TOKEN_CLOSE, false)) { return false; }
                      Severity: Major
                      Found in src/Parser/RegularParser.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return array($this->getObject($name, $parameters, $bbCode, $offset, $content, $this->getBacktrack()));
                        Severity: Major
                        Found in src/Parser/RegularParser.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return \in_array($closingName, $names, true) ? $closingName : false;
                          Severity: Major
                          Found in src/Parser/RegularParser.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    if(!$this->close($names)) { return false; }
                            Severity: Major
                            Found in src/Parser/RegularParser.php - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language