krixon/rules

View on GitHub

Showing 33 of 42 total issues

ComparisonNode has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class ComparisonNode implements Node
{
    private $identifier;
    private $operator;
    private $value;
Severity: Minor
Found in src/Ast/ComparisonNode.php - About 4 hrs to fix

    Function isSatisfiedBy has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function isSatisfiedBy($value) : bool
        {
            if (empty($this->children)) {
                return false;
            }
    Severity: Minor
    Found in src/Specification/Composite.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 parseComparisonExpression has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function parseComparisonExpression() : Ast\Node
        {
            $left    = $this->parseIdentifier();
            $negated = false;
    
    
    Severity: Minor
    Found in src/Parser/DefaultParser.php - About 1 hr to fix

      Function parseComparisonExpression has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          private function parseComparisonExpression() : Ast\Node
          {
              $left    = $this->parseIdentifier();
              $negated = false;
      
      
      Severity: Minor
      Found in src/Parser/DefaultParser.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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace Krixon\Rules\Specification;
      Severity: Major
      Found in src/Specification/ContainsGenerator.php and 2 other locations - About 1 hr to fix
      src/Specification/DateMatchesGenerator.php on lines 1..38
      src/Specification/NumberMatchesGenerator.php on lines 1..38

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 115.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace Krixon\Rules\Specification;
      Severity: Major
      Found in src/Specification/NumberMatchesGenerator.php and 2 other locations - About 1 hr to fix
      src/Specification/ContainsGenerator.php on lines 1..38
      src/Specification/DateMatchesGenerator.php on lines 1..38

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 115.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace Krixon\Rules\Specification;
      Severity: Major
      Found in src/Specification/DateMatchesGenerator.php and 2 other locations - About 1 hr to fix
      src/Specification/ContainsGenerator.php on lines 1..38
      src/Specification/NumberMatchesGenerator.php on lines 1..38

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 115.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          private function next() : void
          {
              $char = $this->advance();
      
              switch ($char) {
      Severity: Minor
      Found in src/Lexer/Lexer.php - About 1 hr to fix

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

            public function visitLogical(LogicalNode $node) : void
            {
                $left  = $node->left();
                $right = $node->right();
        
        
        Severity: Minor
        Found in src/Ast/Writer.php - About 1 hr to fix

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

              private function parseLiteralList() : Ast\LiteralNodeList
              {
                  $this->match(Token::LEFT_BRACKET);
          
                  $this->next();
          Severity: Minor
          Found in src/Parser/DefaultParser.php - About 1 hr to fix

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

                public function visitComparison(ComparisonNode $node) : void
                {
                    $node->identifier()->accept($this);
            
                    $negated = $this->negating;
            Severity: Minor
            Found in src/Ast/Writer.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 visitComparison has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function visitComparison(ComparisonNode $node) : void
                {
                    $node->identifier()->accept($this);
            
                    $negated = $this->negating;
            Severity: Minor
            Found in src/Ast/Writer.php - About 1 hr to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              <?php
              
              declare(strict_types=1);
              
              namespace Krixon\Rules\Specification;
              Severity: Minor
              Found in src/Specification/TimezoneMatchesGenerator.php and 1 other location - About 55 mins to fix
              src/Specification/StringMatchesGenerator.php on lines 1..34

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 99.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              <?php
              
              declare(strict_types=1);
              
              namespace Krixon\Rules\Specification;
              Severity: Minor
              Found in src/Specification/StringMatchesGenerator.php and 1 other location - About 55 mins to fix
              src/Specification/TimezoneMatchesGenerator.php on lines 1..35

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 99.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                  public function visitLogical(Ast\LogicalNode $node) : void
                  {
                      $node->right()->accept($this);
                      $node->left()->accept($this);
              
              
              Severity: Minor
              Found in src/Compiler/BaseCompiler.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 blockComment has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function blockComment() : void
                  {
                      /* This kind of comment continues until it is closed. It can also be nested. */
                      $balance = 1;
              
              
              Severity: Minor
              Found in src/Lexer/Lexer.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 string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function string()
                  {
                      $buffer = '';
              
                      while ($this->peek() !== '"' && !$this->eof()) {
              Severity: Minor
              Found in src/Lexer/Lexer.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 isSatisfiedBy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function isSatisfiedBy($value) : bool
                  {
                      if (empty($this->candidates)) {
                          return false;
                      }
              Severity: Minor
              Found in src/Specification/Contains.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 parseLiteralList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function parseLiteralList() : Ast\LiteralNodeList
                  {
                      $this->match(Token::LEFT_BRACKET);
              
                      $this->next();
              Severity: Minor
              Found in src/Parser/DefaultParser.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 new TimezoneMatches($candidate);
              Severity: Major
              Found in src/Specification/Contains.php - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language