phug-php/lexer

View on GitHub

Showing 28 of 28 total issues

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

    public function scan(State $state)
    {
        $reader = $state->getReader();

        if ($reader->match('(?<raw>\!)?#\{')) {
Severity: Minor
Found in Lexer/Scanner/DynamicTagScanner.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 scan has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function scan(State $state)
    {
        $reader = $state->getReader();

        foreach ($state->scanToken(
Severity: Minor
Found in Lexer/Scanner/FilterScanner.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 scan has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function scan(State $state)
    {
        $reader = $state->getReader();

        //Text block on tags etc. (p. some text|p!. some text)
Severity: Minor
Found in Lexer/Scanner/SubScanner.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 scan has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function scan(State $state)
    {
        $reader = $state->getReader();

        foreach ($state->scanToken(
Severity: Minor
Found in Lexer/Scanner/FilterScanner.php - About 1 hr to fix

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

        public function lex($input, $path = null)
        {
            $stateClassName = $this->getOption('lexer_state_class_name');
            $lexEvent = new LexEvent($input, $path, $stateClassName, [
                'encoding'                 => $this->getOption('encoding'),
    Severity: Minor
    Found in Lexer.php - About 1 hr to fix

      Function scan has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function scan(State $state)
          {
              $tokens = [];
      
              /** @var ImportToken $token */
      Severity: Minor
      Found in Lexer/Scanner/ImportScanner.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 getList has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getList()
          {
              return [
                  //TODO: Several of these are non-standard and need to be encapsulated into extensions
                  //Namely: ForScanner, DoScanner, VariableScanner
      Severity: Minor
      Found in Scanners.php - About 1 hr to fix

        Method scan has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function scan(State $state)
            {
                $reader = $state->getReader();
        
                if (!$reader->peekString('//')) {
        Severity: Minor
        Found in Lexer/Scanner/CommentScanner.php - About 1 hr to fix

          Method __construct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct(Lexer $lexer, $input, array $options)
              {
                  $this->lexer = $lexer;
                  $this->setOptionsRecursive([
                      'reader_class_name'        => Reader::class,
          Severity: Minor
          Found in Lexer/State.php - About 1 hr to fix

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

                public function scan(State $state)
                {
                    $keywords = $state->getOption('keyword_names');
            
                    if (count($keywords)) {
            Severity: Minor
            Found in Lexer/Scanner/KeywordScanner.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 scanInterpolationTokens has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                private function scanInterpolationTokens(State $state, &$firstToken)
                {
                    if (static::INTERPOLATION_ENABLED) {
                        foreach ($state->scan(InterpolationScanner::class) as $subToken) {
                            if ($firstToken) {
            Severity: Minor
            Found in Lexer/Scanner/TextScanner.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 getIndentLevel has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getIndentLevel(State $state, $maxLevel = INF, callable $getIndentChar = null)
                {
                    if ($maxLevel <= 0) {
                        return 0;
                    }
            Severity: Minor
            Found in Lexer/Scanner/IndentationScanner.php - About 1 hr to fix

              Function analyze has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function analyze($quitOnOutdent, array $breakChars = [])
                  {
                      $this->outdent = false;
                      $this->level = $this->state->getLevel();
                      $this->newLevel = $this->level;
              Severity: Minor
              Found in Lexer/Analyzer/LineAnalyzer.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 getIndentLevel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getIndentLevel(State $state, $maxLevel = INF, callable $getIndentChar = null)
                  {
                      if ($maxLevel <= 0) {
                          return 0;
                      }
              Severity: Minor
              Found in Lexer/Scanner/IndentationScanner.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 scan has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function scan(State $state)
                  {
                      foreach ($state->scanToken(
                          BlockToken::class,
                          'block(?:[\t ]+(?<mode>append|prepend|replace))?'.
              Severity: Minor
              Found in Lexer/Scanner/BlockScanner.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 scan has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function scan(State $state)
                  {
                      $reader = $state->getReader();
              
                      if (!$reader->peekChar('<')) {
              Severity: Minor
              Found in Lexer/Scanner/MarkupScanner.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 loopScan has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function loopScan($scanners, $required = false)
                  {
                      if ($this->reader->hasLength() && $this->scanners === null) {
                          $this->scanners = $this->filterScanners($scanners);
                      }
              Severity: Minor
              Found in Lexer/State.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 yieldLines has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function yieldLines(State $state, array $lines, LineAnalyzer $analyzer)
                  {
                      yield $state->createToken(IndentToken::class);
              
                      $maxIndent = $analyzer->getMaxIndent();
              Severity: Minor
              Found in Lexer/Scanner/MultilineScanner.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 scanParenthesesContent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function scanParenthesesContent(State $state, array $options)
                  {
                      $reader = $state->getReader();
              
                      while ($reader->hasLength()) {
              Severity: Minor
              Found in Lexer/Scanner/AttributeScanner.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 scan has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function scan($scanners, array $options = [])
                  {
                      $scanners = $this->filterScanners($scanners);
              
                      foreach ($scanners as $scanner) {
              Severity: Minor
              Found in Lexer/State.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

              Severity
              Category
              Status
              Source
              Language