MikeNGarrett/Play-Later

View on GitHub

Showing 129 of 129 total issues

Avoid too many return statements within this method.
Open

            return false;
Severity: Major
Found in config.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
    Severity: Major
    Found in config.php - About 30 mins to fix

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

      function maybe_unserialize( $original ) {
          if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
              return @unserialize( $original );
          return false;
      }
      Severity: Minor
      Found in config.php by phpmd

      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 false;
      Severity: Major
      Found in config.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return false;
        Severity: Major
        Found in config.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return false;
          Severity: Major
          Found in config.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
            Severity: Major
            Found in config.php - About 30 mins to fix

              The method is_serialized has a boolean flag argument $strict, which is a certain sign of a Single Responsibility Principle violation.
              Open

              function is_serialized( $data, $strict = true ) {
              Severity: Minor
              Found in config.php by phpmd

              BooleanArgumentFlag

              Since: 1.4.0

              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

              Example

              class Foo {
                  public function bar($flag = true) {
                  }
              }

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

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

                      $this->session = new SpotifyWebAPI\Session( $spotify_client_id, $spotify_client_secret, $spotify_redirect_uri );
              Severity: Minor
              Found in spotify-config.php by phpmd

              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

              Avoid too many return statements within this method.
              Open

                              return false;
              Severity: Major
              Found in config.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return false;
                Severity: Major
                Found in config.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return false;
                  Severity: Major
                  Found in config.php - About 30 mins to fix

                    Missing class import via use statement (line '25', column '20').
                    Open

                            $this->api = new SpotifyWebAPI\SpotifyWebAPI();
                    Severity: Minor
                    Found in spotify-config.php by phpmd

                    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 get_playlist has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function get_playlist( $me, $api, $offset = 0 ) {
                        $new_all_user_playlists = array();
                        $all_user_playlists_playlists = $api->getUserPlaylists( $me->id, array( 'offset' => $offset ) );
                        $total = $all_user_playlists_playlists->total;
                        $total_pages = $total / 20;
                    Severity: Minor
                    Found in home.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

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

                    function get_playlist( $me, $api, $offset = 0 ) {
                        $new_all_user_playlists = array();
                        $all_user_playlists_playlists = $api->getUserPlaylists( $me->id, array( 'offset' => $offset ) );
                        $total = $all_user_playlists_playlists->total;
                        $total_pages = $total / 20;
                    Severity: Minor
                    Found in all.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

                    The method __construct() contains an exit expression.
                    Open

                                die();
                    Severity: Minor
                    Found in config.php by phpmd

                    ExitExpression

                    Since: 0.2

                    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                    Example

                    class Foo {
                        public function bar($param)  {
                            if ($param === 42) {
                                exit(23);
                            }
                        }
                    }

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

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

                        } else {
                            $semicolon = strpos( $data, ';' );
                            $brace     = strpos( $data, '}' );
                            // Either ; or } must exist.
                            if ( false === $semicolon && false === $brace )
                    Severity: Minor
                    Found in config.php by phpmd

                    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 function is_serialized() has an NPath complexity of 4800. The configured NPath complexity threshold is 200.
                    Open

                    function is_serialized( $data, $strict = true ) {
                        // if it isn't a string, it isn't serialized.
                        if ( ! is_string( $data ) ) {
                            return false;
                        }
                    Severity: Minor
                    Found in config.php by phpmd

                    NPathComplexity

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

                    The function is_serialized() has a Cyclomatic Complexity of 24. The configured cyclomatic complexity threshold is 10.
                    Open

                    function is_serialized( $data, $strict = true ) {
                        // if it isn't a string, it isn't serialized.
                        if ( ! is_string( $data ) ) {
                            return false;
                        }
                    Severity: Minor
                    Found in config.php by phpmd

                    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

                    Heading (h4) has already been defined.
                    Open

                    li.album h4
                    Severity: Minor
                    Found in css/site.css by csslint
                    Severity
                    Category
                    Status
                    Source
                    Language