spiritix/lada-cache

View on GitHub

Showing 59 of 59 total issues

Function getRows has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRows()
    {
        $rows = [];
        $wheres = $this->queryBuilder->wheres ?: [];

Severity: Minor
Found in src/Spiritix/LadaCache/Reflector.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 getTableTags has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTableTags($tables, $rows)
    {
        $tags = [];
        $type = $this->reflector->getType();

Severity: Minor
Found in src/Spiritix/LadaCache/Tagger.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 getTablesFromWhere has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTablesFromWhere(QueryBuilder $queryBuilder, &$tables) {
        if (!isset($queryBuilder->wheres)) {
            return;
        }
        $wheres = $queryBuilder->wheres ?: [];
Severity: Minor
Found in src/Spiritix/LadaCache/Reflector.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 (($type === Reflector::QUERY_TYPE_SELECT && $isSpecific) ||
                ($type === Reflector::QUERY_TYPE_UPDATE && !$isSpecific) ||
                ($type === Reflector::QUERY_TYPE_DELETE && !$isSpecific) ||
                ($type === Reflector::QUERY_TYPE_TRUNCATE)) {

Severity: Major
Found in src/Spiritix/LadaCache/Tagger.php - About 1 hr to fix

    Function tablesCachable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function tablesCachable()
        {
            $tables = $this->reflector->getTables();
    
            if ($this->isInclusive()) {
    Severity: Minor
    Found in src/Spiritix/LadaCache/Manager.php - About 55 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 variables with short names like $id. Configured minimum length is 3.
    Open

        public function delete($id = null)

    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

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

        public function selectSub($query, $as)

    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

    The class LadaCacheServiceProvider has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
    Open

    class LadaCacheServiceProvider extends ServiceProvider
    {
        /**
         * The package configuration file.
         */

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            ConnectionInterface $connection,
            Grammar $grammar = null,
            Processor $processor = null,
            QueryHandler $handler,
            Model $model = null
    Severity: Minor
    Found in src/Spiritix/LadaCache/Database/QueryBuilder.php - About 35 mins to fix

      Method newPivot has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
      Severity: Minor
      Found in src/Spiritix/LadaCache/Database/LadaCacheTrait.php - About 35 mins to fix

        Method endMeasuring has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function endMeasuring($type, $hash, $tags, $sql, $parameters)
        Severity: Minor
        Found in src/Spiritix/LadaCache/Debug/CacheCollector.php - About 35 mins to fix

          Expected 1 space after FUNCTION keyword; 0 found
          Open

                  $this->app->singleton('command.lada-cache.flush', function() {

          Expected 1 space after FUNCTION keyword; 0 found
          Open

                  $this->app->singleton('command.lada-cache.disable', function() {

          Blank line found at start of control structure
          Open

                  if ($this->writeConfig('active', "env('LADA_CACHE_ACTIVE', true)")) {

          Blank line found at start of control structure
          Open

                          foreach ($joins as $join) {

          Blank line found at start of control structure
          Open

                  foreach ($tables as $table) {

          Expected 1 space after FUNCTION keyword; 0 found
          Open

                  $this->app->singleton('lada.invalidator', function($app) {

          Blank line found at start of control structure
          Open

                          ($type === Reflector::QUERY_TYPE_TRUNCATE)) {

          Blank line found at start of control structure
          Open

                  foreach ($wheres as $where) {

          Expected 1 space after FUNCTION keyword; 0 found
          Open

                  $this->app->singleton('lada.handler', function($app) {
          Severity
          Category
          Status
          Source
          Language