phug-php/formatter

View on GitHub
Formatter/AbstractFormat.php

Summary

Maintainability
F
5 days
Test Coverage

Showing 15 of 15 total issues

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

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

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

    abstract class AbstractFormat implements FormatInterface, OptionInterface
    {
    use HandleVariable;
    use OptionTrait;
    use PatternTrait;
    Severity: Minor
    Found in Formatter/AbstractFormat.php - About 5 hrs 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 Formatter/AbstractFormat.php - About 4 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 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 Formatter/AbstractFormat.php - About 2 hrs to fix

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

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

            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 Formatter/AbstractFormat.php - About 1 hr to fix

              Function formatMixinCallElement has a Cognitive Complexity of 12 (exceeds 5 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 Formatter/AbstractFormat.php - About 1 hr to fix

              Function formatElementChildren has a Cognitive Complexity of 12 (exceeds 5 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 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 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 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 Formatter/AbstractFormat.php - About 1 hr to fix

                    Function formatExpressionElement has a Cognitive Complexity of 9 (exceeds 5 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 Formatter/AbstractFormat.php - About 55 mins to fix

                    Function __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    public function __construct(?Formatter $formatter = null)
                    {
                    $patterns = [
                    'class_attribute' => static::CLASS_ATTRIBUTE,
                    'string_attribute' => static::STRING_ATTRIBUTE,
                    Severity: Minor
                    Found in Formatter/AbstractFormat.php - About 35 mins to fix

                    Function formatDynamicValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    protected function formatDynamicValue($formattedName, $value)
                    {
                    if ($value instanceof ExpressionElement &&
                    strtolower($value->getValue()) === 'undefined'
                    ) {
                    Severity: Minor
                    Found in Formatter/AbstractFormat.php - About 25 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status