digipolisgent/robo-digipolis-symfony

View on GitHub
src/Robo/Plugin/Commands/DigipolisSymfonyDefaultHooksCommands.php

Summary

Maintainability
A
2 hrs
Test Coverage

env accesses the super-global variable $_ENV.
Open

    protected function env($key, $default = null)
    {
        $value = array_key_exists($key, $_ENV) ? $_ENV[$key] : false;
        if ($value === false) {
            return is_callable($default) ? call_user_func($default) : $default;

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

env accesses the super-global variable $_ENV.
Open

    protected function env($key, $default = null)
    {
        $value = array_key_exists($key, $_ENV) ? $_ENV[$key] : false;
        if ($value === false) {
            return is_callable($default) ? call_user_func($default) : $default;

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

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

    public function defaultDbConfig()
    {
        $rootDir = $this->getConfig()->get('digipolis.root.project', false);
        if (!$rootDir) {
            return false;
Severity: Minor
Found in src/Robo/Plugin/Commands/DigipolisSymfonyDefaultHooksCommands.php - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

                return substr($value, 1, -1);
    Severity: Major
    Found in src/Robo/Plugin/Commands/DigipolisSymfonyDefaultHooksCommands.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return $value;
      Severity: Major
      Found in src/Robo/Plugin/Commands/DigipolisSymfonyDefaultHooksCommands.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return;
        Severity: Major
        Found in src/Robo/Plugin/Commands/DigipolisSymfonyDefaultHooksCommands.php - About 30 mins to fix

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

              protected function env($key, $default = null)
              {
                  $value = array_key_exists($key, $_ENV) ? $_ENV[$key] : false;
                  if ($value === false) {
                      return is_callable($default) ? call_user_func($default) : $default;

          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

          Line exceeds 120 characters; contains 122 characters
          Open

                  preg_match('/^([^:\/\/]*):\/\/([^:]*):([^@]*)@([^:]*):([^\/]*)\/([^\?]*)(\?serverVersion=.*)?$/', $url, $matches);

          Opening brace should be on a new line
          Open

              public function getPreRestoreBackupRemoteHandler() {

          There are no issues that match your filters.

          Category
          Status