ampache/ampache

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

Summary

Maintainability
F
1 wk
Test Coverage

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/Json5_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($songs, $user, $encode = true, $object = true)
    {
        if ((count($songs) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
            $songs = array_slice($songs, self::$offset, self::$limit);
        }
Severity: Minor
Found in src/Module/Api/Json5_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($songs, $user, $encode = true, $object = true)
    {
        if ((count($songs) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
            $songs = array_slice($songs, self::$offset, self::$limit);
        }
Severity: Minor
Found in src/Module/Api/Json5_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 Json5_Data.php has 963 lines of code (exceeds 500 allowed). Consider refactoring.
Open

<?php

declare(strict_types=0);

/**
Severity: Major
Found in src/Module/Api/Json5_Data.php - About 1 day to fix

    Json5_Data has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Json5_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/Json5_Data.php - About 4 hrs to fix

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

          public static function playlists($playlists, $user, $songs = false, $object = true): string
          {
              if ((count($playlists) > self::$limit || self::$offset > 0) && self::$limit) {
                  $playlists = array_slice($playlists, self::$offset, self::$limit);
              }
      Severity: Minor
      Found in src/Module/Api/Json5_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

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

      class Json5_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/Json5_Data.php by phpmd

      The class Json5_Data has 24 public methods. Consider refactoring Json5_Data to keep number of public methods under 10.
      Open

      class Json5_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/Json5_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

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

          public static function songs($songs, $user, $encode = true, $object = true)
          {
              if ((count($songs) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                  $songs = array_slice($songs, self::$offset, self::$limit);
              }
      Severity: Minor
      Found in src/Module/Api/Json5_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 albums has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function albums($albums, $include, $user, $encode = true, $object = true)
          {
              if ((count($albums) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                  $albums = array_splice($albums, self::$offset, self::$limit);
              }
      Severity: Minor
      Found in src/Module/Api/Json5_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 genre_array has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function genre_array($tags): array
          {
              $JSON = array();
      
              if (!empty($tags)) {
      Severity: Minor
      Found in src/Module/Api/Json5_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 podcasts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function podcasts($podcasts, $user, $episodes = false, $object = true): string
          {
              if ((count($podcasts) > self::$limit || self::$offset > 0) && self::$limit) {
                  $podcasts = array_splice($podcasts, self::$offset, self::$limit);
              }
      Severity: Minor
      Found in src/Module/Api/Json5_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 artists has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function artists($artists, $include, $user, $encode = true, $object = true)
          {
              if ((count($artists) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                  $artists = array_splice($artists, self::$offset, self::$limit);
              }
      Severity: Minor
      Found in src/Module/Api/Json5_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 podcast_episodes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function podcast_episodes($podcast_episodes, $user, $encode = true, $object = true)
          {
              if ((count($podcast_episodes) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                  $podcast_episodes = array_splice($podcast_episodes, self::$offset, self::$limit);
              }
      Severity: Minor
      Found in src/Module/Api/Json5_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 artists has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

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

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

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

              public static function live_streams($live_streams, $object = true): string
              {
                  if ((count($live_streams) > self::$limit || self::$offset > 0) && self::$limit) {
                      $live_streams = array_splice($live_streams, self::$offset, self::$limit);
                  }
          Severity: Minor
          Found in src/Module/Api/Json5_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 bookmarks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function bookmarks($bookmarks, $object = true): string
              {
                  if ((count($bookmarks) > self::$limit || self::$offset > 0) && self::$limit) {
                      $bookmarks = array_splice($bookmarks, self::$offset, self::$limit);
                  }
          Severity: Minor
          Found in src/Module/Api/Json5_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 catalogs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function catalogs($catalogs, $object = true): string
              {
                  if ((count($catalogs) > self::$limit || self::$offset > 0) && self::$limit) {
                      $catalogs = array_splice($catalogs, self::$offset, self::$limit);
                  }
          Severity: Minor
          Found in src/Module/Api/Json5_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 videos has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function videos($videos, $user, $object = true): string
              {
                  if ((count($videos) > self::$limit || self::$offset > 0) && self::$limit) {
                      $videos = array_slice($videos, self::$offset, self::$limit);
                  }
          Severity: Minor
          Found in src/Module/Api/Json5_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 labels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function labels($labels, $object = true): string
              {
                  if ((count($labels) > self::$limit || self::$offset > 0) && self::$limit) {
                      $labels = array_splice($labels, self::$offset, self::$limit);
                  }
          Severity: Minor
          Found in src/Module/Api/Json5_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 deleted has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function deleted($object_type, $objects): string
              {
                  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/Json5_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

          Avoid too many return statements within this method.
          Open

                          return self::podcasts($objects, $user, $include);
          Severity: Major
          Found in src/Module/Api/Json5_Data.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return self::videos($objects, $user);
            Severity: Major
            Found in src/Module/Api/Json5_Data.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return self::error('4710', sprintf(T_('Bad Request: %s'), $type), 'indexes', 'type');
              Severity: Major
              Found in src/Module/Api/Json5_Data.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return self::shares($objects);
                Severity: Major
                Found in src/Module/Api/Json5_Data.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return self::podcast_episodes($objects, $user);
                  Severity: Major
                  Found in src/Module/Api/Json5_Data.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return self::live_streams($objects);
                    Severity: Major
                    Found in src/Module/Api/Json5_Data.php - About 30 mins to fix

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

                          public static function licenses(array $licenses, $object = true): string
                          {
                              if ((count($licenses) > self::$limit || self::$offset > 0) && self::$limit) {
                                  $licenses = array_splice($licenses, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 method songs() has an NPath complexity of 375. The configured NPath complexity threshold is 200.
                      Open

                          public static function songs($songs, $user, $encode = true, $object = true)
                          {
                              if ((count($songs) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $songs = array_slice($songs, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 an NPath complexity of 632. The configured NPath complexity threshold is 200.
                      Open

                          public static function playlists($playlists, $user, $songs = false, $object = true): string
                          {
                              if ((count($playlists) > self::$limit || self::$offset > 0) && self::$limit) {
                                  $playlists = array_slice($playlists, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 1095. The configured NPath complexity threshold is 200.
                      Open

                          public static function albums($albums, $include, $user, $encode = true, $object = true)
                          {
                              if ((count($albums) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $albums = array_splice($albums, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 class Json5_Data has 1332 lines of code. Current threshold is 1000. Avoid really long classes.
                      Open

                      class Json5_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/Json5_Data.php by phpmd

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

                          public static function songs($songs, $user, $encode = true, $object = true)
                          {
                              if ((count($songs) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $songs = array_slice($songs, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_Data.php by phpmd

                      The method artists() has an NPath complexity of 255. The configured NPath complexity threshold is 200.
                      Open

                          public static function artists($artists, $include, $user, $encode = true, $object = true)
                          {
                              if ((count($artists) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $artists = array_splice($artists, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
                      Open

                          public static function albums($albums, $include, $user, $encode = true, $object = true)
                          {
                              if ((count($albums) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $albums = array_splice($albums, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 podcast_episodes() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                      Open

                          public static function podcast_episodes($podcast_episodes, $user, $encode = true, $object = true)
                          {
                              if ((count($podcast_episodes) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $podcast_episodes = array_splice($podcast_episodes, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 playlists() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10.
                      Open

                          public static function playlists($playlists, $user, $songs = false, $object = true): string
                          {
                              if ((count($playlists) > self::$limit || self::$offset > 0) && self::$limit) {
                                  $playlists = array_slice($playlists, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 12. The configured cyclomatic complexity threshold is 10.
                      Open

                          public static function artists($artists, $include, $user, $encode = true, $object = true)
                          {
                              if ((count($artists) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $artists = array_splice($artists, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 13. The configured cyclomatic complexity threshold is 10.
                      Open

                          public static function songs($songs, $user, $encode = true, $object = true)
                          {
                              if ((count($songs) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $songs = array_slice($songs, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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)
                          {
                              // here is where we call the object type
                              switch ($type) {
                                  case 'song':
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 Json5_Data has a coupling between objects value of 29. Consider to reduce the number of dependencies under 13.
                      Open

                      class Json5_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/Json5_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 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/Json5_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/Json5_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/Json5_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/Json5_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/Json5_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/Json5_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/Json5_Data.php and 4 other locations - About 1 day to fix
                      src/Module/Api/Json4_Data.php on lines 465..491
                      src/Module/Api/Json_Data.php on lines 880..906
                      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/Json5_Data.php and 1 other location - About 4 hrs to fix
                      src/Module/Api/Json_Data.php on lines 1761..1783

                      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 = array();
                      
                              if (!empty($tags)) {
                      Severity: Major
                      Found in src/Module/Api/Json5_Data.php and 1 other location - About 3 hrs to fix
                      src/Module/Api/Json_Data.php on lines 174..200

                      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 ($tags as $tag_id) {
                                  $tag    = new Tag($tag_id);
                                  $counts = $tag->count();
                                  $JSON[] = array(
                                      "id" => (string)$tag_id,
                      Severity: Major
                      Found in src/Module/Api/Json5_Data.php and 2 other locations - About 3 hrs to fix
                      src/Module/Api/Json4_Data.php on lines 264..277
                      src/Module/Api/Json_Data.php on lines 637..650

                      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(Traversable $shouts, $object = true): string
                          {
                              $JSON = [];
                      
                              /** @var Shoutbox $shout */
                      Severity: Major
                      Found in src/Module/Api/Json5_Data.php and 1 other location - About 2 hrs to fix
                      src/Module/Api/Json_Data.php on lines 1731..1751

                      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 ($labels as $label_id) {
                                  $label = $labelRepository->findById($label_id);
                                  if ($label === null) {
                                      continue;
                                  }
                      Severity: Major
                      Found in src/Module/Api/Json5_Data.php and 1 other location - About 2 hrs to fix
                      src/Module/Api/Json_Data.php on lines 584..602

                      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

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

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

                      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/Json5_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/Json5_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 $live_streams is not named in camelCase.
                      Open

                          public static function live_streams($live_streams, $object = true): string
                          {
                              if ((count($live_streams) > self::$limit || self::$offset > 0) && self::$limit) {
                                  $live_streams = array_splice($live_streams, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 $podcast_episodes is not named in camelCase.
                      Open

                          public static function podcast_episodes($podcast_episodes, $user, $encode = true, $object = true)
                          {
                              if ((count($podcast_episodes) > self::$limit || self::$offset > 0) && (self::$limit && $encode)) {
                                  $podcast_episodes = array_splice($podcast_episodes, self::$offset, self::$limit);
                              }
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 $return_data is not named in camelCase.
                      Open

                          public static function success($string, $return_data = array()): string
                          {
                              $message = array("success" => $string);
                              foreach ($return_data as $title => $data) {
                                  $message[$title] = $data;
                      Severity: Minor
                      Found in src/Module/Api/Json5_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 Json5_Data is not named in CamelCase.
                      Open

                      class Json5_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/Json5_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 $object_type is not named in camelCase.
                      Open

                          public static function deleted($object_type, $objects): string
                          {
                              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/Json5_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/Json5_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

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

                      class Json5_Data

                      Expected 0 spaces after opening bracket; newline found
                      Open

                                      if (

                      Expected 0 spaces after opening bracket; newline found
                      Open

                                      if (

                      There are no issues that match your filters.

                      Category
                      Status