kylekatarnls/nodejs-php-fallback

View on GitHub

Showing 42 of 42 total issues

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

class NodejsPhpFallback
{
    protected $nodePath;

    protected static $modulePaths = array();

Since: PHPMD 0.2.5

The Weighted Method Count (WMC) of a class is a good indicator of how much time and effort is required to modify and maintain this class. The WMC metric is defined as the sum of complexities of all methods declared in a class. A large number of methods also means that this class has a greater potential impact on derived classes.

Example:

class Foo {
      public function bar() {
          if ($a == $b)  {
              if ($a1 == $b1) {
                  fiddle();
              } elseif ($a2 == $b2) {
                  fiddle();
              } else {
              }
          }
      }
      public function baz() {
          if ($a == $b) {
              if ($a1 == $b1) {
                  fiddle();
              } elseif ($a2 == $b2) {
                  fiddle();
              } else {
              }
          }
      }
      // Several other complex methods
  }

Source: http://phpmd.org/rules/codesize.txt

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

class NodejsPhpFallback
{
    protected $nodePath;

    protected static $modulePaths = array();
Severity: Minor
Found in src/NodejsPhpFallback/NodejsPhpFallback.php - About 2 hrs to fix

    File NodejsPhpFallback.php has 259 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace NodejsPhpFallback;
    
    use Composer\Composer;
    Severity: Minor
    Found in src/NodejsPhpFallback/NodejsPhpFallback.php - About 2 hrs to fix

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

          protected static function getNpmConfig(Composer $composer, $key = null)
          {
              $vendorDir = $composer->getConfig()->get('vendor-dir');
      
              $npm = array();
      Severity: Minor
      Found in src/NodejsPhpFallback/NodejsPhpFallback.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 askForInstall has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function askForInstall(Event $event, $npmConfirm, $npm)
          {
              $io = $event->getIO();
      
              if (!$io->isInteractive()) {
      Severity: Minor
      Found in src/NodejsPhpFallback/NodejsPhpFallback.php - About 1 hr to fix

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

            public static function installPackages($npm, $onFound = null)
            {
                if (!count($npm)) {
                    return true;
                }
        Severity: Minor
        Found in src/NodejsPhpFallback/NodejsPhpFallback.php - About 1 hr to fix

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

              public static function installPackages($npm, $onFound = null)
              {
                  if (!count($npm)) {
                      return true;
                  }
          Severity: Minor
          Found in src/NodejsPhpFallback/NodejsPhpFallback.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

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

              protected static function getGlobalInstallChoice(IOInterface $io, $message)

          Since: PHPMD 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: http://phpmd.org/rules/naming.txt

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

                  $io = $event->getIO();

          Since: PHPMD 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: http://phpmd.org/rules/naming.txt

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

              protected $io;

          Since: PHPMD 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: http://phpmd.org/rules/naming.txt

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

                  $io = $event->getIO();

          Since: PHPMD 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: http://phpmd.org/rules/naming.txt

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

              public function activate(Composer $composer, IOInterface $io)

          Since: PHPMD 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: http://phpmd.org/rules/naming.txt

          Function askForInstall has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function askForInstall(Event $event, $npmConfirm, $npm)
              {
                  $io = $event->getIO();
          
                  if (!$io->isInteractive()) {
          Severity: Minor
          Found in src/NodejsPhpFallback/NodejsPhpFallback.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

          Avoid unused parameters such as '$composer'.
          Open

              public function activate(Composer $composer, IOInterface $io)

          Since: PHPMD 0.2

          Avoid passing parameters to methods or constructors and then not using those parameters.

          Example:

          class Foo
            {
                private function bar($howdy)
                {
                    // $howdy is not used
                }
            }

          Source: http://phpmd.org/rules/unusedcode.txt

          The method askForInstall() has an NPath complexity of 336. The configured NPath complexity threshold is 200.
          Open

              public static function askForInstall(Event $event, $npmConfirm, $npm)
              {
                  $io = $event->getIO();
          
                  if (!$io->isInteractive()) {

          Since: PHPMD 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: http://phpmd.org/rules/codesize.txt

          Avoid using static access to class 'NodejsPhpFallback\NodejsPhpFallback' in method 'onAutoloadDump'.
          Open

                  NodejsPhpFallback::install($event);

          Since: PHPMD 1.4.0

          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

          Example:

          class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

          Source: http://phpmd.org/rules/cleancode.txt

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

              public static function askForInstall(Event $event, $npmConfirm, $npm)
              {
                  $io = $event->getIO();
          
                  if (!$io->isInteractive()) {

          Since: PHPMD 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: http://phpmd.org/rules/codesize.txt

          Line exceeds 120 characters; contains 141 characters
          Open

                          if ($dependency === '.' || $dependency === '..' || !is_dir($subDirectory = $directory . DIRECTORY_SEPARATOR . $dependency)) {

          Line exceeds 120 characters; contains 131 characters
          Open

                      if ($namespace === '.' || $namespace === '..' || !is_dir($directory = $vendorDir . DIRECTORY_SEPARATOR . $namespace)) {

          Opening parenthesis of a multi-line function call must be the last content on the line
          Open

                  $manual = static::getGlobalInstallChoice($io,
          Severity
          Category
          Status
          Source
          Language