phug-php/formatter

View on GitHub

Showing 48 of 48 total issues

Function isInExclusionContext has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function isInExclusionContext(&$tokens, $index)
    {
        foreach ([
            // Exclude tokens before the variables
            -1 => [
Severity: Minor
Found in Formatter/Partial/HandleVariable.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

Method provideAttributesAssignment has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function provideAttributesAssignment()
    {
        return $this
            ->registerHelper(
                'attributes_mapping',
Severity: Minor
Found in Formatter/Partial/AssignmentHelpersTrait.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

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

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

        Function isBlockTag has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function isBlockTag(MarkupInterface $element)
            {
                if ($element->belongsTo($this->getOption('inline_tags'))) {
                    return false;
                }
        Severity: Minor
        Found in Formatter/Format/XhtmlFormat.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 yieldAssignmentElement has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function yieldAssignmentElement(AssignmentElement $element)
            {
                foreach ($this->getOption('assignment_handlers') as $handler) {
                    $iterator = $handler($element) ?: [];
        
        
        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

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

            public function __construct(Formatter $formatter = null)
            {
                parent::__construct($formatter);
        
                $this
        Severity: Minor
        Found in Formatter/Format/XmlFormat.php - About 1 hr to fix

          Method getDebugError has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getDebugError($error, $code, $path = null)
              {
                  /** @var \Throwable $error */
                  $line = $this->getSourceLine($error);
                  if ($line === false) {
          Severity: Minor
          Found in Formatter.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 isInFunctionParams has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function isInFunctionParams(&$tokens, $index)
                  {
                      $afterOpen = false;
                      for ($i = $index - 1; $i >= 0; $i--) {
                          if (in_array($tokens[$i], [')', '}'], true)) {
              Severity: Minor
              Found in Formatter/Partial/HandleVariable.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

              Consider simplifying this complex logical expression.
              Open

                      if (!$checked ||
                          $this->isInExclusionContext($tokens, $index) ||
                          $this->isInFunctionParams($tokens, $index) ||
                          $this->isInKeywordParams($tokens, $index) ||
                          $this->isInComplexInterpolation($tokens, $index) ||
              Severity: Major
              Found in Formatter/Partial/HandleVariable.php - About 1 hr to fix

                Function hasDuplicateAttributeNames has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function hasDuplicateAttributeNames(MarkupInterface $element)
                    {
                        if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
                            $names = [];
                            foreach ($element->getAttributes() as $attribute) {
                Severity: Minor
                Found in Formatter/Format/XmlFormat.php - About 55 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

                Function formatAttributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function formatAttributes(MarkupElement $element)
                    {
                        if ($this->hasNonStaticAttributes($element) ||
                            $this->hasDuplicateAttributeNames($element)) {
                            $empty = true;
                Severity: Minor
                Found in Formatter/Format/XmlFormat.php - About 55 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

                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

                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 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        $name,
                        $autoClosed = false,
                        SplObjectStorage $attributes = null,
                        ParserNode $originNode = null,
                        NodeInterface $parent = null,
                Severity: Minor
                Found in Formatter/Element/MarkupElement.php - About 45 mins to fix

                  Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          $name,
                          SplObjectStorage $attributes = null,
                          AssignmentContainerInterface $container = null,
                          ParserNode $originNode = null,
                          NodeInterface $parent = null,
                  Severity: Minor
                  Found in Formatter/Element/AssignmentElement.php - About 45 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if ($nonEmptyAttribute && (
                                !$value ||
                                ($value instanceof TextElement && ((string) $value->getValue()) === '') ||
                                (is_string($value) && in_array(trim($value), ['', '""', "''"], true))
                            )) {
                    Severity: Major
                    Found in Formatter/Format/XmlFormat.php - About 40 mins to fix

                      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              $name,
                              $value,
                              ParserNode $originNode = null,
                              NodeInterface $parent = null,
                              array $children = null
                      Severity: Minor
                      Found in Formatter/Element/AttributeElement.php - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language