bb-drummer/phpagstract

View on GitHub

Showing 75 of 75 total issues

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

<?php

namespace PHPagstract\Token\Tokens;

use PHPagstract\Token\MarkupTokenizer;
Severity: Major
Found in src/PHPagstract/Token/Tokens/DocType.php and 2 other locations - About 1 day to fix
src/PHPagstract/Token/Tokens/CData.php on lines 1..82
src/PHPagstract/Token/Tokens/Comment.php on lines 1..82

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

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

namespace PHPagstract\Token\Tokens;

use PHPagstract\Token\MarkupTokenizer;
Severity: Major
Found in src/PHPagstract/Token/Tokens/Comment.php and 2 other locations - About 1 day to fix
src/PHPagstract/Token/Tokens/CData.php on lines 1..82
src/PHPagstract/Token/Tokens/DocType.php on lines 1..82

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

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

namespace PHPagstract\Token\Tokens;

use PHPagstract\Token\MarkupTokenizer;
Severity: Major
Found in src/PHPagstract/Token/Tokens/CData.php and 2 other locations - About 1 day to fix
src/PHPagstract/Token/Tokens/Comment.php on lines 1..82
src/PHPagstract/Token/Tokens/DocType.php on lines 1..82

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

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

    private function getHTML401NamedToNumeric() 
    {
        return array(
            '&nbsp;'     => '&#160;',  // no-break space = non-breaking space, U+00A0 ISOnum
            '&iexcl;'    => '&#161;',  // inverted exclamation mark, U+00A1 ISOnum
Severity: Major
Found in src/PHPagstract/Symbol/Symbols/Tokens/PagstractSimpleValue.php - About 1 day to fix

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

        public function parse($html)
        {
            // Get token position.
            $positionArray = MarkupTokenizer::getPosition($html);
            $this->setLine($positionArray['line']);
    Severity: Major
    Found in src/PHPagstract/Token/Tokens/Text.php and 1 other location - About 1 day to fix
    src/PHPagstract/Token/Tokens/Pagstract/PagstractPropertyReferenceText.php on lines 51..88

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

    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

        public function parse($html)
        {
            // Get token position.
            $positionArray = PropertyReferenceTokenizer::getPosition($html);
            $this->setLine($positionArray['line']);
    src/PHPagstract/Token/Tokens/Text.php on lines 39..76

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

    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

    File theme.main.js has 516 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    (function($) {
        /**
         *
         * K15t Help Theme
         * Main Javascript
    Severity: Major
    Found in docs/freiheit/assets/js/theme.main.js - About 1 day to fix

      Function toString has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

          public function toString() 
          {   
              
              $attr = ($this->getAttributes());
              
      Severity: Minor
      Found in src/PHPagstract/Symbol/Symbols/Tokens/PagstractList.php - About 7 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 toString has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function toString() 
          {
              $EOL = $this->config()->EOL();
              $attr = ($this->getAttributes());
              
      Severity: Minor
      Found in src/PHPagstract/Symbol/Symbols/Tokens/Doctype.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

      File Element.php has 312 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace PHPagstract\Token\Tokens;
      
      use PHPagstract\Token\MarkupTokenizer;
      Severity: Minor
      Found in src/PHPagstract/Token/Tokens/Element.php - About 3 hrs to fix

        Function findThemePaths has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function findThemePaths($themeId, $result = []) 
            {
                $themesDir = $this->getThemesDir();
                $paths = scandir($themesDir);
                
        Severity: Minor
        Found in src/PHPagstract/Page/Resolver/FilepathResolver.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 setDataStream has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function setDataStream($dataStream) 
            {
                // make sure, we will handle an object
                if (empty($dataStream)) {
                    // create generic data object
        Severity: Minor
        Found in src/PHPagstract/Page/PageAbstract.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

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

            public function toString() 
            {
                $EOL = $this->config()->EOL();
                $attr = ($this->getAttributes());
                $property = null;
        Severity: Major
        Found in src/PHPagstract/Symbol/Symbols/Tokens/PagstractRendered.php and 1 other location - About 3 hrs to fix
        src/PHPagstract/Symbol/Symbols/Tokens/PagstractSimpleValue.php on lines 30..72

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

        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

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

            public function toString() 
            {
                $EOL = $this->config()->EOL();
                $attr = ($this->getAttributes());
                $property = null;
        src/PHPagstract/Symbol/Symbols/Tokens/PagstractRendered.php on lines 30..52

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

        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

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

                    if ($value == '') {
                        $remainingHtml = ltrim(mb_substr(ltrim($html), mb_strlen($name) + 3));
                    } else {
                        $remainingHtml = ltrim($html);
        
        
        src/PHPagstract/Token/Tokens/Element.php on lines 248..262

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

        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

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

                    if ($value == '') {
                        $remainingHtml = ltrim(mb_substr(ltrim($html), mb_strlen($name) + 3));
                    } else {
                        $remainingHtml = ltrim($html);
        
        
        Severity: Major
        Found in src/PHPagstract/Token/Tokens/Element.php and 1 other location - About 3 hrs to fix
        src/PHPagstract/Token/Tokens/Pagstract/PagstractAbstractToken.php on lines 308..322

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

        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

        File PagstractAbstractToken.php has 290 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Pagstract token abstract class
         */
        namespace PHPagstract\Token\Tokens;
        Severity: Minor
        Found in src/PHPagstract/Token/Tokens/Pagstract/PagstractAbstractToken.php - About 2 hrs to fix

          File PagstractSimpleValue.php has 284 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * PHPagstract simple value reference token symbol class
           */
          namespace PHPagstract\Symbol\Symbols\Tokens;
          Severity: Minor
          Found in src/PHPagstract/Symbol/Symbols/Tokens/PagstractSimpleValue.php - About 2 hrs to fix

            Method toString has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function toString() 
                {   
                    
                    $attr = ($this->getAttributes());
                    
            Severity: Major
            Found in src/PHPagstract/Symbol/Symbols/Tokens/PagstractList.php - About 2 hrs to fix

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

                  public static function buildFromHtml($html, Token $parent = null, $throwOnError = false)
                  {
                      $matchCriteria = self::getMatchings();
                      foreach ($matchCriteria as $className => $regex) {
                          if (preg_match($regex["start"], $html) === 1) {
              Severity: Minor
              Found in src/PHPagstract/Token/Tokens/TokenFactory.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

              Severity
              Category
              Status
              Source
              Language