finally-a-fast/faftephp

View on GitHub

Showing 149 of 149 total issues

File Parser.php has 1135 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Faf\TemplateEngine;
Severity: Major
Found in src/Parser.php - About 2 days to fix

    Function prepareNode has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function prepareNode(
            DOMXPath $xPath,
            HTML5DOMElement $domNode,
            ParserElement $parserElement,
            string $currentTagName
    Severity: Minor
    Found in src/Parser.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

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

    <?php
    
    declare(strict_types=1);
    
    namespace Faf\TemplateEngine\Elements;
    Severity: Major
    Found in src/Elements/FormatAsDatetime.php and 1 other location - About 1 day to fix
    src/Elements/FormatAsTime.php on lines 1..111

    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 349.

    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 Faf\TemplateEngine\Elements;
    Severity: Major
    Found in src/Elements/FormatAsTime.php and 1 other location - About 1 day to fix
    src/Elements/FormatAsDatetime.php on lines 1..111

    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 349.

    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

    Parser has 53 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Parser extends BaseObject
    {
        public const ROOT = 'root';
    
        public const MODE_PROD = 0;
    Severity: Major
    Found in src/Parser.php - About 7 hrs to fix

      Method prepareNode has 171 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function prepareNode(
              DOMXPath $xPath,
              HTML5DOMElement $domNode,
              ParserElement $parserElement,
              string $currentTagName
      Severity: Major
      Found in src/Parser.php - About 6 hrs to fix

        Function loadAllowedChildElements has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function loadAllowedChildElements(): array
            {
                $debugId = $this->debugStart('Load allowed child elements');
                $key = 'fafte-allowed-child-elements-' . md5(implode('', array_keys($this->parserElements)));
                $allowedChildElements = null;
        Severity: Minor
        Found in src/Parser.php - About 6 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 parseElements has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

            public function parseElements(string $string, string $currentTagName, bool $rawData = false)
            {
                $parentLanguage = $this->currentLanguage;
                $this->currentLanguage = $this->getLanguage();
        
        
        Severity: Minor
        Found in src/Parser.php - About 6 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

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

        <?php
        
        declare(strict_types=1);
        
        namespace Faf\TemplateEngine\Elements;
        Severity: Major
        Found in src/Elements/ConditionalStatementConditionFalse.php and 1 other location - About 4 hrs to fix
        src/Elements/ConditionalStatementConditionTrue.php on lines 1..86

        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 182.

        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 Faf\TemplateEngine\Elements;
        Severity: Major
        Found in src/Elements/ConditionalStatementConditionTrue.php and 1 other location - About 4 hrs to fix
        src/Elements/ConditionalStatementConditionFalse.php on lines 1..86

        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 182.

        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 parseElements has 100 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function parseElements(string $string, string $currentTagName, bool $rawData = false)
            {
                $parentLanguage = $this->currentLanguage;
                $this->currentLanguage = $this->getLanguage();
        
        
        Severity: Major
        Found in src/Parser.php - About 4 hrs to fix

          The class Parser has 11 public methods. Consider refactoring Parser to keep number of public methods under 10.
          Open

          class Parser extends BaseObject
          {
              public const ROOT = 'root';
          
              public const MODE_PROD = 0;
          Severity: Minor
          Found in src/Parser.php by phpmd

          TooManyPublicMethods

          Since: 0.1

          A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

          By default it ignores methods starting with 'get' or 'set'.

          Example

          Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

          The class Parser has an overall complexity of 212 which is very high. The configured complexity threshold is 50.
          Open

          class Parser extends BaseObject
          {
              public const ROOT = 'root';
          
              public const MODE_PROD = 0;
          Severity: Minor
          Found in src/Parser.php by phpmd

          Function htmlTag has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              public function htmlTag(
                  string $name,
                  string $content = '',
                  ?array $options = [],
                  string $attributePrefix = ''
          Severity: Minor
          Found in src/Parser.php - About 3 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 getValue has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function &getValue(&$data, string $path, bool $callLastClosure = true)
              {
                  static::checkForClosure($data);
          
                  $workData = $data;
          Severity: Minor
          Found in src/Parser.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

          ElementSetting has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ElementSetting extends BaseObject
          {
              /**
               * @var string
               */
          Severity: Minor
          Found in src/Helpers/ElementSetting.php - About 2 hrs to fix

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

            <?php
            
            declare(strict_types=1);
            
            namespace Faf\TemplateEngine\Elements;
            Severity: Major
            Found in src/Elements/StrToUpper.php and 1 other location - About 2 hrs to fix
            src/Elements/StrToLower.php on lines 1..64

            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 133.

            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 Faf\TemplateEngine\Elements;
            Severity: Major
            Found in src/Elements/StrToLower.php and 1 other location - About 2 hrs to fix
            src/Elements/StrToUpper.php on lines 1..63

            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 133.

            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

            ParserElement has 23 functions (exceeds 20 allowed). Consider refactoring.
            Open

            abstract class ParserElement extends BaseObject
            {
                use TagTrait;
            
                /**
            Severity: Minor
            Found in src/Helpers/ParserElement.php - About 2 hrs to fix

              Method elementSettings has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function elementSettings(): array
                  {
                      return [
                          new ElementSetting([
                              'name' => 'datetime',
              Severity: Major
              Found in src/Elements/TimeTag.php - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language