ampache/ampache

View on GitHub
src/Module/Api/Json_Data.php

Summary

Maintainability
F
1 wk
Test Coverage

songs accesses the super-global variable $_REQUEST.
Open

    public static function songs($objects, $user, $encode = true, $object = true)
    {
        $output = array(
            "total_count" => count($objects)
        );
Severity: Minor
Found in src/Module/Api/Json_Data.php by phpmd

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

user accesses the super-global variable $_REQUEST.
Open

    public static function user(User $user, bool $fullinfo, ?bool $object = true): string
    {
        $user->format();
        $art_url = Art::url($user->id, 'user', $_REQUEST['auth'] ?? '');
        if ($fullinfo) {
Severity: Minor
Found in src/Module/Api/Json_Data.php by phpmd

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

songs accesses the super-global variable $_REQUEST.
Open

    public static function songs($objects, $user, $encode = true, $object = true)
    {
        $output = array(
            "total_count" => count($objects)
        );
Severity: Minor
Found in src/Module/Api/Json_Data.php by phpmd

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

democratic accesses the super-global variable $_REQUEST.
Open

    public static function democratic($object_ids, $user, $object = true): string
    {
        if (!is_array($object_ids)) {
            $object_ids = array();
        }
Severity: Minor
Found in src/Module/Api/Json_Data.php by phpmd

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

File Json_Data.php has 1389 lines of code (exceeds 500 allowed). Consider refactoring.
Open

<?php

declare(strict_types=0);

/**
Severity: Major
Found in src/Module/Api/Json_Data.php - About 2 days to fix

    Function index has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function index($objects, $type, $user, $include = false): string
        {
            $output = [];
    
            if ((count($objects) > self::$limit || self::$offset > 0) && self::$limit) {
    Severity: Minor
    Found in src/Module/Api/Json_Data.php - About 1 day 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

    Json_Data has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Json_Data
    {
        // This is added so that we don't pop any webservers
        private static ?int $limit = 5000;
        private static int $offset = 0;
    Severity: Minor
    Found in src/Module/Api/Json_Data.php - About 4 hrs to fix

      Function playlists has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function playlists($objects, $user, $songs = false, $encode = true, $object = true, $show_dupes = true)
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 4 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

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

      class Json_Data
      {
          // This is added so that we don't pop any webservers
          private static ?int $limit = 5000;
          private static int $offset = 0;
      Severity: Minor
      Found in src/Module/Api/Json_Data.php by phpmd

      The class Json_Data has 28 public methods. Consider refactoring Json_Data to keep number of public methods under 10.
      Open

      class Json_Data
      {
          // This is added so that we don't pop any webservers
          private static ?int $limit = 5000;
          private static int $offset = 0;
      Severity: Minor
      Found in src/Module/Api/Json_Data.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      The class Json_Data has 29 non-getter- and setter-methods. Consider refactoring Json_Data to keep number of methods under 25.
      Open

      class Json_Data
      {
          // This is added so that we don't pop any webservers
          private static ?int $limit = 5000;
          private static int $offset = 0;
      Severity: Minor
      Found in src/Module/Api/Json_Data.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanymethods

      Function songs has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function songs($objects, $user, $encode = true, $object = true)
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function albums has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function albums($objects, $include, $user, $encode = true, $object = true)
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function bookmarks has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function bookmarks($objects, $include = false, $object = true): string
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function podcasts has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function podcasts($objects, $user, $episodes = false, $encode = true, $object = true)
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function labels has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function labels($objects, $encode = true, $object = true)
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function users has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function users($objects, $encode = true, $object = true)
          {
              if ((count($objects) > self::$limit || self::$offset > 0) && self::$limit) {
                  $objects = array_splice($objects, self::$offset, self::$limit);
              }
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function videos has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function videos($objects, $user, $encode = true, $object = true)
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function artists has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function artists($objects, $include, $user, $encode = true, $object = true)
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function podcast_episodes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function podcast_episodes($objects, $user, $encode = true, $object = true)
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function indexes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function indexes($objects, $type, $user, $include = false): string
          {
              // here is where we call the object type
              switch ($type) {
                  case 'song':
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          public static function catalogs($objects, $object = true): string
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          public static function live_streams($objects, $object = true): string
          {
              $output = array(
                  "total_count" => count($objects)
              );
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          private static function genre_array($tags): array
          {
              $JSON = [];
      
              if (!empty($tags)) {
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method playlists has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function playlists($objects, $user, $songs = false, $encode = true, $object = true, $show_dupes = true)
      Severity: Minor
      Found in src/Module/Api/Json_Data.php - About 45 mins to fix

        Function genres has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function genres($objects, $encode = true, $object = true)
            {
                $output = array(
                    "total_count" => count($objects)
                );
        Severity: Minor
        Found in src/Module/Api/Json_Data.php - About 45 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 licenses has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function licenses($objects, $object = true): string
            {
                $output = array(
                    "total_count" => count($objects)
                );
        Severity: Minor
        Found in src/Module/Api/Json_Data.php - About 45 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

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

            public static function browses($objects, $parent_id, $parent_type, $child_type, $catalog_id): string
        Severity: Minor
        Found in src/Module/Api/Json_Data.php - About 35 mins to fix

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

              public static function artists($objects, $include, $user, $encode = true, $object = true)
          Severity: Minor
          Found in src/Module/Api/Json_Data.php - About 35 mins to fix

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

                public static function podcasts($objects, $user, $episodes = false, $encode = true, $object = true)
            Severity: Minor
            Found in src/Module/Api/Json_Data.php - About 35 mins to fix

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

                  public static function albums($objects, $include, $user, $encode = true, $object = true)
              Severity: Minor
              Found in src/Module/Api/Json_Data.php - About 35 mins to fix

                Function deleted has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function deleted($object_type, $objects): string
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.php - About 35 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 shares has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function shares($objects, $object = true): string
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 class Json_Data has 1847 lines of code. Current threshold is 1000. Avoid really long classes.
                Open

                class Json_Data
                {
                    // This is added so that we don't pop any webservers
                    private static ?int $limit = 5000;
                    private static int $offset = 0;
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                The method songs() has an NPath complexity of 1095. The configured NPath complexity threshold is 200.
                Open

                    public static function songs($objects, $user, $encode = true, $object = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method albums() has an NPath complexity of 1365. The configured NPath complexity threshold is 200.
                Open

                    public static function albums($objects, $include, $user, $encode = true, $object = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method songs() has 141 lines of code. Current threshold is set to 100. Avoid really long methods.
                Open

                    public static function songs($objects, $user, $encode = true, $object = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                The method index() has an NPath complexity of 216. The configured NPath complexity threshold is 200.
                Open

                    public static function index($objects, $type, $user, $include = false): string
                    {
                        $output = [];
                
                        if ((count($objects) > self::$limit || self::$offset > 0) && self::$limit) {
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method index() has 130 lines of code. Current threshold is set to 100. Avoid really long methods.
                Open

                    public static function index($objects, $type, $user, $include = false): string
                    {
                        $output = [];
                
                        if ((count($objects) > self::$limit || self::$offset > 0) && self::$limit) {
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                The method playlists() has an NPath complexity of 480. The configured NPath complexity threshold is 200.
                Open

                    public static function playlists($objects, $user, $songs = false, $encode = true, $object = true, $show_dupes = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method playlists() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
                Open

                    public static function playlists($objects, $user, $songs = false, $encode = true, $object = true, $show_dupes = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

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

                    public static function albums($objects, $include, $user, $encode = true, $object = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

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

                    public static function songs($objects, $user, $encode = true, $object = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

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

                    public static function index($objects, $type, $user, $include = false): string
                    {
                        $output = [];
                
                        if ((count($objects) > self::$limit || self::$offset > 0) && self::$limit) {
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

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

                    public static function bookmarks($objects, $include = false, $object = true): string
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

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

                    public static function artists($objects, $include, $user, $encode = true, $object = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

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

                    public static function indexes($objects, $type, $user, $include = false): string
                    {
                        // here is where we call the object type
                        switch ($type) {
                            case 'song':
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

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

                class Json_Data
                {
                    // This is added so that we don't pop any webservers
                    private static ?int $limit = 5000;
                    private static int $offset = 0;
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                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 genres uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method playlists uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method catalogs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $output = $JSON[0] ?? array();
                        }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method user uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $JSON = array(
                                "id" => (string)$user->id,
                                "username" => $user->username,
                                "create_date" => $user->create_date,
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method live_streams uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $output = $JSON[0] ?? array();
                        }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method albums uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method songs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method artists uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method songs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $licenseLink = '';
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method genre_array uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                                } else {
                                    $atags[$data['id']] = array(
                                        'name' => $data['name'],
                                        'count' => 1
                                    );
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method shares uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $output = $JSON[0] ?? array();
                        }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method playlists uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $items = (int)($playitem_total ?? 0);
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method videos uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method playlists uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $playlist = new Playlist($playlist_id);
                                if ($playlist->isNew()) {
                                    continue;
                                }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method podcast_episodes uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $output = $JSON[0] ?? array();
                        }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method podcasts uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method index uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                                        } else {
                                            $sql        = "SELECT `playlist_data`.`id`, `playlist_data`.`object_id`, `playlist_data`.`object_type` FROM `playlist_data` WHERE `playlist_data`.`playlist` = ? ORDER BY `playlist_data`.`track`;";
                                            $db_results = Dba::read($sql, array($object_id));
                                            while ($row = Dba::fetch_assoc($db_results)) {
                                                $output[$object_id][] = array(
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method bookmarks uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $output = $JSON[0] ?? array();
                        }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method index uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $output = $objects;
                        }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method licenses uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $output = $JSON[0] ?? array();
                        }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method labels uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 method users uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $output = $JSON[0] ?? array();
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

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

                    private static ?int $limit = 5000;
                Severity: Critical
                Found in src/Module/Api/Json_Data.php by phan

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

                            if ((int)$playlist_id === 0) {
                                $playlist = new Search((int) str_replace('smart_', '', (string)$playlist_id), 'song', $user);
                                if (
                                    $playlist->isNew() ||
                                    ($hide_dupe_searches && $playlist->user == $user->getId() && in_array($playlist->name, $playlist_names))
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 4 other locations - About 1 day to fix
                src/Module/Api/Json4_Data.php on lines 465..491
                src/Module/Api/Json5_Data.php on lines 558..584
                src/Module/Api/Xml4_Data.php on lines 547..573
                src/Module/Api/Xml5_Data.php on lines 652..678

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

                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

                    public static function timeline($activities, $object = true): string
                    {
                        $JSON = array();
                        foreach ($activities as $activity_id) {
                            $activity = new Useractivity($activity_id);
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 1 other location - About 4 hrs to fix
                src/Module/Api/Json5_Data.php on lines 1251..1273

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

                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

                    private static function genre_array($tags): array
                    {
                        $JSON = [];
                
                        if (!empty($tags)) {
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 1 other location - About 3 hrs to fix
                src/Module/Api/Json5_Data.php on lines 160..186

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

                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

                        foreach ($objects as $tag_id) {
                            $tag    = new Tag($tag_id);
                            $counts = $tag->count();
                            $JSON[] = array(
                                "id" => (string)$tag_id,
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 2 other locations - About 3 hrs to fix
                src/Module/Api/Json4_Data.php on lines 264..277
                src/Module/Api/Json5_Data.php on lines 356..369

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

                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

                    public static function shouts(array $shouts, bool $object = true): string
                    {
                        $JSON = [];
                
                        foreach ($shouts as $shout) {
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 1 other location - About 2 hrs to fix
                src/Module/Api/Json5_Data.php on lines 1220..1241

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

                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

                        foreach ($objects as $label_id) {
                            $label = $labelRepository->findById($label_id);
                            if ($label === null) {
                                continue;
                            }
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 1 other location - About 2 hrs to fix
                src/Module/Api/Json5_Data.php on lines 317..335

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

                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

                        foreach ($objects as $object) {
                            $trimmed  = Catalog::trim_prefix(trim((string)$object['name']), $pattern);
                            $prefix   = $trimmed['prefix'];
                            $basename = $trimmed['string'];
                            $JSON[]   = array(
                Severity: Minor
                Found in src/Module/Api/Json_Data.php and 1 other location - About 55 mins to fix
                src/Module/Api/Json_Data.php on lines 461..471

                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

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

                        foreach ($objects as $object) {
                            $trimmed  = Catalog::trim_prefix(trim((string)$object['name']), $pattern);
                            $prefix   = $trimmed['prefix'];
                            $basename = $trimmed['string'];
                            $JSON[]   = array(
                Severity: Minor
                Found in src/Module/Api/Json_Data.php and 1 other location - About 55 mins to fix
                src/Module/Api/Json_Data.php on lines 419..429

                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

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

                                case 'song_artist':
                                    foreach ($objects as $object_id) {
                                        $output[$object_id] = [];
                
                                        $sql        = "SELECT DISTINCT `album_map`.`album_id` FROM `album_map` WHERE `album_map`.`object_id` = ? AND `album_map`.`object_type` = 'song';";
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 4 other locations - About 40 mins to fix
                src/Module/Api/Json_Data.php on lines 223..236
                src/Module/Api/Json_Data.php on lines 251..264
                src/Module/Api/Json_Data.php on lines 265..278
                src/Module/Api/Json_Data.php on lines 308..321

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

                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 5 locations. Consider refactoring.
                Open

                                case 'podcast':
                                    foreach ($objects as $object_id) {
                                        $output[$object_id] = [];
                
                                        $sql        = "SELECT DISTINCT `podcast_episode`.`id` FROM `podcast_episode` WHERE `podcast_episode`.`podcast` = ?;";
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 4 other locations - About 40 mins to fix
                src/Module/Api/Json_Data.php on lines 223..236
                src/Module/Api/Json_Data.php on lines 237..250
                src/Module/Api/Json_Data.php on lines 251..264
                src/Module/Api/Json_Data.php on lines 265..278

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

                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 5 locations. Consider refactoring.
                Open

                                case 'album_artist':
                                    foreach ($objects as $object_id) {
                                        $output[$object_id] = [];
                
                                        $sql        = "SELECT DISTINCT `album_map`.`album_id` FROM `album_map` WHERE `album_map`.`object_id` = ? AND `album_map`.`object_type` = 'album';";
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 4 other locations - About 40 mins to fix
                src/Module/Api/Json_Data.php on lines 237..250
                src/Module/Api/Json_Data.php on lines 251..264
                src/Module/Api/Json_Data.php on lines 265..278
                src/Module/Api/Json_Data.php on lines 308..321

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

                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 5 locations. Consider refactoring.
                Open

                                case 'artist':
                                    foreach ($objects as $object_id) {
                                        $output[$object_id] = [];
                
                                        $sql        = "SELECT DISTINCT `album_map`.`album_id` FROM `album_map` WHERE `album_map`.`object_id` = ?;";
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 4 other locations - About 40 mins to fix
                src/Module/Api/Json_Data.php on lines 223..236
                src/Module/Api/Json_Data.php on lines 237..250
                src/Module/Api/Json_Data.php on lines 265..278
                src/Module/Api/Json_Data.php on lines 308..321

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

                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 5 locations. Consider refactoring.
                Open

                                case 'album':
                                    foreach ($objects as $object_id) {
                                        $output[$object_id] = [];
                
                                        $sql        = "SELECT DISTINCT `song`.`id` FROM `song` WHERE `song`.`album` = ?;";
                Severity: Major
                Found in src/Module/Api/Json_Data.php and 4 other locations - About 40 mins to fix
                src/Module/Api/Json_Data.php on lines 223..236
                src/Module/Api/Json_Data.php on lines 237..250
                src/Module/Api/Json_Data.php on lines 251..264
                src/Module/Api/Json_Data.php on lines 308..321

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

                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

                        foreach ($objects as $live_stream_id) {
                            $live_stream = new Live_Stream($live_stream_id);
                            if ($live_stream->isNew()) {
                                continue;
                            }
                Severity: Minor
                Found in src/Module/Api/Json_Data.php and 1 other location - About 30 mins to fix
                src/Module/Api/Json5_Data.php on lines 246..260

                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

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

                            $catalog_rename_pattern = $catalog->rename_pattern;
                Severity: Minor
                Found in src/Module/Api/Json_Data.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 $bookmark_creation_date. Keep variable name length under 20.
                Open

                            $bookmark_creation_date = $bookmark->creation_date;
                Severity: Minor
                Found in src/Module/Api/Json_Data.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

                The parameter $parent_type is not named in camelCase.
                Open

                    public static function browses($objects, $parent_id, $parent_type, $child_type, $catalog_id): string
                    {
                        $output = array(
                            "total_count" => count($objects),
                            "catalog_id" => (string)$catalog_id,
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseParameterName

                Since: 0.2

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

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $catalog_id is not named in camelCase.
                Open

                    public static function browses($objects, $parent_id, $parent_type, $child_type, $catalog_id): string
                    {
                        $output = array(
                            "total_count" => count($objects),
                            "catalog_id" => (string)$catalog_id,
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseParameterName

                Since: 0.2

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

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The class Json_Data is not named in CamelCase.
                Open

                class Json_Data
                {
                    // This is added so that we don't pop any webservers
                    private static ?int $limit = 5000;
                    private static int $offset = 0;
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseClassName

                Since: 0.2

                It is considered best practice to use the CamelCase notation to name classes.

                Example

                class class_name {
                }

                Source

                The parameter $return_data is not named in camelCase.
                Open

                    public static function success($string, $return_data = array()): string
                    {
                        $message = array(
                            "success" => $string
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseParameterName

                Since: 0.2

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

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $show_dupes is not named in camelCase.
                Open

                    public static function playlists($objects, $user, $songs = false, $encode = true, $object = true, $show_dupes = true)
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseParameterName

                Since: 0.2

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

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $parent_id is not named in camelCase.
                Open

                    public static function browses($objects, $parent_id, $parent_type, $child_type, $catalog_id): string
                    {
                        $output = array(
                            "total_count" => count($objects),
                            "catalog_id" => (string)$catalog_id,
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseParameterName

                Since: 0.2

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

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $object_ids is not named in camelCase.
                Open

                    public static function democratic($object_ids, $user, $object = true): string
                    {
                        if (!is_array($object_ids)) {
                            $object_ids = array();
                        }
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseParameterName

                Since: 0.2

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

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $object_type is not named in camelCase.
                Open

                    public static function deleted($object_type, $objects): string
                    {
                        $output = array(
                            "total_count" => count($objects)
                        );
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseParameterName

                Since: 0.2

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

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $child_type is not named in camelCase.
                Open

                    public static function browses($objects, $parent_id, $parent_type, $child_type, $catalog_id): string
                    {
                        $output = array(
                            "total_count" => count($objects),
                            "catalog_id" => (string)$catalog_id,
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpmd

                CamelCaseParameterName

                Since: 0.2

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

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                Expected 0 spaces after opening bracket; newline found
                Open

                                if (
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpcodesniffer

                Class name "Json_Data" is not in camel caps format
                Open

                class Json_Data
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpcodesniffer

                Expected 0 spaces after opening bracket; newline found
                Open

                                if (
                Severity: Minor
                Found in src/Module/Api/Json_Data.php by phpcodesniffer

                There are no issues that match your filters.

                Category
                Status