PHPSocialNetwork/phpfastcache-bundle

View on GitHub

Showing 43 of 43 total issues

Remove error control operator '@' on line 49.
Open

    public function size_format($bytes, $decimals = 2, $octetFormat = false, $separator = '')
    {
        $bytes = (int)$bytes;
        $sz = 'BKMGTP';
        $factor = floor((\strlen($bytes) - 1) / 3);

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Avoid too many return statements within this method.
Open

        return $string;
Severity: Major
Found in src/Command/PhpfastcacheSetCommand.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return (array) $jsonArray;
    Severity: Major
    Found in src/Command/PhpfastcacheSetCommand.php - About 30 mins to fix

      Missing class import via use statement (line '31', column '15').
      Open

                new \Twig_SimpleFilter('sizeFormat', [$this, 'size_format']),

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

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

          protected function autoTypeCast($string)
          {
              if(\in_array(\strtolower($string), ['true', 'false'], true)){
                  return $string === 'true';
              }
      Severity: Minor
      Found in src/Command/PhpfastcacheSetCommand.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 using static access to class '\Phpfastcache\Api' in method 'collect'.
      Open

                'apiChangelog' => PhpfastcacheApi::getChangelog(),
      Severity: Minor
      Found in src/DataCollector/CacheCollector.php by phpmd

      StaticAccess

      Since: 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 https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid unused parameters such as '$response'.
      Open

          public function collect(Request $request, Response $response, \Exception $exception = null)
      Severity: Minor
      Found in src/DataCollector/CacheCollector.php by phpmd

      UnusedFormalParameter

      Since: 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 https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Avoid using static access to class '\Phpfastcache\CacheManager' in method 'collect'.
      Open

                  'namespacePath (deprecated)' => CacheManager::getNamespacePath(),
      Severity: Minor
      Found in src/DataCollector/CacheCollector.php by phpmd

      StaticAccess

      Since: 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 https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Phpfastcache\Api' in method 'collect'.
      Open

                'apiVersion' => PhpfastcacheApi::getVersion(),
      Severity: Minor
      Found in src/DataCollector/CacheCollector.php by phpmd

      StaticAccess

      Since: 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 https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid unused parameters such as '$exception'.
      Open

          public function collect(Request $request, Response $response, \Exception $exception = null)
      Severity: Minor
      Found in src/DataCollector/CacheCollector.php by phpmd

      UnusedFormalParameter

      Since: 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 https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Avoid unused parameters such as '$request'.
      Open

          public function collect(Request $request, Response $response, \Exception $exception = null)
      Severity: Minor
      Found in src/DataCollector/CacheCollector.php by phpmd

      UnusedFormalParameter

      Since: 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 https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Avoid using static access to class '\Phpfastcache\Api' in method 'collect'.
      Open

                'pfcVersion' => PhpfastcacheApi::getPhpFastCacheVersion(),
      Severity: Minor
      Found in src/DataCollector/CacheCollector.php by phpmd

      StaticAccess

      Since: 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 https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Phpfastcache\CacheManager' in method 'collect'.
      Open

                  'driverList' => CacheManager::getDriverList(true),
      Severity: Minor
      Found in src/DataCollector/CacheCollector.php by phpmd

      StaticAccess

      Since: 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 https://phpmd.org/rules/cleancode.html#staticaccess

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

          public function indexAction(Request $request, Phpfastcache $phpfastcache)
          {
              $pfc_test = null;
      
              $cache = $phpfastcache->get('filecache');

      Avoid using static access to class '\Phpfastcache\CacheManager' in method 'get'.
      Open

                      $driverClass = CacheManager::getDriverClass($this->config[ 'drivers' ][ $name ][ 'type' ]);
      Severity: Minor
      Found in src/Service/Phpfastcache.php by phpmd

      StaticAccess

      Since: 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 https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Phpfastcache\CacheManager' in method 'get'.
      Open

                                CacheManager::getInstance(
                                  $this->config[ 'drivers' ][ $name ][ 'type' ],
                                  new $configClass($this->config[ 'drivers' ][ $name ][ 'parameters' ])
                                )
      Severity: Minor
      Found in src/Service/Phpfastcache.php by phpmd

      StaticAccess

      Since: 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 https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Phpfastcache\CacheManager' in method 'getConfigTreeBuilder'.
      Open

                                  ->enumNode('type')->isRequired()->values(CacheManager::getDriverList())->end() // @TODO : Add all available drivers

      StaticAccess

      Since: 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 https://phpmd.org/rules/cleancode.html#staticaccess

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

                  foreach ($caches[ 'drivers' ] as $name => $parameters) {

      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 unused parameters such as '$request'.
      Open

          public function indexAction(Request $request, Phpfastcache $phpfastcache)

      UnusedFormalParameter

      Since: 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 https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $failedInstances = [];
              $io = new SymfonyStyle($input, $output);
      
      

      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

      Severity
      Category
      Status
      Source
      Language