ampache/ampache

View on GitHub
src/Application/Api/Ajax/Handler/IndexAjaxHandler.php

Summary

Maintainability
F
4 days
Test Coverage

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_SESSION.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

handle accesses the super-global variable $_REQUEST.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');

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

Function handle has a Cognitive Complexity of 116 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');
Severity: Minor
Found in src/Application/Api/Ajax/Handler/IndexAjaxHandler.php - About 2 days 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 handle has 350 lines of code (exceeds 200 allowed). Consider refactoring.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');
        $user    = Core::get_global('user');
Severity: Major
Found in src/Application/Api/Ajax/Handler/IndexAjaxHandler.php - About 7 hrs to fix

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

    final class IndexAjaxHandler implements AjaxHandlerInterface
    {
        private RequestParserInterface $requestParser;
    
        private SlideshowInterface $slideshow;

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

            RequestParserInterface $requestParser,
            SlideshowInterface $slideshow,
            AlbumRepositoryInterface $albumRepository,
            LabelRepositoryInterface $labelRepository,
            SongRepositoryInterface $songRepository,
    Severity: Major
    Found in src/Application/Api/Ajax/Handler/IndexAjaxHandler.php - About 1 hr to fix

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

          public function handle(): void
          {
              $results = array();
              $action  = $this->requestParser->getFromRequest('action');
              $user    = Core::get_global('user');

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

          public function handle(): void
          {
              $results = array();
              $action  = $this->requestParser->getFromRequest('action');
              $user    = Core::get_global('user');

      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

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

      final class IndexAjaxHandler implements AjaxHandlerInterface
      {
          private RequestParserInterface $requestParser;
      
          private SlideshowInterface $slideshow;

      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

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                          } else {
                              $object_ids = $this->songRepository->getByLabel((string)$label->name);
                          }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      Avoid assigning values to variables in if clauses and the like (line '190', column '25').
      Open

          public function handle(): void
          {
              $results = array();
              $action  = $this->requestParser->getFromRequest('action');
              $user    = Core::get_global('user');

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

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

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $data = Stats::get_recently_played($user_id, 'stream', 'song');
                          Song::build_cache(array_keys($data));
                          require Ui::find_template('show_recently_played.inc.php');
                      }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                              } else {
                                  return;
                              }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $results['random_video_selection'] = '<!-- None found -->';
                      }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                          } else {
                              debug_event('index.ajax', 'Already wanted, skipped.', 5);
                          }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                          } else {
                              $fullname  = $this->requestParser->getFromRequest('fullname');
                              $artist    = $this->wantedRepository->findByName($fullname);
                              $biography = Recommendation::get_artist_info_by_name(rawurldecode($fullname));
                          }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $results['random_selection'] = '<!-- None found -->';
      
                          if (Access::check('interface', 75)) {
                              $catalogs = Catalog::get_catalogs();

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                          } else {
                              $walbums = array();
                          }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $results['random_selection'] = '<!-- None found -->';
      
                          if (Access::check('interface', 75)) {
                              $catalogs = Catalog::get_catalogs();

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                          } else {
                              $artist      = (int)$this->requestParser->getFromRequest('artist');
                              $aobj        = new Artist($artist);
                              $artist_mbid = $aobj->mbid;
                          }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                              } else {
                                  debug_event('index.ajax', 'Cannot get missing albums: MusicBrainz ID required.', 3);
                              }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $data = Stats::get_recently_played($user_id, 'stream', 'song');
                          Song::build_cache(array_keys($data));
                          require Ui::find_template('show_recently_played.inc.php');
                      }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method handle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                                  } else {
                                      $missing_objects[] = $similar;
                                  }

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

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

                              $biography = Recommendation::get_artist_info($artist->id);

      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 local variables such as '$hide_columns'.
      Open

                      $hide_columns = array('cel_artist');

      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 local variables such as '$ajax_page'.
      Open

                      $ajax_page = 'index';

      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 local variables such as '$artists'.
      Open

                          $artists = Recommendation::get_artists_like($this->requestParser->getFromRequest('media_artist'), 3, false);

      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 local variables such as '$walbums'.
      Open

                                  $walbums = Wanted::get_missing_albums($artist);

      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 local variables such as '$songs'.
      Open

                          $songs   = Recommendation::get_songs_like($media_id, 3);

      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 local variables such as '$limit_threshold'.
      Open

                          $limit_threshold = AmpConfig::get('stats_threshold', 7);

      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

      syntax error, unexpected 'RequestParserInterface' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
      Open

          private RequestParserInterface $requestParser;

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  case 'random_albums':
                      $albums = $this->albumRepository->getRandom(
                          $user->id,
                          $moment
                      );
      Severity: Major
      Found in src/Application/Api/Ajax/Handler/IndexAjaxHandler.php and 1 other location - About 4 hrs to fix
      src/Application/Api/Ajax/Handler/IndexAjaxHandler.php on lines 131..151

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 173.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  case 'random_album_disks':
                      $albumDisks = $this->albumRepository->getRandomAlbumDisk(
                          $user->id,
                          $moment
                      );
      Severity: Major
      Found in src/Application/Api/Ajax/Handler/IndexAjaxHandler.php and 1 other location - About 4 hrs to fix
      src/Application/Api/Ajax/Handler/IndexAjaxHandler.php on lines 110..130

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 173.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          public function __construct(
              RequestParserInterface $requestParser,
              SlideshowInterface $slideshow,
              AlbumRepositoryInterface $albumRepository,
              LabelRepositoryInterface $labelRepository,
      Severity: Major
      Found in src/Application/Api/Ajax/Handler/IndexAjaxHandler.php and 2 other locations - About 2 hrs to fix
      src/Module/Album/Deletion/AlbumDeleter.php on lines 63..81
      src/Module/Application/Login/DefaultAction.php on lines 71..89

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 132.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

                      if (AmpConfig::get('home_recently_played_all')) {
                          $data = Stats::get_recently_played($user_id);
                          require_once Ui::find_template('show_recently_played_all.inc.php');
                      } else {
                          $data = Stats::get_recently_played($user_id, 'stream', 'song');
      Severity: Major
      Found in src/Application/Api/Ajax/Handler/IndexAjaxHandler.php and 3 other locations - About 30 mins to fix
      public/templates/show_index.inc.php on lines 84..91
      src/Application/Api/Ajax/Handler/IndexAjaxHandler.php on lines 368..375
      src/Application/Api/Ajax/Handler/StatsAjaxHandler.php on lines 98..105

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 90.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

                      if (AmpConfig::get('home_recently_played_all')) {
                          $data = Stats::get_recently_played($user_id);
                          require_once Ui::find_template('show_recently_played_all.inc.php');
                      } else {
                          $data = Stats::get_recently_played($user_id, 'stream', 'song');
      Severity: Major
      Found in src/Application/Api/Ajax/Handler/IndexAjaxHandler.php and 3 other locations - About 30 mins to fix
      public/templates/show_index.inc.php on lines 84..91
      src/Application/Api/Ajax/Handler/IndexAjaxHandler.php on lines 346..353
      src/Application/Api/Ajax/Handler/StatsAjaxHandler.php on lines 98..105

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 90.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status