phug-php/formatter

View on GitHub

Showing 48 of 48 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

    File XmlFormat.php has 448 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Phug\Formatter\Format;
    
    use Closure;
    Severity: Minor
    Found in Formatter/Format/XmlFormat.php - About 6 hrs 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

          File Formatter.php has 342 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace Phug;
          
          // Elements
          Severity: Minor
          Found in Formatter.php - About 4 hrs to fix

            Function getSourceLine has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getSourceLine($error)
                {
                    $previous = null;
                    $line = null;
            
            
            Severity: Minor
            Found in Formatter.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

            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

                Formatter has 25 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Formatter implements ModuleContainerInterface
                {
                    use LevelTrait;
                    use ModuleContainerTrait;
                
                
                Severity: Minor
                Found in Formatter.php - About 2 hrs to fix

                  Method yieldAssignmentElement has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function yieldAssignmentElement(AssignmentElement $element)
                      {
                          foreach ($this->getOption('assignment_handlers') as $handler) {
                              $iterator = $handler($element) ?: [];
                  
                  
                  Severity: Major
                  Found in Formatter/Format/XmlFormat.php - About 2 hrs to fix

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

                    class XmlFormat extends AbstractFormat
                    {
                        use AssignmentHelpersTrait;
                    
                        const DOCTYPE = '<?xml version="1.0" encoding="utf-8" ?>';
                    Severity: Minor
                    Found in Formatter/Format/XmlFormat.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

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

                          public function __construct(Formatter $formatter = null)
                          {
                              $this->setOptionsRecursive([
                                  'white_space_sensitive_tags' => [
                                      'pre',
                      Severity: Major
                      Found in Formatter/Format/XhtmlFormat.php - About 2 hrs to fix

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

                            protected function formatAttributeElement(AttributeElement $element)
                            {
                                $value = $element->getValue();
                                $name = $element->getName();
                                $nonEmptyAttribute = ($name === 'class' || $name === 'id');
                        Severity: Minor
                        Found in Formatter/Format/XmlFormat.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 isInExclusionContext has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function isInExclusionContext(&$tokens, $index)
                            {
                                foreach ([
                                    // Exclude tokens before the variables
                                    -1 => [
                        Severity: Major
                        Found in Formatter/Partial/HandleVariable.php - About 2 hrs to fix

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

                              public function __construct($options = null)
                              {
                                  $this->initFormats()->setOptionsDefaults($options ?: [], [
                                      'debug'                        => false,
                                      'located_exception_class_name' => LocatedException::class,
                          Severity: Major
                          Found in Formatter.php - About 2 hrs to fix

                            Method formatAttributeElement has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function formatAttributeElement(AttributeElement $element)
                                {
                                    $value = $element->getValue();
                                    $name = $element->getName();
                                    $nonEmptyAttribute = ($name === 'class' || $name === 'id');
                            Severity: Minor
                            Found in Formatter/Format/XmlFormat.php - About 1 hr to fix

                              Method getSourceLine has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function getSourceLine($error)
                                  {
                                      $previous = null;
                                      $line = null;
                              
                              
                              Severity: Minor
                              Found in Formatter.php - About 1 hr 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 hasNonStaticAttributes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function hasNonStaticAttributes(MarkupInterface $element)
                                      {
                                          if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
                                              foreach ($element->getAttributes() as $attribute) {
                                                  if ($attribute->hasStaticMember('value')) {
                                  Severity: Minor
                                  Found in Formatter/Format/XmlFormat.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language