MikeNGarrett/Play-Later

View on GitHub
all.php

Summary

Maintainability
F
5 days
Test Coverage

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

    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

    TODO found
    Open

    // TODO: grab all rows or something and actually show an accurate count
    Severity: Minor
    Found in all.php by fixme

    TODO found
    Open

    // TODO: figure out what the hell to exactly do with these currently useless genres
    Severity: Minor
    Found in all.php by fixme

    TODO found
    Open

    /* // TODO: figure out what the hell to do here
    Severity: Minor
    Found in all.php by fixme

    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

    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

              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

    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( $album['artists'] ) && !empty( $album['artists'] ) && !is_serialized( $album['artists'] ) ) {
                        foreach ($album['artists'] as $artist) {
                            $buf[] = '<a class="artist" href="'.$artist->uri.'">'.$artist->name.'</a>';
                        }
                        echo implode(', ', $buf);
    Severity: Minor
    Found in all.php and 1 other location - About 55 mins to fix
    home.php on lines 447..454

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

    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 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 $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 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

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

        static $e = array('&#38;', '&#34;', '&#60;', '&#62;');
    Severity: Minor
    Found in all.php by phpmd

    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 $s. Configured minimum length is 3.
    Open

    function xe($s) {
    Severity: Minor
    Found in all.php by phpmd

    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 $me. Configured minimum length is 3.
    Open

    function get_playlist( $me, $api, $offset = 0 ) {
    Severity: Minor
    Found in all.php by phpmd

    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 $u. Configured minimum length is 3.
    Open

        static $u = array('&', '"', '<', '>');
    Severity: Minor
    Found in all.php by phpmd

    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 variable $total_pages is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $all_user_playlists_playlists is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $all_user_playlists_playlists is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $total_pages is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $new_all_user_playlists is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $new_all_user_playlists is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $all_user_playlists_playlists is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $new_all_user_playlists is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $all_user_playlists_playlists is not named in camelCase.
    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 by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status