MikeNGarrett/Play-Later

View on GitHub

Showing 129 of 129 total issues

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

if( !empty( $_SESSION['spotify_token'] ) && !empty( $_SESSION['spotify_expires'] ) ) {
    if ( $_SESSION['spotify_expires'] < time() ) {
        if( !empty($_SESSION['spotify_refresh_token']) ) {
            $spotify->session->refreshAccessToken( $_SESSION['spotify_refresh_token'] );
            $_SESSION['spotify_token'] = $spotify->session->getAccessToken();
Severity: Major
Found in home.php and 1 other location - About 3 days to fix
all.php on lines 23..94

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 676.

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

if( !empty( $_SESSION['spotify_token'] ) && !empty( $_SESSION['spotify_expires'] ) ) {
    if ( $_SESSION['spotify_expires'] < time() ) {
        if( !empty($_SESSION['spotify_refresh_token']) ) {
            $spotify->session->refreshAccessToken( $_SESSION['spotify_refresh_token'] );
            $_SESSION['spotify_token'] = $spotify->session->getAccessToken();
Severity: Major
Found in all.php and 1 other location - About 3 days to fix
home.php on lines 27..97

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 676.

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

File all.php has 384 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
// This is /music-bin/
if( !defined('CHECK') )
    header( 'Location: '.APPURL.'music-bin/' );

Severity: Minor
Found in all.php - About 5 hrs to fix

    Identical blocks of code found in 2 locations. 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: Major
    Found in all.php and 1 other location - About 5 hrs to fix
    home.php on lines 121..137

    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 186.

    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

    Identical blocks of code found in 2 locations. 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: Major
    Found in home.php and 1 other location - About 5 hrs to fix
    all.php on lines 118..134

    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 186.

    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

    File home.php has 335 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    if( !defined('CHECK') )
        header( 'Location: '.APPURL );
    
    error_reporting(E_ALL);
    Severity: Minor
    Found in home.php - About 4 hrs to fix

      Function is_serialized has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      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 - 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

      Method create_database has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function create_database() {
              try
              {
                  $this->exec('
                      CREATE TABLE IF NOT EXISTS albums (
      Severity: Major
      Found in config.php - About 2 hrs to fix

        Method is_serialized has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        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 - About 1 hr to fix

          Avoid excessively long variable names like $new_all_user_playlists. Keep variable name length under 20.
          Open

              $new_all_user_playlists = array();
          Severity: Minor
          Found in all.php by phpmd

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $all_user_playlists_playlists. Keep variable name length under 20.
          Open

              $all_user_playlists_playlists = $api->getUserPlaylists( $me->id, array( 'offset' => $offset ) );
          Severity: Minor
          Found in all.php by phpmd

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $all_user_playlists_playlists. Keep variable name length under 20.
          Open

              $all_user_playlists_playlists = $api->getUserPlaylists( $me->id, array( 'offset' => $offset ) );
          Severity: Minor
          Found in home.php by phpmd

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $new_all_user_playlists. Keep variable name length under 20.
          Open

              $new_all_user_playlists = array();
          Severity: Minor
          Found in home.php by phpmd

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $spotify_client_secret. Keep variable name length under 20.
          Open

              public function __construct( $spotify_client_id = '', $spotify_client_secret = '', $spotify_redirect_uri = '', $callback_url = '')
          Severity: Minor
          Found in spotify-config.php by phpmd

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

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

                    if ( !empty($_GET) ) {
                      foreach ($_GET as $parameter => $value) {
                        if( $parameter == 'offset' || $parameter == 'q' ) continue;
                        if( is_array( $value ) ) {
                          foreach( $value as $v ) {
          Severity: Major
          Found in home.php and 1 other location - About 1 hr to fix
          all.php on lines 452..463

          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 108.

          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

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

                    if ( !empty($_GET) ) {
                      foreach ($_GET as $parameter => $value) {
                        if( $parameter == 'offset' || $parameter == 'q' ) continue;
                        if( is_array( $value ) ) {
                          foreach( $value as $v ) {
          Severity: Major
          Found in all.php and 1 other location - About 1 hr to fix
          home.php on lines 477..488

          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 108.

          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

          Avoid using short method names like ::xe(). The configured minimum method name length is 3.
          Open

          function xe($s) {
              static $u = array('&', '"', '<', '>');
              static $e = array('&#38;', '&#34;', '&#60;', '&#62;');
              return str_replace($u, $e, $s);
          }
          Severity: Minor
          Found in home.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

          Avoid using short method names like ::xe(). The configured minimum method name length is 3.
          Open

          function xe($s) {
              static $u = array('&', '"', '<', '>');
              static $e = array('&#38;', '&#34;', '&#60;', '&#62;');
              return str_replace($u, $e, $s);
          }
          Severity: Minor
          Found in all.php by phpmd

          ShortMethodName

          Since: 0.2

          Detects when very short method names are used.

          Example

          class ShortMethod {
              public function a( $index ) { // Violation
              }
          }

          Source https://phpmd.org/rules/naming.html#shortmethodname

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

          if( isset( $_GET['date'] ) ) {
              switch($_GET['date']) {
                  case 'this-week':
                  default :
                      $from_day = $last_friday;
          Severity: Major
          Found in all.php and 1 other location - About 1 hr to fix
          home.php on lines 158..174

          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 106.

          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

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

          if( isset( $_GET['date'] ) ) {
              switch($_GET['date']) {
                  case 'this-week':
                  default :
                      $from_day = $last_friday;
          Severity: Major
          Found in home.php and 1 other location - About 1 hr to fix
          all.php on lines 157..173

          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 106.

          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

          Severity
          Category
          Status
          Source
          Language