phug-php/phug

View on GitHub
src/Phug/Formatter/Formatter/AbstractFormat.php

Summary

Maintainability
F
4 days
Test Coverage
A
100%

File AbstractFormat.php has 806 lines of code (exceeds 400 allowed). Consider refactoring.
Open

<?php

namespace Phug\Formatter;

use Phug\Formatter;
Severity: Major
Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 day to fix

    Method formatMixinCallElement has 117 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function formatMixinCallElement(MixinCallElement $mixinCall)
        {
            $hasBlock = $mixinCall->hasChildren();
            $children = new PhpUnwrap($this->formatElementChildren($mixinCall), $this->formatter);
            $mixinName = $mixinCall->getName();
    Severity: Major
    Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 4 hrs to fix

      AbstractFormat has 40 functions (exceeds 30 allowed). Consider refactoring.
      Open

      abstract class AbstractFormat implements FormatInterface, OptionInterface
      {
          use HandleVariable;
          use OptionTrait;
          use PatternTrait;
      Severity: Minor
      Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 3 hrs to fix

        Method formatMixinElement has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function formatMixinElement(MixinElement $mixin)
            {
                $mixinName = $mixin->getName();
                $name = is_string($mixinName)
                    ? var_export($mixinName, true)
        Severity: Major
        Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 3 hrs to fix

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

              public function __construct(Formatter $formatter = null)
              {
                  $patterns = [
                      'class_attribute'        => static::CLASS_ATTRIBUTE,
                      'string_attribute'       => static::STRING_ATTRIBUTE,
          Severity: Major
          Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 2 hrs to fix

            Function handleTokens has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
            Open

                protected function handleTokens($code, $checked)
                {
                    $phpTokenHandler = $this->getOption('php_token_handlers');
                    $untouched = false;
            
            
            Severity: Minor
            Found in src/Phug/Formatter/Formatter/AbstractFormat.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 handleTokens has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function handleTokens($code, $checked)
                {
                    $phpTokenHandler = $this->getOption('php_token_handlers');
                    $untouched = false;
            
            
            Severity: Minor
            Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

              Method setFormatter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function setFormatter(Formatter $formatter)
                  {
                      $this->formatter = $formatter;
                      $format = $this;
              
              
              Severity: Minor
              Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

                Method formatElementChildren has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function formatElementChildren(ElementInterface $element, $indentStep = 1)
                    {
                        $indentLevel = $this->formatter->getLevel();
                        $this->formatter->setLevel($indentLevel + $indentStep);
                        $content = '';
                Severity: Minor
                Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

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

                      protected function formatKeywordElement(KeywordElement $element)
                      {
                          $name = $element->getName();
                          $keyword = $this->getOption(['keywords', $name]);
                          $result = call_user_func($keyword, $element->getValue(), $element, $name);
                  Severity: Minor
                  Found in src/Phug/Formatter/Formatter/AbstractFormat.php - About 1 hr to fix

                    Function formatMixinCallElement has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
                    Open

                        protected function formatMixinCallElement(MixinCallElement $mixinCall)
                        {
                            $hasBlock = $mixinCall->hasChildren();
                            $children = new PhpUnwrap($this->formatElementChildren($mixinCall), $this->formatter);
                            $mixinName = $mixinCall->getName();
                    Severity: Minor
                    Found in src/Phug/Formatter/Formatter/AbstractFormat.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 formatElementChildren has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
                    Open

                        protected function formatElementChildren(ElementInterface $element, $indentStep = 1)
                        {
                            $indentLevel = $this->formatter->getLevel();
                            $this->formatter->setLevel($indentLevel + $indentStep);
                            $content = '';
                    Severity: Minor
                    Found in src/Phug/Formatter/Formatter/AbstractFormat.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 formatExpressionElement has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
                    Open

                        protected function formatExpressionElement(ExpressionElement $code)
                        {
                            $value = $this->formatCode($code->getValue(), $code->isChecked(), !$code->isTransformationAllowed());
                    
                            if ($code->hasStaticValue()) {
                    Severity: Minor
                    Found in src/Phug/Formatter/Formatter/AbstractFormat.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

                    There are no issues that match your filters.

                    Category
                    Status