kylekatarnls/sbp

View on GitHub
src/Sbp/Plugins/Core/Indentation.php

Summary

Maintainability
D
1 day
Test Coverage
A
100%

Function addBracesOnIndent has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

    public static function addBracesOnIndent($content, $caller)
    {
        $content = explode("\n", $content);
        $curind = array();
        $previousRead = '';
Severity: Minor
Found in src/Sbp/Plugins/Core/Indentation.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

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

    public static function addBracesOnIndent($content, $caller)
    {
        $content = explode("\n", $content);
        $curind = array();
        $previousRead = '';
Severity: Major
Found in src/Sbp/Plugins/Core/Indentation.php - About 2 hrs to fix

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

        protected static function isBlock(&$line, &$grouped, $iRead, $pattern)
        {
            if (substr(rtrim($line), -1) === ';') {
                return false;
            }
    Severity: Minor
    Found in src/Sbp/Plugins/Core/Indentation.php - About 1 hr to fix

      Function isBlock has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          protected static function isBlock(&$line, &$grouped, $iRead, $pattern)
          {
              if (substr(rtrim($line), -1) === ';') {
                  return false;
              }
      Severity: Minor
      Found in src/Sbp/Plugins/Core/Indentation.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 (($espaces <= $indent || ($indent === -1 && $espaces === 0)) && preg_match('#(?<![a-zA-Z0-9_\x7f-\xff$\(])('.constant($caller.'::ALLOW_EMPTY_BLOCKS').')(?![a-zA-Z0-9_\x7f-\xff])#', $previousRead) && strpos($previousRead, '{') === false) {
                          $previousRead .= preg_match('`^\s*namespace\s`', $previousRead) || (preg_match('`^\s*([a-zA-Z_]+\s+)*function\s`', $previousRead) && $inInterface !== false) ? ';' : ' {}';
                      }
      Severity: Major
      Found in src/Sbp/Plugins/Core/Indentation.php - About 1 hr to fix

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

            protected static function findLastBlock(&$line, array $blocks)
            {
                $position = false;
                foreach ($blocks as $block) {
                    if (preg_match('#(?<![a-zA-Z0-9$_])'.$block.'(?![a-zA-Z0-9_])#s', $line, $match, PREG_OFFSET_CAPTURE)) {
        Severity: Minor
        Found in src/Sbp/Plugins/Core/Indentation.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

        There are no issues that match your filters.

        Category
        Status