ampache/ampache

View on GitHub
src/Repository/Model/Query.php

Summary

Maintainability
F
6 days
Test Coverage

File Query.php has 888 lines of code (exceeds 500 allowed). Consider refactoring.
Open

<?php

declare(strict_types=0);

/**
Severity: Major
Found in src/Repository/Model/Query.php - About 1 day to fix

    Query has 51 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Query
    {
        private const SORT_STATE = [
            'last_update' => 'ASC',
            'original_year' => 'ASC',
    Severity: Major
    Found in src/Repository/Model/Query.php - About 7 hrs to fix

      Function set_type has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          public function set_type($type, $custom_base = ''): void
          {
              switch ($type) {
                  case 'album':
                      $this->queryType = new AlbumQuery();
      Severity: Minor
      Found in src/Repository/Model/Query.php - About 5 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 Query has an overall complexity of 288 which is very high. The configured complexity threshold is 50.
      Open

      class Query
      {
          private const SORT_STATE = [
              'last_update' => 'ASC',
              'original_year' => 'ASC',
      Severity: Minor
      Found in src/Repository/Model/Query.php by phpmd

      Function set_filter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function set_filter($key, $value): bool
          {
              switch ($key) {
                  case 'album_artist':
                  case 'album_disk':
      Severity: Minor
      Found in src/Repository/Model/Query.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 sql_sort_video has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function sql_sort_video(string $field, string $order, ?string $table = 'video'): string
          {
              $sql = "";
              switch ($field) {
                  case 'addition_time':
      Severity: Minor
      Found in src/Repository/Model/Query.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

      Method set_join_and_and has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function set_join_and_and($type, $table, $source1, $dest1, $source2, $dest2, $source3, $dest3, $priority): void
      Severity: Major
      Found in src/Repository/Model/Query.php - About 1 hr to fix

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

            private function _resort_objects(): bool
            {
                // There are two ways to do this.. the easy way...
                // and the vollmer way, hopefully we don't have to
                // do it the vollmer way
        Severity: Minor
        Found in src/Repository/Model/Query.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 _set_base_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private function _set_base_sql($force = false, $custom_base = ''): void
            {
                // Only allow it to be set once
                if (!empty((string)$this->_state['base']) && !$force) {
                    return;
        Severity: Minor
        Found in src/Repository/Model/Query.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

        Method set_join_and has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function set_join_and($type, $table, $source1, $dest1, $source2, $dest2, $priority): void
        Severity: Major
        Found in src/Repository/Model/Query.php - About 50 mins to fix

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

              private function _get_filter_sql(): string
              {
                  if (!is_array($this->_state['filter'])) {
                      return '';
                  }
          Severity: Minor
          Found in src/Repository/Model/Query.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 __construct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function __construct($query_id = 0, $cached = true)
              {
                  $sid = session_id();
          
                  if (!$cached) {
          Severity: Minor
          Found in src/Repository/Model/Query.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 set_join has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function set_join($type, $table, $source, $dest, $priority): void
          Severity: Minor
          Found in src/Repository/Model/Query.php - About 35 mins to fix

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

                private function _get_limit_sql(): string
                {
                    $offset = $this->get_offset();
                    if ($this->_state['limit'] > 0) {
                        if ($offset > 0) {
            Severity: Minor
            Found in src/Repository/Model/Query.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 LiveStreamQuery::FILTERS;
            Severity: Major
            Found in src/Repository/Model/Query.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return PlaylistLocalplayQuery::FILTERS;
              Severity: Major
              Found in src/Repository/Model/Query.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return PvmsgQuery::FILTERS;
                Severity: Major
                Found in src/Repository/Model/Query.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return PodcastEpisodeQuery::FILTERS;
                  Severity: Major
                  Found in src/Repository/Model/Query.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return SmartPlaylistQuery::FILTERS;
                    Severity: Major
                    Found in src/Repository/Model/Query.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return UserQuery::FILTERS;
                      Severity: Major
                      Found in src/Repository/Model/Query.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return SongQuery::FILTERS;
                        Severity: Major
                        Found in src/Repository/Model/Query.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return WantedQuery::FILTERS;
                          Severity: Major
                          Found in src/Repository/Model/Query.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return SongPreviewQuery::FILTERS;
                            Severity: Major
                            Found in src/Repository/Model/Query.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return TvshowEpisodeQuery::FILTERS;
                              Severity: Major
                              Found in src/Repository/Model/Query.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return TagQuery::FILTERS;
                                Severity: Major
                                Found in src/Repository/Model/Query.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return LabelQuery::FILTERS;
                                  Severity: Major
                                  Found in src/Repository/Model/Query.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return MovieQuery::FILTERS;
                                    Severity: Major
                                    Found in src/Repository/Model/Query.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return PlaylistSearchQuery::FILTERS;
                                      Severity: Major
                                      Found in src/Repository/Model/Query.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                        return PlaylistMediaQuery::FILTERS;
                                        Severity: Major
                                        Found in src/Repository/Model/Query.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                          return PodcastQuery::FILTERS;
                                          Severity: Major
                                          Found in src/Repository/Model/Query.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                            return TvshowQuery::FILTERS;
                                            Severity: Major
                                            Found in src/Repository/Model/Query.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                      return [];
                                              Severity: Major
                                              Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                return;
                                                Severity: Major
                                                Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                  return FollowerQuery::FILTERS;
                                                  Severity: Major
                                                  Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                    return PersonalVideoQuery::FILTERS;
                                                    Severity: Major
                                                    Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return TvshowSeasonQuery::FILTERS;
                                                      Severity: Major
                                                      Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                        return ClipQuery::FILTERS;
                                                        Severity: Major
                                                        Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                          return LicenseQuery::FILTERS;
                                                          Severity: Major
                                                          Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                            return ShoutboxQuery::FILTERS;
                                                            Severity: Major
                                                            Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return PlaylistQuery::FILTERS;
                                                              Severity: Major
                                                              Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                return ShareQuery::FILTERS;
                                                                Severity: Major
                                                                Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                  return CatalogQuery::FILTERS;
                                                                  Severity: Major
                                                                  Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                    return DemocraticQuery::FILTERS;
                                                                    Severity: Major
                                                                    Found in src/Repository/Model/Query.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                      return VideoQuery::FILTERS;
                                                                      Severity: Major
                                                                      Found in src/Repository/Model/Query.php - About 30 mins to fix

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

                                                                            private function _post_process($data): array
                                                                            {
                                                                                $tags = $this->_state['filter']['tag'] ?? '';
                                                                        
                                                                                if (!is_array($tags) || sizeof($tags) < 2) {
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php - About 25 mins to fix

                                                                        Cognitive Complexity

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

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

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

                                                                        Further reading

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

                                                                            private function _get_sql($limit = true): string
                                                                            {
                                                                                if ($this->_state['custom']) {
                                                                                    // custom queries are set by base and should not be added to
                                                                                    $final_sql = $this->_get_base_sql();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 set_type() has 107 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                        Open

                                                                            public function set_type($type, $custom_base = ''): void
                                                                            {
                                                                                switch ($type) {
                                                                                    case 'album':
                                                                                        $this->queryType = new AlbumQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phpmd

                                                                        The method _get_filter_sql() has an NPath complexity of 528. The configured NPath complexity threshold is 200.
                                                                        Open

                                                                            private function _get_filter_sql(): string
                                                                            {
                                                                                if (!is_array($this->_state['filter'])) {
                                                                                    return '';
                                                                                }
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 Query has 1338 lines of code. Current threshold is 1000. Avoid really long classes.
                                                                        Open

                                                                        class Query
                                                                        {
                                                                            private const SORT_STATE = [
                                                                                'last_update' => 'ASC',
                                                                                'original_year' => 'ASC',
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phpmd

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

                                                                            public static function get_allowed_filters($type): array
                                                                            {
                                                                                switch ($type) {
                                                                                    case 'album':
                                                                                        return AlbumQuery::FILTERS;
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 _get_filter_sql() has a Cyclomatic Complexity of 28. The configured cyclomatic complexity threshold is 10.
                                                                        Open

                                                                            private function _get_filter_sql(): string
                                                                            {
                                                                                if (!is_array($this->_state['filter'])) {
                                                                                    return '';
                                                                                }
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 sql_sort_video() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
                                                                        Open

                                                                            public function sql_sort_video(string $field, string $order, ?string $table = 'video'): string
                                                                            {
                                                                                $sql = "";
                                                                                switch ($field) {
                                                                                    case 'addition_time':
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 set_filter() has a Cyclomatic Complexity of 54. The configured cyclomatic complexity threshold is 10.
                                                                        Open

                                                                            public function set_filter($key, $value): bool
                                                                            {
                                                                                switch ($key) {
                                                                                    case 'album_artist':
                                                                                    case 'album_disk':
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 set_type() has a Cyclomatic Complexity of 35. The configured cyclomatic complexity threshold is 10.
                                                                        Open

                                                                            public function set_type($type, $custom_base = ''): void
                                                                            {
                                                                                switch ($type) {
                                                                                    case 'album':
                                                                                        $this->queryType = new AlbumQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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

                                                                        Reduce the number of returns of this function 4, down to the maximum allowed 3.
                                                                        Open

                                                                            private function _get_limit_sql(): string
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function myFunction(){ // Noncompliant as there are 4 return statements
                                                                          if (condition1) {
                                                                            return true;
                                                                          } else {
                                                                            if (condition2) {
                                                                              return false;
                                                                            } else {
                                                                              return true;
                                                                            }
                                                                          }
                                                                          return false;
                                                                        }
                                                                        

                                                                        Reduce the number of returns of this function 33, down to the maximum allowed 3.
                                                                        Open

                                                                            public static function get_allowed_filters($type): array
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function myFunction(){ // Noncompliant as there are 4 return statements
                                                                          if (condition1) {
                                                                            return true;
                                                                          } else {
                                                                            if (condition2) {
                                                                              return false;
                                                                            } else {
                                                                              return true;
                                                                            }
                                                                          }
                                                                          return false;
                                                                        }
                                                                        

                                                                        This function has 9 parameters, which is greater than the 7 authorized.
                                                                        Open

                                                                            public function set_join_and_and($type, $table, $source1, $dest1, $source2, $dest2, $source3, $dest3, $priority): void
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

                                                                        Noncompliant Code Example

                                                                        With a maximum number of 4 parameters:

                                                                        function doSomething($param1, $param2, $param3, $param4, $param5) {
                                                                        ...
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        function doSomething($param1, $param2, $param3, $param4) {
                                                                        ...
                                                                        }
                                                                        

                                                                        Reduce the number of returns of this function 5, down to the maximum allowed 3.
                                                                        Open

                                                                            public function __construct($query_id = 0, $cached = true)
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function myFunction(){ // Noncompliant as there are 4 return statements
                                                                          if (condition1) {
                                                                            return true;
                                                                          } else {
                                                                            if (condition2) {
                                                                              return false;
                                                                            } else {
                                                                              return true;
                                                                            }
                                                                          }
                                                                          return false;
                                                                        }
                                                                        

                                                                        Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
                                                                        Open

                                                                            public function set_filter($key, $value): bool
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                                                                        See

                                                                        Class "Query" has 51 methods, which is greater than 20 authorized. Split it into smaller classes.
                                                                        Open

                                                                        class Query
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

                                                                        Reduce the number of returns of this function 4, down to the maximum allowed 3.
                                                                        Open

                                                                            public function get_saved(): array
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function myFunction(){ // Noncompliant as there are 4 return statements
                                                                          if (condition1) {
                                                                            return true;
                                                                          } else {
                                                                            if (condition2) {
                                                                              return false;
                                                                            } else {
                                                                              return true;
                                                                            }
                                                                          }
                                                                          return false;
                                                                        }
                                                                        

                                                                        Reduce the number of switch cases from 33 to at most 30.
                                                                        Open

                                                                                switch ($type) {
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        When switch statements have large sets of case clauses, it is usually an attempt to map two sets of data. A real map structure would be more readable and maintainable, and should be used instead.

                                                                        Reduce the number of switch cases from 33 to at most 30.
                                                                        Open

                                                                                switch ($type) {
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        When switch statements have large sets of case clauses, it is usually an attempt to map two sets of data. A real map structure would be more readable and maintainable, and should be used instead.

                                                                        Reduce the number of switch cases from 47 to at most 30.
                                                                        Open

                                                                                switch ($key) {
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        When switch statements have large sets of case clauses, it is usually an attempt to map two sets of data. A real map structure would be more readable and maintainable, and should be used instead.

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

                                                                        class Query
                                                                        {
                                                                            private const SORT_STATE = [
                                                                                'last_update' => 'ASC',
                                                                                'original_year' => 'ASC',
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 _get_limit_sql uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                                        Open

                                                                                    } else {
                                                                                        return ' LIMIT ' . (string)($this->_state['limit']);
                                                                                    }
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 _set_base_sql uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                                        Open

                                                                                } else {
                                                                                    // TODO we should remove this default fallback and rely on set_type()
                                                                                    if ($this->queryType === null) {
                                                                                        $this->queryType = new SongQuery();
                                                                                    }
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 set_filter uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                                        Open

                                                                                        } else {
                                                                                            $this->_state['filter'][$key] = array();
                                                                                        }
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 set_sort uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                                        Open

                                                                                } else {
                                                                                    // if the sort already exists you want the reverse
                                                                                    $state = (array_key_exists($sort, $this->_state['sort']))
                                                                                        ? $this->_state['sort'][$sort]
                                                                                        : self::SORT_STATE[$sort] ?? 'DESC';
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 set_filter uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                                        Open

                                                                                        } else {
                                                                                            $this->_state['filter'][$key] = 1;
                                                                                        }
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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

                                                                        Avoid assigning values to variables in if clauses and the like (line '177', column '17').
                                                                        Open

                                                                            public function __construct($query_id = 0, $cached = true)
                                                                            {
                                                                                $sid = session_id();
                                                                        
                                                                                if (!$cached) {
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phpmd

                                                                        IfStatementAssignment

                                                                        Since: 2.7.0

                                                                        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                                                                        Example

                                                                        class Foo
                                                                        {
                                                                            public function bar($flag)
                                                                            {
                                                                                if ($foo = 'bar') { // possible typo
                                                                                    // ...
                                                                                }
                                                                                if ($baz = 0) { // always false
                                                                                    // ...
                                                                                }
                                                                            }
                                                                        }

                                                                        Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

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

                                                                                } else {
                                                                                    // filter and sort set joins as well as group so make sure you run those first
                                                                                    $filter_sql = $this->_get_filter_sql();
                                                                                    $sort_sql   = $this->_get_sort_sql();
                                                                                    // regular queries need to be joined with all the other parts
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 _resort_objects uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                                        Open

                                                                                } else {
                                                                                    // FIXME: this is fragile for large browses
                                                                                    // First pull the objects
                                                                                    $objects = $this->get_saved();
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                                        Open

                                                                                } else {
                                                                                    $sql = 'SELECT `data` FROM `tmp_browse` WHERE `id` = ? AND `sid` = ?';
                                                                        
                                                                                    $db_results = Dba::read($sql, array($query_id, $sid));
                                                                                    if ($results = Dba::fetch_assoc($db_results)) {
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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

                                                                        Define a constant instead of duplicating this literal "tvshow_season" 3 times.
                                                                        Open

                                                                                    case 'tvshow_season':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "playlist" 3 times.
                                                                        Open

                                                                                    case 'playlist':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "start" 3 times.
                                                                        Open

                                                                                'start' => 0,
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "simple" 3 times.
                                                                        Open

                                                                                'simple' => false,
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "video" 6 times.
                                                                        Open

                                                                                    case 'video':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "regex_not_match" 3 times.
                                                                        Open

                                                                                    case 'regex_not_match':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "album_disk" 5 times.
                                                                        Open

                                                                                    case 'album_disk':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "share" 3 times.
                                                                        Open

                                                                                    case 'share':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "live_stream" 3 times.
                                                                        Open

                                                                                    case 'live_stream':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "podcast_episode" 3 times.
                                                                        Open

                                                                                    case 'podcast_episode':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "catalog" 4 times.
                                                                        Open

                                                                                    case 'catalog':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "total" 7 times.
                                                                        Open

                                                                                'total' => null,
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "artist" 6 times.
                                                                        Open

                                                                                    case 'artist':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "extended_key_name" 4 times.
                                                                        Open

                                                                                'extended_key_name' => null,
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Take the required action to fix the issue indicated by this "FIXME" comment.
                                                                        Open

                                                                                    // FIXME: this is fragile for large browses
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        FIXME tags are commonly used to mark places where a bug is suspected, but which the developer wants to deal with later.

                                                                        Sometimes the developer will not have the time or will simply forget to get back to that tag.

                                                                        This rule is meant to track those tags and to ensure that they do not go unnoticed.

                                                                        Noncompliant Code Example

                                                                        function divide($numerator, $denominator) {
                                                                          return $numerator / $denominator;              // FIXME denominator value might be  0
                                                                        }
                                                                        

                                                                        See

                                                                        Define a constant instead of duplicating this literal ".id`" 3 times.
                                                                        Open

                                                                                    $dis = Catalog::get_enable_filter($type, '`' . $type . '`.`id`');
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "limit" 5 times.
                                                                        Open

                                                                                'limit' => 0,
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "tvshow" 3 times.
                                                                        Open

                                                                                    case 'tvshow':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "label" 4 times.
                                                                        Open

                                                                                    case 'label':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "regex_match" 3 times.
                                                                        Open

                                                                                    case 'regex_match':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "nocache" 3 times.
                                                                        Open

                                                                                    $this->id = 'nocache';
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal " LIMIT " 3 times.
                                                                        Open

                                                                                        return ' LIMIT ' . (string)($this->_state['limit']) . ', ' . (string)($offset);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "song_artist" 3 times.
                                                                        Open

                                                                                'song_artist' => null, // Used by $browse->set_type() to filter artists
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "custom" 3 times.
                                                                        Open

                                                                                'custom' => false,
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "filter" 19 times.
                                                                        Open

                                                                                'filter' => array(),
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Remove the unused function parameter "$object_id".
                                                                        Open

                                                                            private function _logic_filter($object_id): bool
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

                                                                        Noncompliant Code Example

                                                                        function doSomething($a, $b) { // "$a" is unused
                                                                          return compute($b);
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        function doSomething($b) {
                                                                          return compute($b);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        Functions in classes that override a class or implement interfaces are ignored.

                                                                        class C extends B {
                                                                        
                                                                          function doSomething($a, $b) {     // no issue reported on $b
                                                                            compute($a);
                                                                          }
                                                                        
                                                                        }
                                                                        

                                                                        See

                                                                        • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
                                                                        • MISRA C:2012, 2.7 - There should be no unused parameters in functions
                                                                        • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
                                                                        • CERT, MSC12-CPP. - Detect and remove code that has no effect

                                                                        Define a constant instead of duplicating this literal "tvshow_episode" 3 times.
                                                                        Open

                                                                                    case 'tvshow_episode':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "select" 5 times.
                                                                        Open

                                                                                'select' => array(),
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "tag_hidden" 3 times.
                                                                        Open

                                                                                    case 'tag_hidden':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "podcast" 4 times.
                                                                        Open

                                                                                    case 'podcast':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "having" 4 times.
                                                                        Open

                                                                                'having' => '', // HAVING is not currently used in Query SQL
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "license" 3 times.
                                                                        Open

                                                                                    case 'license':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "hidden" 3 times.
                                                                        Open

                                                                                    case 'hidden':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "ORDER BY " 3 times.
                                                                        Open

                                                                                $sql = 'ORDER BY ';
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "static" 3 times.
                                                                        Open

                                                                                'static' => false,
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "movie" 3 times.
                                                                        Open

                                                                                    case 'movie':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "video.id" 3 times.
                                                                        Open

                                                                                        $this->set_join_and_and('LEFT', "`rating`", "`rating`.`object_id`", "`video`.`id`", "`rating`.`object_type`", "'video'", "`rating`.`user`", (string)$this->user_id, 100);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "group" 5 times.
                                                                        Open

                                                                                'group' => array(),
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Add a "case default" clause to this "switch" statement.
                                                                        Open

                                                                                switch ($field) {
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

                                                                        Noncompliant Code Example

                                                                        switch ($param) {  //missing default clause
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                        }
                                                                        
                                                                        switch ($param) {
                                                                          default: // default clause should be the last one
                                                                            error();
                                                                            break;
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        switch ($param) {
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                          default:
                                                                            error();
                                                                            break;
                                                                        }
                                                                        

                                                                        See

                                                                        • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
                                                                        • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
                                                                        • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
                                                                        • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
                                                                        • MISRA C:2012, 16.1 - All switch statements shall be well-formed
                                                                        • MISRA C:2012, 16.4 - Every switch statement shall have a default label
                                                                        • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
                                                                        • MITRE, CWE-478 - Missing Default Case in Switch Statement
                                                                        • CERT, MSC01-C. - Strive for logical completeness
                                                                        • CERT, MSC01-CPP. - Strive for logical completeness

                                                                        Add a "case default" clause to this "switch" statement.
                                                                        Open

                                                                                    switch ($type) {
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

                                                                        Noncompliant Code Example

                                                                        switch ($param) {  //missing default clause
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                        }
                                                                        
                                                                        switch ($param) {
                                                                          default: // default clause should be the last one
                                                                            error();
                                                                            break;
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        switch ($param) {
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                          default:
                                                                            error();
                                                                            break;
                                                                        }
                                                                        

                                                                        See

                                                                        • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
                                                                        • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
                                                                        • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
                                                                        • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
                                                                        • MISRA C:2012, 16.1 - All switch statements shall be well-formed
                                                                        • MISRA C:2012, 16.4 - Every switch statement shall have a default label
                                                                        • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
                                                                        • MITRE, CWE-478 - Missing Default Case in Switch Statement
                                                                        • CERT, MSC01-C. - Strive for logical completeness
                                                                        • CERT, MSC01-CPP. - Strive for logical completeness

                                                                        Define a constant instead of duplicating this literal "offset" 3 times.
                                                                        Open

                                                                                'offset' => 0,
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Remove this commented out code.
                                                                        Open

                                                                                //debug_event(self::class, "_resort_objects: " . $sql, 5);
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Programmers should not comment out code as it bloats programs and reduces readability.

                                                                        Unused code should be deleted and can be retrieved from source control history if required.

                                                                        See

                                                                        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
                                                                        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
                                                                        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
                                                                        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

                                                                        Remove this commented out code.
                                                                        Open

                                                                                //debug_event(self::class, 'get_objects query: ' . $sql, 5);
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Programmers should not comment out code as it bloats programs and reduces readability.

                                                                        Unused code should be deleted and can be retrieved from source control history if required.

                                                                        See

                                                                        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
                                                                        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
                                                                        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
                                                                        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

                                                                        Add a "case default" clause to this "switch" statement.
                                                                        Open

                                                                                switch ($type) {
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

                                                                        Noncompliant Code Example

                                                                        switch ($param) {  //missing default clause
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                        }
                                                                        
                                                                        switch ($param) {
                                                                          default: // default clause should be the last one
                                                                            error();
                                                                            break;
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        switch ($param) {
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                          default:
                                                                            error();
                                                                            break;
                                                                        }
                                                                        

                                                                        See

                                                                        • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
                                                                        • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
                                                                        • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
                                                                        • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
                                                                        • MISRA C:2012, 16.1 - All switch statements shall be well-formed
                                                                        • MISRA C:2012, 16.4 - Every switch statement shall have a default label
                                                                        • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
                                                                        • MITRE, CWE-478 - Missing Default Case in Switch Statement
                                                                        • CERT, MSC01-C. - Strive for logical completeness
                                                                        • CERT, MSC01-CPP. - Strive for logical completeness

                                                                        Define a constant instead of duplicating this literal "album" 6 times.
                                                                        Open

                                                                                    case 'album':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Define a constant instead of duplicating this literal "personal_video" 3 times.
                                                                        Open

                                                                                    case 'personal_video':
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                                                                        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                                                                        Noncompliant Code Example

                                                                        With the default threshold of 3:

                                                                        function run() {
                                                                          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                                                                          execute('action1');
                                                                          release('action1');
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        ACTION_1 = 'action1';
                                                                        
                                                                        function run() {
                                                                          prepare(ACTION_1);
                                                                          execute(ACTION_1);
                                                                          release(ACTION_1);
                                                                        }
                                                                        

                                                                        Exceptions

                                                                        To prevent generating some false-positives, literals having less than 5 characters are excluded.

                                                                        Add a "case default" clause to this "switch" statement.
                                                                        Open

                                                                                switch ($type) {
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

                                                                        Noncompliant Code Example

                                                                        switch ($param) {  //missing default clause
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                        }
                                                                        
                                                                        switch ($param) {
                                                                          default: // default clause should be the last one
                                                                            error();
                                                                            break;
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                        }
                                                                        

                                                                        Compliant Solution

                                                                        switch ($param) {
                                                                          case 0:
                                                                            do_something();
                                                                            break;
                                                                          case 1:
                                                                            do_something_else();
                                                                            break;
                                                                          default:
                                                                            error();
                                                                            break;
                                                                        }
                                                                        

                                                                        See

                                                                        • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
                                                                        • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
                                                                        • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
                                                                        • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
                                                                        • MISRA C:2012, 16.1 - All switch statements shall be well-formed
                                                                        • MISRA C:2012, 16.4 - Every switch statement shall have a default label
                                                                        • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
                                                                        • MITRE, CWE-478 - Missing Default Case in Switch Statement
                                                                        • CERT, MSC01-C. - Strive for logical completeness
                                                                        • CERT, MSC01-CPP. - Strive for logical completeness

                                                                        Remove this commented out code.
                                                                        Open

                                                                                //debug_event(self::class, "get_sql: " . $final_sql, 5);
                                                                        Severity: Major
                                                                        Found in src/Repository/Model/Query.php by sonar-php

                                                                        Programmers should not comment out code as it bloats programs and reduces readability.

                                                                        Unused code should be deleted and can be retrieved from source control history if required.

                                                                        See

                                                                        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
                                                                        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
                                                                        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
                                                                        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

                                                                        TODO found
                                                                        Open

                                                                                    // TODO we should remove this default fallback and rely on set_type()
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by fixme

                                                                        TODO found
                                                                        Open

                                                                             * before returning them. TODO this is only for tags/genres? should do this in the select/return if possible
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by fixme

                                                                        TODO found
                                                                        Open

                                                                                return true; // TODO, this must be old so probably not needed
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by fixme

                                                                        FIXME found
                                                                        Open

                                                                                    // FIXME: this is fragile for large browses
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by fixme

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\ArtistQuery
                                                                        Open

                                                                                        return ArtistQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\DemocraticQuery
                                                                        Open

                                                                                        return DemocraticQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\BroadcastQuery
                                                                        Open

                                                                                        return BroadcastQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\ClipQuery
                                                                        Open

                                                                                        return ClipQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Returning type null but get_total() is declared to return int
                                                                        Open

                                                                                    return $this->_state['total'];
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method read from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                $db_results = Dba::read($this->_get_sql(false));
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method read from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                    $db_results = Dba::read($sql, array($query_id, $sid));
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method write from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                Dba::write($sql);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\CatalogQuery
                                                                        Open

                                                                                        return CatalogQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                                                                        Open

                                                                                        debug_event(self::class, 'IGNORED set_filter ' . $this->get_type() . ': ' . $key, 5);
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\FollowerQuery
                                                                        Open

                                                                                        return FollowerQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\AlbumQuery
                                                                        Open

                                                                                        return AlbumQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method insert_id from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                    $insert_id = Dba::insert_id();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\AlbumDiskQuery
                                                                        Open

                                                                                        return AlbumDiskQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method write from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                    Dba::write($sql, array($sid, $data));
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                    if ($results = Dba::fetch_assoc($db_results)) {
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Invalid offset "playlist_type" of array type array{}
                                                                        Open

                                                                                            $this->_state['filter'][$key] = ($this->_state['filter'][$key] == 1) ? 0 : 1;
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\LabelQuery
                                                                        Open

                                                                                        return LabelQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method num_rows from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                $num_rows   = Dba::num_rows($db_results);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\TvshowEpisodeQuery
                                                                        Open

                                                                                        return TvshowEpisodeQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\ArtistQuery
                                                                        Open

                                                                                        $this->queryType = new ArtistQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\DemocraticQuery
                                                                        Open

                                                                                        $this->queryType = new DemocraticQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\FollowerQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new FollowerQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\PersonalVideoQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new PersonalVideoQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\PlaylistLocalplayQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new PlaylistLocalplayQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\ShoutboxQuery
                                                                        Open

                                                                                        $this->queryType = new ShoutboxQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method read from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                $db_results = Dba::read($sql);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\SongQuery
                                                                        Open

                                                                                        $this->queryType = new SongQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\PvmsgQuery
                                                                        Open

                                                                                        return PvmsgQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\ShoutboxQuery
                                                                        Open

                                                                                        return ShoutboxQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\AlbumQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new AlbumQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\AlbumDiskQuery
                                                                        Open

                                                                                        $this->queryType = new AlbumDiskQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\FollowerQuery
                                                                        Open

                                                                                        $this->queryType = new FollowerQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\PlaylistMediaQuery
                                                                        Open

                                                                                        $this->queryType = new PlaylistMediaQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\PlaylistQuery
                                                                        Open

                                                                                        return PlaylistQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\SongPreviewQuery
                                                                        Open

                                                                                        return SongPreviewQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\BroadcastQuery
                                                                        Open

                                                                                        $this->queryType = new BroadcastQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\LicenseQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new LicenseQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\PodcastQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new PodcastQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\ShoutboxQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new ShoutboxQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\WantedQuery
                                                                        Open

                                                                                        $this->queryType = new WantedQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        null passed to foreach instead of array
                                                                        Open

                                                                                foreach ($this->_state['join'] as $joins) {
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\SongQuery
                                                                        Open

                                                                                        return SongQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\AlbumDiskQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new AlbumDiskQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\PlaylistLocalplayQuery
                                                                        Open

                                                                                        $this->queryType = new PlaylistLocalplayQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\PlaylistMediaQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new PlaylistMediaQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\PvmsgQuery
                                                                        Open

                                                                                        $this->queryType = new PvmsgQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\SongPreviewQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new SongPreviewQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                while ($data = Dba::fetch_assoc($db_results)) {
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\PodcastEpisodeQuery
                                                                        Open

                                                                                        return PodcastEpisodeQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\PodcastQuery
                                                                        Open

                                                                                        return PodcastQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\PlaylistQuery
                                                                        Open

                                                                                        $this->queryType = new PlaylistQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\PodcastQuery
                                                                        Open

                                                                                        $this->queryType = new PodcastQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                    $results    = Dba::fetch_assoc($db_results);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\SongQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new SongQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Invalid offset "tag" of array type array{}
                                                                        Open

                                                                                $tags = $this->_state['filter']['tag'] ?? '';
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\CatalogQuery
                                                                        Open

                                                                                        $this->queryType = new CatalogQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\LabelQuery
                                                                        Open

                                                                                        $this->queryType = new LabelQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\SongQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new SongQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\SongQuery
                                                                        Open

                                                                                        $this->queryType = new SongQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\LicenseQuery
                                                                        Open

                                                                                        return LicenseQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\BroadcastQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new BroadcastQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\ClipQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new ClipQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\MovieQuery
                                                                        Open

                                                                                        $this->queryType = new MovieQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\PodcastEpisodeQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new PodcastEpisodeQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\VideoQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new VideoQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                                                                        Open

                                                                                    debug_event(self::class, 'IGNORED set_sort ' . $this->get_type() . ': ' . $sort, 5);
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method fetch_assoc from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                while ($row = Dba::fetch_assoc($db_results)) {
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\MovieQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new MovieQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\PvmsgQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new PvmsgQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method read from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                    $db_results = Dba::read($sql, array(session_id(), $this->id));
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method get_user_filter from undeclared class \Ampache\Repository\Model\Catalog
                                                                        Open

                                                                                            $dis = Catalog::get_user_filter($type, $this->user_id);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method write from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                    Dba::write($sql, array($data, session_id(), $browse_id));
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\PersonalVideoQuery
                                                                        Open

                                                                                        return PersonalVideoQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\CatalogQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new CatalogQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\ClipQuery
                                                                        Open

                                                                                        $this->queryType = new ClipQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\PlaylistSearchQuery
                                                                        Open

                                                                                        $this->queryType = new PlaylistSearchQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\ShareQuery
                                                                        Open

                                                                                        $this->queryType = new ShareQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\TvshowEpisodeQuery
                                                                        Open

                                                                                        $this->queryType = new TvshowEpisodeQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\TvshowQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new TvshowQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\UserQuery
                                                                        Open

                                                                                        $this->queryType = new UserQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method get_enable_filter from undeclared class \Ampache\Repository\Model\Catalog
                                                                        Open

                                                                                    $dis = Catalog::get_enable_filter($type, '`' . $type . '`.`id`');
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\LiveStreamQuery
                                                                        Open

                                                                                        return LiveStreamQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\VideoQuery
                                                                        Open

                                                                                        return VideoQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\LicenseQuery
                                                                        Open

                                                                                        $this->queryType = new LicenseQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\PersonalVideoQuery
                                                                        Open

                                                                                        $this->queryType = new PersonalVideoQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\TvshowSeasonQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new TvshowSeasonQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\PlaylistMediaQuery
                                                                        Open

                                                                                        return PlaylistMediaQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\PlaylistSearchQuery
                                                                        Open

                                                                                        return PlaylistSearchQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\SmartplaylistQuery
                                                                        Open

                                                                                        return SmartPlaylistQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\TagQuery
                                                                        Open

                                                                                        return TagQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\TvshowSeasonQuery
                                                                        Open

                                                                                        return TvshowSeasonQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\DemocraticQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new DemocraticQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\LiveStreamQuery
                                                                        Open

                                                                                        $this->queryType = new LiveStreamQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\SmartplaylistQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new SmartPlaylistQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\SmartplaylistQuery
                                                                        Open

                                                                                        $this->queryType = new SmartPlaylistQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\TvshowQuery
                                                                        Open

                                                                                        $this->queryType = new TvshowQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\UserQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new UserQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\VideoQuery
                                                                        Open

                                                                                        $this->queryType = new VideoQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\WantedQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new WantedQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method read from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                $db_results = Dba::read($sql);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method write from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                        Dba::write($sql, array($data, session_id(), $browse_id));
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\PlaylistSearchQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new PlaylistSearchQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\PlaylistQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new PlaylistQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\SongPreviewQuery
                                                                        Open

                                                                                        $this->queryType = new SongPreviewQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\TagQuery
                                                                        Open

                                                                                        $this->queryType = new TagQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Suspicious type null of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                                                        Open

                                                                                    $key .= '_' . $this->_state['extended_key_name'];
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\PlaylistLocalplayQuery
                                                                        Open

                                                                                        return PlaylistLocalplayQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\ShareQuery
                                                                        Open

                                                                                        return ShareQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\ArtistQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new ArtistQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\LiveStreamQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new LiveStreamQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\PodcastEpisodeQuery
                                                                        Open

                                                                                        $this->queryType = new PodcastEpisodeQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method escape from undeclared class \Ampache\Module\System\Dba
                                                                        Open

                                                                                        $object_id = Dba::escape($object_id);
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\MovieQuery
                                                                        Open

                                                                                        return MovieQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\TvshowQuery
                                                                        Open

                                                                                        return TvshowQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\WantedQuery
                                                                        Open

                                                                                        return WantedQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\TagQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new TagQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\TvshowSeasonQuery
                                                                        Open

                                                                                        $this->queryType = new TvshowSeasonQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Reference to constant FILTERS from undeclared class \Ampache\Module\Database\Query\UserQuery
                                                                        Open

                                                                                        return UserQuery::FILTERS;
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Call to method __construct from undeclared class \Ampache\Module\Database\Query\AlbumQuery
                                                                        Open

                                                                                        $this->queryType = new AlbumQuery();
                                                                        Severity: Critical
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\LabelQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new LabelQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\ShareQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new ShareQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        Assigning \Ampache\Module\Database\Query\TvshowEpisodeQuery to property but \Ampache\Repository\Model\Query->queryType is \Ampache\Module\Database\Query\QueryInterface|null
                                                                        Open

                                                                                        $this->queryType = new TvshowEpisodeQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phan

                                                                        The parameter $query_id is not named in camelCase.
                                                                        Open

                                                                            public function __construct($query_id = 0, $cached = true)
                                                                            {
                                                                                $sid = session_id();
                                                                        
                                                                                if (!$cached) {
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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_id is not named in camelCase.
                                                                        Open

                                                                            private function _logic_filter($object_id): bool
                                                                            {
                                                                                return true; // TODO, this must be old so probably not needed
                                                                            }
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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

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

                                                                            public $id;
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.php by phpmd

                                                                        ShortVariable

                                                                        Since: 0.2

                                                                        Detects when a field, local, or parameter has a very short name.

                                                                        Example

                                                                        class Something {
                                                                            private $q = 15; // VIOLATION - Field
                                                                            public static function main( array $as ) { // VIOLATION - Formal
                                                                                $r = 20 + $this->q; // VIOLATION - Local
                                                                                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                                                                    $r += $this->q;
                                                                                }
                                                                            }
                                                                        }

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

                                                                        The parameter $custom_base is not named in camelCase.
                                                                        Open

                                                                            public function set_type($type, $custom_base = ''): void
                                                                            {
                                                                                switch ($type) {
                                                                                    case 'album':
                                                                                        $this->queryType = new AlbumQuery();
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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_number is not named in camelCase.
                                                                        Open

                                                                            public function set_catalog($catalog_number): void
                                                                            {
                                                                                $this->catalog = $catalog_number;
                                                                            }
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 $custom_base is not named in camelCase.
                                                                        Open

                                                                            private function _set_base_sql($force = false, $custom_base = ''): void
                                                                            {
                                                                                // Only allow it to be set once
                                                                                if (!empty((string)$this->_state['base']) && !$force) {
                                                                                    return;
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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 function save_objects($object_ids): bool
                                                                            {
                                                                                // Saving these objects has two operations, one holds it in
                                                                                // a local variable and then second holds it in a row in the
                                                                                // tmp_browse table
                                                                        Severity: Minor
                                                                        Found in src/Repository/Model/Query.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

                                                                        Method name "_get_having_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_having_sql(): string

                                                                        Method name "_get_group_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_group_sql(): string

                                                                        Property name "$_state" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            protected $_state = array(

                                                                        Method name "_serialize" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private static function _serialize($data): string

                                                                        Method name "_get_filter_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_filter_sql(): string

                                                                        Method name "_get_join_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_join_sql(): string

                                                                        Method name "_logic_filter" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _logic_filter($object_id): bool

                                                                        Method name "_get_select" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_select(): string

                                                                        Method name "_get_sort_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_sort_sql(): string

                                                                        Method name "_sql_sort" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _sql_sort($field, $order): string

                                                                        Method name "_post_process" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _post_process($data): array

                                                                        Method name "_get_base_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_base_sql(): string

                                                                        Method name "_get_limit_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_limit_sql(): string

                                                                        Method name "_get_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _get_sql($limit = true): string

                                                                        Method name "_set_base_sql" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _set_base_sql($force = false, $custom_base = ''): void

                                                                        Property name "$_cache" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            protected $_cache;

                                                                        Method name "_resort_objects" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _resort_objects(): bool

                                                                        Method name "_unserialize" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private static function _unserialize($data)

                                                                        Method name "_sql_filter" should not be prefixed with an underscore to indicate visibility
                                                                        Open

                                                                            private function _sql_filter($filter, $value): string

                                                                        Expected 0 spaces after opening bracket; newline found
                                                                        Open

                                                                                if (

                                                                        There are no issues that match your filters.

                                                                        Category
                                                                        Status