phug-php/phug

View on GitHub

Showing 113 of 115 total issues

Function __call has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

    public function __call($method, $parameters)
    {
        if ($this instanceof OptionInterface && $this->hasOption('macros')) {
            $macros = $this->getOption('macros') ?: [];
            if (isset($macros[$method])) {
Severity: Minor
Found in src/Phug/Util/Util/Partial/MacroableTrait.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

Function isExpired has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

    public function isExpired($file, &$cachePath = null)
    {
        if (isset($this->options['up_to_date_check']) && !$this->options['up_to_date_check']) {
            if (func_num_args() > 1) {
                $cachePath = $this->getRegistryPath($file);
Severity: Minor
Found in src/Phug/Phug/Phug/Optimizer.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

Function loopScan has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

    public function loopScan($scanners, $required = false)
    {
        if ($this->reader->hasLength() && $this->scanners === null) {
            $this->scanners = $this->filterScanners($scanners);
        }
Severity: Minor
Found in src/Phug/Lexer/Lexer/State.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

Function analyze has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

    public function analyze($quitOnOutdent, array $breakChars = [])
    {
        $this->outdent = false;
        $this->level = $this->state->getLevel();
        $this->newLevel = $this->level;
Severity: Minor
Found in src/Phug/Lexer/Lexer/Analyzer/LineAnalyzer.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

Function getIndentLevel has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

    public function getIndentLevel(State $state, $maxLevel = INF, callable $getIndentChar = null)
    {
        if ($maxLevel <= 0) {
            return 0;
        }
Severity: Minor
Found in src/Phug/Lexer/Lexer/Scanner/IndentationScanner.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

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

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

Avoid too many return statements within this method.
Open

        return false;
Severity: Major
Found in src/Phug/Formatter/Formatter.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return $this->pattern(
                'attribute_pattern',
                $this->format($name),
                $this->format($value)
            );
    Severity: Major
    Found in src/Phug/Formatter/Formatter/Format/XmlFormat.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return $this->cache[$cacheKey];
      Severity: Major
      Found in src/Phug/DependencyInjection/DependencyInjection.php - About 30 mins to fix

        Function scan has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            public function scan($scanners, array $options = [])
            {
                $scanners = $this->filterScanners($scanners);
        
                foreach ($scanners as $scanner) {
        Severity: Minor
        Found in src/Phug/Lexer/Lexer/State.php - About 25 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 scanParenthesesContent has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            private function scanParenthesesContent(State $state, array $options)
            {
                $reader = $state->getReader();
        
                while ($reader->hasLength()) {
        Severity: Minor
        Found in src/Phug/Lexer/Lexer/Scanner/AttributeScanner.php - About 25 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 getUnescapedLines has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            protected function getUnescapedLines(State $state, $lines)
            {
                $buffer = '';
                $interpolationLevel = 0;
        
        
        Severity: Minor
        Found in src/Phug/Lexer/Lexer/Scanner/MultilineScanner.php - About 25 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 getUnescapedLineValue has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            protected function getUnescapedLineValue(State $state, $value, &$interpolationLevel, &$buffer)
            {
                if (is_string($value)) {
                    if ($interpolationLevel) {
                        yield $this->unEscapedToken($state, $value);
        Severity: Minor
        Found in src/Phug/Lexer/Lexer/Scanner/MultilineScanner.php - About 25 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

        Severity
        Category
        Status
        Source
        Language