XaBerr/JUICE

View on GitHub
JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php

Summary

Maintainability
F
1 wk
Test Coverage

File Parsedown.php has 1193 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Parsedown;
#
#
# Parsedown
Severity: Major
Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 3 days to fix

    Function lines has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function lines(array $lines)
        {
            $CurrentBlock = null;
    
            foreach ($lines as $line)
    Severity: Minor
    Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 1 day 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

    Parsedown has 46 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Parsedown
    {
        # ~
    
        const version = '1.6.0';
    Severity: Minor
    Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 6 hrs to fix

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

          protected function lines(array $lines)
          {
              $CurrentBlock = null;
      
              foreach ($lines as $line)
      Severity: Major
      Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 4 hrs to fix

        The class Parsedown has 41 non-getter- and setter-methods. Consider refactoring Parsedown to keep number of methods under 25.
        Open

        class Parsedown
        {
            # ~
        
            const version = '1.6.0';

        TooManyMethods

        Since: 0.1

        A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        The default was changed from 10 to 25 in PHPMD 2.3.

        Example

        Source https://phpmd.org/rules/codesize.html#toomanymethods

        The class Parsedown has an overall complexity of 204 which is very high. The configured complexity threshold is 50.
        Open

        class Parsedown
        {
            # ~
        
            const version = '1.6.0';

        Method blockTable has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function blockTable($Line, array $Block = null)
            {
                if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
                {
                    return;
        Severity: Major
        Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 3 hrs to fix

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

              protected function blockTable($Line, array $Block = null)
              {
                  if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
                  {
                      return;
          Severity: Minor
          Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.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 inlineLink has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function inlineLink($Excerpt)
              {
                  $Element = array(
                      'name' => 'a',
                      'handler' => 'line',
          Severity: Major
          Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 2 hrs to fix

            Function blockMarkup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function blockMarkup($Line)
                {
                    if ($this->markupEscaped)
                    {
                        return;
            Severity: Minor
            Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.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

            Function line has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                public function line($text)
                {
                    $markup = '';
            
                    # $excerpt is based on the first occurrence of a marker
            Severity: Minor
            Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.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 line has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function line($text)
                {
                    $markup = '';
            
                    # $excerpt is based on the first occurrence of a marker
            Severity: Minor
            Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 1 hr to fix

              Method blockMarkup has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function blockMarkup($Line)
                  {
                      if ($this->markupEscaped)
                      {
                          return;
              Severity: Minor
              Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 1 hr to fix

                Method blockListContinue has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function blockListContinue($Line, array $Block)
                    {
                        if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
                        {
                            if (isset($Block['interrupted']))
                Severity: Minor
                Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 1 hr to fix

                  Function element has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function element(array $Element)
                      {
                          $markup = '<'.$Element['name'];
                  
                          if (isset($Element['attributes']))
                  Severity: Minor
                  Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.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 blockTableContinue has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function blockTableContinue($Line, array $Block)
                      {
                          if (isset($Block['interrupted']))
                          {
                              return;
                  Severity: Minor
                  Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 1 hr to fix

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

                        protected function inlineLink($Excerpt)
                        {
                            $Element = array(
                                'name' => 'a',
                                'handler' => 'line',
                    Severity: Minor
                    Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.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 element has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function element(array $Element)
                        {
                            $markup = '<'.$Element['name'];
                    
                            if (isset($Element['attributes']))
                    Severity: Minor
                    Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 1 hr to fix

                      Method blockMarkupContinue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function blockMarkupContinue($Line, array $Block)
                          {
                              if (isset($Block['closed']))
                              {
                                  return;
                      Severity: Minor
                      Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.php - About 1 hr to fix

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

                            protected function blockTableContinue($Line, array $Block)
                            {
                                if (isset($Block['interrupted']))
                                {
                                    return;
                        Severity: Minor
                        Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.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 blockMarkupContinue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function blockMarkupContinue($Line, array $Block)
                            {
                                if (isset($Block['closed']))
                                {
                                    return;
                        Severity: Minor
                        Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.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 blockListContinue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function blockListContinue($Line, array $Block)
                            {
                                if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
                                {
                                    if (isset($Block['interrupted']))
                        Severity: Minor
                        Found in JATE/dist/jate/modules/ExternalModules/Parsedown/Parsedown.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

                        The class Parsedown has 1523 lines of code. Current threshold is 1000. Avoid really long classes.
                        Open

                        class Parsedown
                        {
                            # ~
                        
                            const version = '1.6.0';

                        The method lines() has an NPath complexity of 233295. The configured NPath complexity threshold is 200.
                        Open

                            protected function lines(array $lines)
                            {
                                $CurrentBlock = null;
                        
                                foreach ($lines as $line)

                        NPathComplexity

                        Since: 0.1

                        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                        Example

                        class Foo {
                            function bar() {
                                // lots of complicated code
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#npathcomplexity

                        The method lines() has 162 lines of code. Current threshold is set to 100. Avoid really long methods.
                        Open

                            protected function lines(array $lines)
                            {
                                $CurrentBlock = null;
                        
                                foreach ($lines as $line)

                        The method blockTable() has 106 lines of code. Current threshold is set to 100. Avoid really long methods.
                        Open

                            protected function blockTable($Line, array $Block = null)
                            {
                                if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
                                {
                                    return;

                        The method blockTable() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                        Open

                            protected function blockTable($Line, array $Block = null)
                            {
                                if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
                                {
                                    return;

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method lines() has a Cyclomatic Complexity of 26. The configured cyclomatic complexity threshold is 10.
                        Open

                            protected function lines(array $lines)
                            {
                                $CurrentBlock = null;
                        
                                foreach ($lines as $line)

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method blockMarkup() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                        Open

                            protected function blockMarkup($Line)
                            {
                                if ($this->markupEscaped)
                                {
                                    return;

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method inlineEmphasis uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                {
                                    return;
                                }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method lines uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    {
                                        $Blocks []= $CurrentBlock;
                        
                                        $CurrentBlock = $this->paragraph($Line);
                        
                        

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method lines uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                        {
                                            if ($this->isBlockCompletable($CurrentBlock['type']))
                                            {
                                                $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
                                            }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method inlineLink uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    {
                                        $definition = strtolower($Element['text']);
                                    }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method element uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    {
                                        $markup .= $Element['text'];
                                    }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method blockMarkup uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    {
                                        if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
                                        {
                                            return;
                                        }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method inlineLink uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                {
                                    return;
                                }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method blockMarkupContinue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    {
                                        $Block['closed'] = true;
                                    }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method inlineLink uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                {
                                    if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
                                    {
                                        $definition = strlen($matches[1]) ? $matches[1] : $Element['text'];
                                        $definition = strtolower($definition);

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method unmarkedText uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                {
                                    $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $text);
                                    $text = str_replace(" \n", "\n", $text);
                                }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method element uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                {
                                    $markup .= ' />';
                                }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        Avoid unused local variables such as '$matches'.
                        Open

                                if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close

                        UnusedLocalVariable

                        Since: 0.2

                        Detects when a local variable is declared and/or assigned, but not used.

                        Example

                        class Foo {
                            public function doSomething()
                            {
                                $i = 5; // Unused
                            }
                        }

                        Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

                        Avoid using short method names like Parsedown::li(). The configured minimum method name length is 3.
                        Open

                            protected function li($lines)
                            {
                                $markup = $this->lines($lines);
                        
                                $trimmedMarkup = trim($markup);

                        ShortMethodName

                        Since: 0.2

                        Detects when very short method names are used.

                        Example

                        class ShortMethod {
                            public function a( $index ) { // Violation
                            }
                        }

                        Source https://phpmd.org/rules/naming.html#shortmethodname

                        Avoid variables with short names like $id. Configured minimum length is 3.
                        Open

                                    $id = strtolower($matches[1]);

                        ShortVariable

                        Since: 0.2

                        Detects when a field, local, or parameter has a very short name.

                        Example

                        class Something {
                            private $q = 15; // VIOLATION - Field
                            public static function main( array $as ) { // VIOLATION - Formal
                                $r = 20 + $this->q; // VIOLATION - Local
                                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                    $r += $this->q;
                                }
                            }
                        }

                        Source https://phpmd.org/rules/naming.html#shortvariable

                        Constant version should be defined in uppercase
                        Open

                            const version = '1.6.0';

                        ConstantNamingConventions

                        Since: 0.2

                        Class/Interface constant names should always be defined in uppercase.

                        Example

                        class Foo {
                            const MY_NUM = 0; // ok
                            const myTest = ""; // fail
                        }

                        Source https://phpmd.org/rules/naming.html#constantnamingconventions

                        There are no issues that match your filters.

                        Category
                        Status