ampache/ampache

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

Summary

Maintainability
F
2 wks
Test Coverage

File Upnp_Api.php has 1534 lines of code (exceeds 500 allowed). Consider refactoring.
Open

<?php

declare(strict_types=0);

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

    Function _musicChilds has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function _musicChilds($prmPath, $prmQuery, $start, $count): array
        {
            $mediaItems = array();
            $maxCount   = 0;
            $queryData  = array();
    Severity: Minor
    Found in src/Module/Api/Upnp_Api.php - About 1 day to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function createDIDL has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function createDIDL($prmItems, $filterValue): DOMDocument
        {
            $xmlDoc               = new DOMDocument('1.0' /*, 'utf-8'*/);
            $xmlDoc->formatOutput = true; // Note: other players don't seem to do this
            // Create root element and add namespaces:
    Severity: Minor
    Found in src/Module/Api/Upnp_Api.php - About 1 day to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function _musicMetadata has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function _musicMetadata($prmPath): ?array
        {
            $root    = 'amp://music';
            $pathreq = explode('/', $prmPath);
            if ($pathreq[0] == '' && count($pathreq) > 0) {
    Severity: Minor
    Found in src/Module/Api/Upnp_Api.php - About 6 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function parseUPnPRequest has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function parseUPnPRequest($prmRequest): array
        {
            $retArr = array();
            $reader = new XMLReader();
            $result = $reader->XML($prmRequest);
    Severity: Minor
    Found in src/Module/Api/Upnp_Api.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

    Upnp_Api has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Upnp_Api
    {
        /**
         * UPnP classes:
         * object.item.audioItem
    Severity: Minor
    Found in src/Module/Api/Upnp_Api.php - About 5 hrs to fix

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

          private static function parse_upnp_searchcriteria($query, $type): array
          {
              // Transforms a upnp search query into an Ampache search query
              $upnp_translations = array(
                  array('upnp:class = "object.container.album.musicAlbum"', 'album'),
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.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

      Function _videoChilds has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function _videoChilds($prmPath, $prmQuery, $start, $count): array
          {
              $mediaItems = array();
              $maxCount   = 0;
              $queryData  = array();
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.php - About 4 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function _videoMetadata has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function _videoMetadata($prmPath): ?array
          {
              $root    = 'amp://video';
              $pathreq = explode('/', $prmPath);
              if ($pathreq[0] == '' && count($pathreq) > 0) {
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.php - About 4 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

      The class Upnp_Api has 15 public methods. Consider refactoring Upnp_Api to keep number of public methods under 10.
      Open

      class Upnp_Api
      {
          /**
           * UPnP classes:
           * object.item.audioItem
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.php by phpmd

      TooManyPublicMethods

      Since: 0.1

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

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

      Example

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

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

      class Upnp_Api
      {
          /**
           * UPnP classes:
           * object.item.audioItem
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.php by phpmd

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

      class Upnp_Api
      {
          /**
           * UPnP classes:
           * object.item.audioItem
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.php by phpmd

      TooManyMethods

      Since: 0.1

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

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

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

      Example

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

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

          public static function _callSearch($criteria, $filter, $start, $count): array
          {
              $type = self::parse_upnp_filter($filter);
              $data = self::parse_upnp_searchcriteria($criteria, $type);
              debug_event(self::class, 'Dumping search data: ' . var_export($data, true), 5);
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.php - About 2 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          public static function discovery_request($data, $address): void
          {
              // Process a discovery request.  The response must be sent to the address specified by $remote
              $headers = self::get_headers($data);
              if (self::SSDP_DEBUG) {
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.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 parse_upnp_search_term has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function parse_upnp_search_term($query, $context): array
          {
              //echo "Search term ", $query, "\n";
              $tok = str_getcsv($query, ' ');
              //for ($i = 0; $i<sizeof($tok); $i++) {
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.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 gettokens has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function gettokens($str): array
          {
              $tokens        = array();
              $nospacetokens = array();
              // put the string into lowercase
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.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 sddpSend has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function sddpSend($delay = 15, $host = "239.255.255.250", $port = 1900, $prefix = "NT", $alive = true): void
      Severity: Minor
      Found in src/Module/Api/Upnp_Api.php - About 35 mins to fix

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

                $prmDIDL,
                $prmNumRet,
                $prmTotMatches,
                $prmResponseType = 'u:BrowseResponse',
                $prmUpdateID = '0'
        Severity: Minor
        Found in src/Module/Api/Upnp_Api.php - About 35 mins to fix

          The class Upnp_Api has 1938 lines of code. Current threshold is 1000. Avoid really long classes.
          Open

          class Upnp_Api
          {
              /**
               * UPnP classes:
               * object.item.audioItem
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

          The method _musicChilds() has an NPath complexity of 264. The configured NPath complexity threshold is 200.
          Open

              public static function _musicChilds($prmPath, $prmQuery, $start, $count): array
              {
                  $mediaItems = array();
                  $maxCount   = 0;
                  $queryData  = array();
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

          NPathComplexity

          Since: 0.1

          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

          Example

          class Foo {
              function bar() {
                  // lots of complicated code
              }
          }

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

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

              public static function createDIDL($prmItems, $filterValue): DOMDocument
              {
                  $xmlDoc               = new DOMDocument('1.0' /*, 'utf-8'*/);
                  $xmlDoc->formatOutput = true; // Note: other players don't seem to do this
                  // Create root element and add namespaces:
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

          The method parse_upnp_searchcriteria() has an NPath complexity of 8064. The configured NPath complexity threshold is 200.
          Open

              private static function parse_upnp_searchcriteria($query, $type): array
              {
                  // Transforms a upnp search query into an Ampache search query
                  $upnp_translations = array(
                      array('upnp:class = "object.container.album.musicAlbum"', 'album'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

          NPathComplexity

          Since: 0.1

          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

          Example

          class Foo {
              function bar() {
                  // lots of complicated code
              }
          }

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

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

              public static function _musicMetadata($prmPath): ?array
              {
                  $root    = 'amp://music';
                  $pathreq = explode('/', $prmPath);
                  if ($pathreq[0] == '' && count($pathreq) > 0) {
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

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

              public static function _videoMetadata($prmPath): ?array
              {
                  $root    = 'amp://video';
                  $pathreq = explode('/', $prmPath);
                  if ($pathreq[0] == '' && count($pathreq) > 0) {
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

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

              private static function parse_upnp_searchcriteria($query, $type): array
              {
                  // Transforms a upnp search query into an Ampache search query
                  $upnp_translations = array(
                      array('upnp:class = "object.container.album.musicAlbum"', 'album'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

          The method createDIDL() has an NPath complexity of 4599. The configured NPath complexity threshold is 200.
          Open

              public static function createDIDL($prmItems, $filterValue): DOMDocument
              {
                  $xmlDoc               = new DOMDocument('1.0' /*, 'utf-8'*/);
                  $xmlDoc->formatOutput = true; // Note: other players don't seem to do this
                  // Create root element and add namespaces:
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

          NPathComplexity

          Since: 0.1

          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

          Example

          class Foo {
              function bar() {
                  // lots of complicated code
              }
          }

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

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

              public static function _videoChilds($prmPath, $prmQuery, $start, $count): array
              {
                  $mediaItems = array();
                  $maxCount   = 0;
                  $queryData  = array();
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

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

              public static function _musicChilds($prmPath, $prmQuery, $start, $count): array
              {
                  $mediaItems = array();
                  $maxCount   = 0;
                  $queryData  = array();
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

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

              public static function parseUPnPRequest($prmRequest): array
              {
                  $retArr = array();
                  $reader = new XMLReader();
                  $result = $reader->XML($prmRequest);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 createDIDL() has a Cyclomatic Complexity of 37. The configured cyclomatic complexity threshold is 10.
          Open

              public static function createDIDL($prmItems, $filterValue): DOMDocument
              {
                  $xmlDoc               = new DOMDocument('1.0' /*, 'utf-8'*/);
                  $xmlDoc->formatOutput = true; // Note: other players don't seem to do this
                  // Create root element and add namespaces:
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 parse_upnp_search_term() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
          Open

              private static function parse_upnp_search_term($query, $context): array
              {
                  //echo "Search term ", $query, "\n";
                  $tok = str_getcsv($query, ' ');
                  //for ($i = 0; $i<sizeof($tok); $i++) {
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 discovery_request() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
          Open

              public static function discovery_request($data, $address): void
              {
                  // Process a discovery request.  The response must be sent to the address specified by $remote
                  $headers = self::get_headers($data);
                  if (self::SSDP_DEBUG) {
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 _musicChilds() has a Cyclomatic Complexity of 49. The configured cyclomatic complexity threshold is 10.
          Open

              public static function _musicChilds($prmPath, $prmQuery, $start, $count): array
              {
                  $mediaItems = array();
                  $maxCount   = 0;
                  $queryData  = array();
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 _videoMetadata() has a Cyclomatic Complexity of 23. The configured cyclomatic complexity threshold is 10.
          Open

              public static function _videoMetadata($prmPath): ?array
              {
                  $root    = 'amp://video';
                  $pathreq = explode('/', $prmPath);
                  if ($pathreq[0] == '' && count($pathreq) > 0) {
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 gettokens() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
          Open

              private static function gettokens($str): array
              {
                  $tokens        = array();
                  $nospacetokens = array();
                  // put the string into lowercase
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 _musicMetadata() has a Cyclomatic Complexity of 33. The configured cyclomatic complexity threshold is 10.
          Open

              public static function _musicMetadata($prmPath): ?array
              {
                  $root    = 'amp://music';
                  $pathreq = explode('/', $prmPath);
                  if ($pathreq[0] == '' && count($pathreq) > 0) {
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 _videoChilds() has a Cyclomatic Complexity of 22. The configured cyclomatic complexity threshold is 10.
          Open

              public static function _videoChilds($prmPath, $prmQuery, $start, $count): array
              {
                  $mediaItems = array();
                  $maxCount   = 0;
                  $queryData  = array();
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 parse_upnp_searchcriteria() has a Cyclomatic Complexity of 25. The configured cyclomatic complexity threshold is 10.
          Open

              private static function parse_upnp_searchcriteria($query, $type): array
              {
                  // Transforms a upnp search query into an Ampache search query
                  $upnp_translations = array(
                      array('upnp:class = "object.container.album.musicAlbum"', 'album'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 _callSearch() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
          Open

              public static function _callSearch($criteria, $filter, $start, $count): array
              {
                  $type = self::parse_upnp_filter($filter);
                  $data = self::parse_upnp_searchcriteria($criteria, $type);
                  debug_event(self::class, 'Dumping search data: ' . var_export($data, true), 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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

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

          class Upnp_Api
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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.

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

              public static function _musicMetadata($prmPath): ?array
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

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

              public static function _musicChilds($prmPath, $prmQuery, $start, $count): array
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

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

              private static function parse_upnp_searchcriteria($query, $type): array
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

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

              public static function _videoMetadata($prmPath): ?array
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

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

              public static function createDIDL($prmItems, $filterValue): DOMDocument
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

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

              public static function _callSearch($criteria, $filter, $start, $count): array
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

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

              public static function parseUPnPRequest($prmRequest): array
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

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

              public static function _videoChilds($prmPath, $prmQuery, $start, $count): array
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

          This function "_musicChilds" has 209 lines, which is greater than the 150 lines authorized. Split it into smaller functions.
          Open

              public static function _musicChilds($prmPath, $prmQuery, $start, $count): array
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php by sonar-php

          A function that grows too large tends to aggregate too many responsibilities.

          Such functions inevitably become harder to understand and therefore harder to maintain.

          Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.

          Those smaller functions will not only be easier to understand, but also probably easier to test.

          This function "_musicMetadata" has 180 lines, which is greater than the 150 lines authorized. Split it into smaller functions.
          Open

              public static function _musicMetadata($prmPath): ?array
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php by sonar-php

          A function that grows too large tends to aggregate too many responsibilities.

          Such functions inevitably become harder to understand and therefore harder to maintain.

          Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.

          Those smaller functions will not only be easier to understand, but also probably easier to test.

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

          class Upnp_Api
          {
              /**
               * UPnP classes:
               * object.item.audioItem
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 parse_upnp_searchcriteria uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

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

                      } else {
                          $ndItem = $xmlDoc->createElement('item');
                      }
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 parse_upnp_searchcriteria uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      $data['operator'] = 'error'; // Should really be an error operator/return
          
                      return $data; // go no further because we can't handle the combination of and and or
                  }
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 discovery_request uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          if (self::SSDP_DEBUG) {
                              debug_event(self::class, 'ST header not for a service we provide [' . $actst . ']', 5);
                          }
                      }
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 parse_upnp_search_term uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

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

                  } else {
                      $strHeader .= 'NTS: ssdp:byebye' . "\r\n";
                      $delay = 2;
                  }
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 gettokens uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

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

                  } else {
                      $data['type'] = $tokens[0];
                      $tokens[0]    = '';
                  }
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 isinFilter uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      $testKey = $keytoCheck;
                  }
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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 "playlists" 3 times.
          Open

                      case 'playlists':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "object.item.imageItem" 8 times.
          Open

                      'gif' => array('class' => 'object.item.imageItem', 'mime' => 'http-get:*:image/gif:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "operator" 7 times.
          Open

                              $term['operator'] = 4;
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "http_host" 3 times.
          Open

                  $key  = 'ampache_' . AmpConfig::get('http_host');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "bitrate" 3 times.
          Open

                              case 'bitrate':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "nrAudioChannels" 3 times.
          Open

                              case 'nrAudioChannels':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "urn:schemas-upnp-org:service:ContentDirectory:1" 3 times.
          Open

                      } elseif ($headers['st'] == 'urn:schemas-upnp-org:service:ContentDirectory:1') {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "http-get:*:video/mpeg2ts:*" 7 times.
          Open

                      'm2t' => array('class' => 'object.item.videoItem', 'mime' => 'http-get:*:video/mpeg2ts:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "searchable" 4 times.
          Open

                              case 'searchable':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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_videos" 3 times.
          Open

                      case 'personal_videos':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "upnp:genre" 3 times.
          Open

                          case 'upnp:genre':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "childCount" 23 times.
          Open

                              case 'childCount':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "clips" 3 times.
          Open

                      case 'clips':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "upnp:class" 29 times.
          Open

                          $item['upnp:class'] == 'object.container' ||
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "239.255.255.250" 3 times.
          Open

              private static function udpSend($buf, $delay = 15, $host = "239.255.255.250", $port = 1900): void
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "sampleFrequency" 3 times.
          Open

                              case 'sampleFrequency':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "object.item.audioItem" 16 times.
          Open

                      'wav' => array('class' => 'object.item.audioItem', 'mime' => 'http-get:*:audio/x-wav:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "albums" 3 times.
          Open

                      case 'albums':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "artists" 3 times.
          Open

                      case 'artists':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

                                      'childCount' => $counts['live_stream'],
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

                  //echo "Search term ", $query, "\n";
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "upnp:albumArtURI" 5 times.
          Open

                      'upnp:albumArtURI' => $art_url,
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "ruletype" 8 times.
          Open

                              $term['ruletype'] = 'title';
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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" 4 times.
          Open

                                      'childCount' => $counts['playlist'],
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "protocolInfo" 6 times.
          Open

                              case 'protocolInfo':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "action" 5 times.
          Open

                                  $retArr['action'] = 'browse';
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "require_session" 5 times.
          Open

                  $api_session = (AmpConfig::get('require_session')) ? Stream::get_session() : false;
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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, 'checking '.$testKey.' in '.var_export($filt, true), 5);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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

                  //    $str = strtolower($str);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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

                  //for ($i = 0; $i<sizeof($tokens); $i++) {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "smartplaylists" 3 times.
          Open

                      case 'smartplaylists':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "movies" 3 times.
          Open

                      case 'movies':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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, 'Dumping $search results: '.var_export( $ids, true ), 5);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

                      //$line = str_replace( ' ', '', $line );
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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

                  //for ($i = 0; $i<sizeof($tok); $i++) {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "artist" 5 times.
          Open

                                      'childCount' => $counts['artist'],
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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_streams" 3 times.
          Open

                      case 'live_streams':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "USN: uuid:" 5 times.
          Open

                  $rootDevice .= 'USN: uuid:' . $uuidStr . '::upnp:rootdevice' . "\r\n" . "\r\n";
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

                  //if( strpos( $filter, 'upnp:album' ) ){
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "upnp:album" 3 times.
          Open

                          case 'upnp:album':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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, $album->get_fullname(), 5);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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, 'replace <<< ' . $title, 5);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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"

          Define a constant instead of duplicating this literal "dc:title" 26 times.
          Open

                                      'dc:title' => T_('Artists'),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "object.container" 21 times.
          Open

                          $item['upnp:class'] == 'object.container' ||
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "http-get:*:image/jpeg:*" 3 times.
          Open

                      'jpg' => array('class' => 'object.item.imageItem', 'mime' => 'http-get:*:image/jpeg:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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" 8 times.
          Open

                                      'childCount' => $counts['album'],
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

                  //$strHeader .= 'NTS: ssdp:alive' . "\r\n";
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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, 'slice: ' . $maxCount . "   " . $start . "    " . $count, 5);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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"

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

                              case 'duration':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "http-get:*:video/mp4:*" 3 times.
          Open

                      'mp4' => array('class' => 'object.item.videoItem', 'mime' => 'http-get:*:video/mp4:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "object.item.unknownItem" 4 times.
          Open

                      'upnp:class' => (isset($arrFileType['class'])) ? $arrFileType['class'] : 'object.item.unknownItem',
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "tvshows" 3 times.
          Open

                      case 'tvshows':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

                          #             echo 'discovery response for ssdp:all';
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "restricted" 27 times.
          Open

                              case 'restricted':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "songs" 3 times.
          Open

                      case 'songs':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

                      //echo 'BARELINE:'.$line.'&'.count($tokens).PHP_EOL;
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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

                  //echo 'DELAYTIME: [' . $headers['mx'] . ']' . PHP_EOL;
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 ($data['type']) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "http-get:*:video/mpeg:*" 6 times.
          Open

                      'mpg' => array('class' => 'object.item.videoItem', 'mime' => 'http-get:*:video/mpeg:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "false" 7 times.
          Open

                      'restricted' => 'false',
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "http-get:*:audio/mpeg:*" 4 times.
          Open

                      'mpa' => array('class' => 'object.item.audioItem', 'mime' => 'http-get:*:audio/mpeg:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "parentID" 27 times.
          Open

                              case 'parentID':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "podcasts" 3 times.
          Open

                      case 'podcasts':
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "object.item.videoItem" 29 times.
          Open

                      'asf' => array('class' => 'object.item.videoItem', 'mime' => 'http-get:*:video/x-ms-asf:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "podcast" 3 times.
          Open

                                      'childCount' => $counts['podcast'],
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "class" 62 times.
          Open

                      'upnp:class' => (isset($arrFileType['class'])) ? $arrFileType['class'] : 'object.item.unknownItem',
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 "http-get:*:video/mpeg2:*" 4 times.
          Open

                      'mpeg2' => array('class' => 'object.item.videoItem', 'mime' => 'http-get:*:video/mpeg2:*',),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

                  //   echo "\nNUM_AND ", $num_and;
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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

                  // for ($i = 0; $i<sizeof($tokens); $i++) {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.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 ($reader->localName) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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 (count($pathreq)) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.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

          TODO found
          Open

                  // sometimes here comes only one single item, not an array. Convert it to array. (TODO - UGLY)
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by fixme

          TODO found
          Open

                  // TODO patched out for now: creates problems in search results
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by fixme

          XXX found
          Open

                      'restricted' => 'false', // XXX
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by fixme

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

                              debug_event(self::class, 'ST header not for a service we provide [' . $actst . ']', 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Album
          Open

                                      $album = new Album($album_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\TvShow
          Open

                                  if ($tvshow->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Album
          Open

                                  if ($album->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                                      $video->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Clip
          Open

                                  $video = new Clip((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, 'M-SEARCH MAN header not understood [' . $headers['man'] . ']', 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                  $counts = Catalog::get_server_counts(0);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Artist
          Open

                                  if ($artist->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                              $catalogs = Catalog::get_catalogs();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Song
          Open

                                              $song->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                                  $season = new TVShow_Season((int)$pathreq[2]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                                  if (isset($episode->id)) {
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Song
          Open

                                              $song = new Song($item['object_id']);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                                  $radio = new Live_Stream($radio_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method getEpisodeIds from undeclared class \Ampache\Repository\Model\Podcast
          Open

                                      $episodes = $podcast->getEpisodeIds();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                          debug_event(self::class, $item, 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Album
          Open

                                  if (isset($album->id)) {
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_items from undeclared class \Ampache\Repository\Model\Search
          Open

                                      $items              = $playlist->get_items();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, 'HEADERS:' . var_export($headers, true), 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                          debug_event(self::class, 'item is not array', 2);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                                  $radio = new Live_Stream((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                                  if ($radio->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to deprecated function \Ampache\Module\Api\Upnp_Api::getAlbumRepository() defined at /code/src/Module/Api/Upnp_Api.php:1979
          Open

                                      $album_ids              = static::getAlbumRepository()->getAlbumByArtist($artist->id);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Album
          Open

                                          $album->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_searches from undeclared class \Ampache\Repository\Model\Search
          Open

                                  $searches              = Search::get_searches();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $counts = count(Catalog::get_tvshows());
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                                  $video = new TVShow_Episode((int)$pathreq[3]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, $str, 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, $reader->localName . ' ' . (string) $reader->nodeType . ' ' . (string) XMLReader::ELEMENT . ' ' . (string) $reader->isEmptyElement, 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Song
          Open

                                  if ($song->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                  debug_event(self::class, 'MusicChilds: [' . $prmPath . '] [' . $prmQuery . ']' . '[' . $start . '] [' . $count . ']', 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                  debug_event(self::class, 'MusicChilds4: [' . $pathreq[0] . ']', 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to deprecated function \Ampache\Module\Api\Upnp_Api::getSongRepository() defined at /code/src/Module/Api/Upnp_Api.php:1969
          Open

                                      $song_ids              = static::getSongRepository()->getByAlbum($album->id);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                                  $radio->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                                          $episode = new Podcast_Episode($episode_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Artist
          Open

                                      $artist->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to deprecated function \Ampache\Module\Api\Upnp_Api::getPodcastRepository() defined at /code/src/Module/Api/Upnp_Api.php:1999
          Open

                                  $podcast = self::getPodcastRepository()->findById((int)$pathreq[1]);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Search
          Open

                                      $playlist     = new Search($search['id'], 'song');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Search
          Open

                                  if ($playlist->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                                      $season->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Search
          Open

                                  $playlist = new Search((int)$pathreq[1], 'song');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Search
          Open

                                      $playlist->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                                      $episode->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Artist
          Open

                                      $album_ids              = static::getAlbumRepository()->getAlbumByArtist($artist->id);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Song
          Open

                                          $song->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Song
          Open

                                              $song = new Song($item['object_id']);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Search
          Open

                                  $playlist = new Search((int)$pathreq[1], 'song');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                                  if ($video->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $counts = Catalog::get_videos_count(null, 'clip');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Album
          Open

                                      $album->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Album
          Open

                                          $album = new Album($album_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Album
          Open

                                      $album->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Argument 2 (value) is int but \DOMDocument::createElement() takes string
          Open

                  $ndNumRet = $doc->createElement('NumberReturned', $prmNumRet);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Song
          Open

                                          $song = new Song($song_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Album
          Open

                                  $album = new Album((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Search
          Open

                                  if ($playlist->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Artist
          Open

                                  $artist = new Artist((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\TvShow
          Open

                                      $tvshow->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Possibly zero references to use statement for classlike/namespace Podcast (\Ampache\Repository\Model\Podcast)
          Open

          use Ampache\Repository\Model\Podcast;
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, 'Sending response to: ' . $addr[0] . ':' . $addr[1] . PHP_EOL . $response, 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, '(Sent)', 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Possibly zero references to use statement for classlike/namespace User (\Ampache\Repository\Model\User)
          Open

          use Ampache\Repository\Model\User;
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                  $counts = Catalog::get_server_counts(0);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                                  $episode = new Podcast_Episode((int)$pathreq[2]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Album
          Open

                                          if ($album->isNew()) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to deprecated function \Ampache\Module\Api\Upnp_Api::getPodcastRepository() defined at /code/src/Module/Api/Upnp_Api.php:1999
          Open

                                  $podcast = self::getPodcastRepository()->findById((int)$pathreq[1]);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                                  if ($season->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $album_ids              = Catalog::get_albums($count, $start);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Artist
          Open

                                  $artist = new Artist((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Album
          Open

                                  $album = new Album((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Song
          Open

                                      $song->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $artists              = Catalog::get_artists(null, $count, $start);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Album
          Open

                                      $song_ids              = static::getSongRepository()->getByAlbum($album->id);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Artist
          Open

                                  if ($artist->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to deprecated function \Ampache\Module\Api\Upnp_Api::getLiveStreamRepository() defined at /code/src/Module/Api/Upnp_Api.php:1989
          Open

                              $radios = static::getLiveStreamRepository()->findAll(
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                                          $episode->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, 'XML reader class setup failed', 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Song
          Open

                                  $song = new Song((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                                      $radio->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Album
          Open

                                      if ($album->isNew()) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $catalog = Catalog::create_from_id($catalog_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Song
          Open

                                              $song->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $podcasts              = Catalog::get_podcasts();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\TvShow
          Open

                                  $tvshow = new TvShow((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, 'Discovery request from ' . $address, 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                  debug_event(self::class, 'Token ' . var_export($tok, true), 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property album_count from undeclared class \Ampache\Repository\Model\Artist
          Open

                      'childCount' => $artist->album_count,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Clip
          Open

                                  if ($video->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_artist from undeclared class \Ampache\Repository\Model\Song
          Open

                      'dc:creator' => self::_replaceSpecialSymbols($song->f_artist),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Parameter $radio has undeclared type \Ampache\Repository\Model\Live_Stream
          Open

              public static function _itemLiveStream($radio, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                              $videos              = Catalog::get_videos(null, 'clip');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                      'id' => 'amp://music/live_streams/' . $radio->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Artist
          Open

                              if ($artist->isNew()) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                      'dc:title' => self::_replaceSpecialSymbols($video->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_items from undeclared class \Ampache\Repository\Model\Search
          Open

                      'childCount' => count($playlist->get_items()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                      'dc:title' => self::_replaceSpecialSymbols($video->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Parameter $song has undeclared type \Ampache\Repository\Model\Song
          Open

              public static function _itemSong($song, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\Video
          Open

                      'dc:title' => self::_replaceSpecialSymbols($video->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_album from undeclared class \Ampache\Repository\Model\Song
          Open

                      'upnp:album' => self::_replaceSpecialSymbols($song->f_album),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property tags from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                      'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property size from undeclared class \Ampache\Repository\Model\Clip
          Open

                      'size' => $video->size,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property type from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                  $arrFileType    = $fileTypesByExt[$video->type];
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method play_url from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                      $ret['res']          = $episode->play_url('', 'api');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\TvShow
          Open

                                  $tvshow = new TvShow((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                                          $season = new TVShow_Season($season_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                              $videos              = Catalog::get_videos(null, 'personal_video');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Album
          Open

                      'id' => 'amp://music/albums/' . $album->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Parameter $playlist has undeclared type \Ampache\Repository\Model\Search
          Open

              private static function _itemSmartPlaylist($playlist, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                      'id' => $parent . '/' . $video->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_time_h from undeclared class \Ampache\Repository\Model\Movie
          Open

                      'duration' => $video->f_time_h . '.0',
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                                  if ($video->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $tvshows                  = Catalog::get_tvshows();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Artist
          Open

                              $artist->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to undeclared property \Ampache\Repository\Model\Playlist->id
          Open

                      'id' => 'amp://music/playlists/' . $playlist->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property comment from undeclared class \Ampache\Repository\Model\Song
          Open

                      'description' => self::_replaceSpecialSymbols($song->comment),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\TvShow
          Open

                      'id' => 'amp://video/tvshows/' . $tvshow->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property type from undeclared class \Ampache\Repository\Model\Movie
          Open

                  $arrFileType    = $fileTypesByExt[$video->type];
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                      'id' => $parent . '/' . $video->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_episodes from undeclared class \Ampache\Repository\Model\Podcast
          Open

                      'childCount' => count($podcast->get_episodes()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Movie
          Open

                                  $video = new Movie((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Album
          Open

                              if ($album->isNew()) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Tag
          Open

                              $tag->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_fullname from undeclared class \Ampache\Repository\Model\Album
          Open

                      'dc:title' => self::_replaceSpecialSymbols($album->get_fullname()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property name from undeclared class \Ampache\Repository\Model\Search
          Open

                      'dc:title' => self::_replaceSpecialSymbols($playlist->name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $counts = Catalog::get_videos_count(null, 'movie');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Movie
          Open

                  $art_url     = Art::url($video->id, 'video', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                                      $video->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\Movie
          Open

                      'dc:title' => self::_replaceSpecialSymbols($video->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Artist
          Open

                              $artist = new Artist($artist_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Album
          Open

                              $album = new Album($album_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property type from undeclared class \Ampache\Repository\Model\Song
          Open

                  $arrFileType    = $fileTypesByExt[$song->type];
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property name from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                      'dc:title' => self::_replaceSpecialSymbols($radio->name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property tvshow from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                      'id' => 'amp://video/tvshows/' . $season->tvshow . '/' . $season->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                      'dc:title' => self::_replaceSpecialSymbols($season->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                  $art_url     = Art::url($video->id, 'video', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_time_h from undeclared class \Ampache\Repository\Model\Video
          Open

                      'duration' => $video->f_time_h . '.0',
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_fullname from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                      'dc:title' => self::_replaceSpecialSymbols($episode->get_fullname()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                              $videos              = Catalog::get_videos(null, 'movie');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Artist
          Open

                      'id' => 'amp://music/artists/' . $artist->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_fullname from undeclared class \Ampache\Repository\Model\Artist
          Open

                      'dc:title' => self::_replaceSpecialSymbols($artist->get_fullname()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Album
          Open

                  $art_url     = Art::url($album->id, 'album', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\TvShow
          Open

                      'dc:title' => self::_replaceSpecialSymbols($tvshow->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Clip
          Open

                      'id' => $parent . '/' . $video->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\Clip
          Open

                      'dc:title' => self::_replaceSpecialSymbols($video->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_time_h from undeclared class \Ampache\Repository\Model\Clip
          Open

                      'duration' => $video->f_time_h . '.0',
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property podcast from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                  $art_url     = Art::url($episode->podcast, 'podcast', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                      'id' => 'amp://music/podcasts/' . $episode->podcast . '/' . $episode->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property size from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                      $ret['size']         = $episode->size;
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to undeclared property \Ampache\Repository\Model\Playlist->name
          Open

                      'dc:title' => self::_replaceSpecialSymbols($playlist->name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_artist from undeclared class \Ampache\Repository\Model\Song
          Open

                      'upnp:artist' => self::_replaceSpecialSymbols($song->f_artist),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property codec from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                  $arrFileType    = $fileTypesByExt[$radio->codec];
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                  $art_url     = Art::url($video->id, 'video', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Video
          Open

                      'id' => $parent . '/' . $video->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method play_url from undeclared class \Ampache\Repository\Model\Video
          Open

                      'res' => $video->play_url('', 'api'),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Movie
          Open

                                      $video->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_seasons from undeclared class \Ampache\Repository\Model\TvShow
          Open

                                      $season_ids                  = $tvshow->get_seasons();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method run from undeclared class \Ampache\Repository\Model\Search
          Open

                  $ids = Search::run($data); // return a list of IDs
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property album from undeclared class \Ampache\Repository\Model\Song
          Open

                  $art_url     = Art::url($song->album, 'album', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property type from undeclared class \Ampache\Repository\Model\Clip
          Open

                  $arrFileType    = $fileTypesByExt[$video->type];
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property tags from undeclared class \Ampache\Repository\Model\Movie
          Open

                      'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method play_url from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                      'res' => $video->play_url('', 'api'),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_time_h from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                      'duration' => $video->f_time_h . '.0',
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property type from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                  $arrFileType    = (!empty($episode->type)) ? $fileTypesByExt[$episode->type] : array();
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property podcast from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                      'id' => 'amp://music/podcasts/' . $episode->podcast . '/' . $episode->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\Movie
          Open

                                  if ($video->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                                  $video = new Personal_Video((int)$pathreq[1]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\TvShow
          Open

                                  if ($tvshow->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                                          $season->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                  debug_event(self::class, 'Dumping search data: ' . var_export($data, true), 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                  debug_event(self::class, ' ' . (string) count($ids) . ' ids looking for type ' . $data['type'], 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Song
          Open

                              $song = new Song($song_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Tag
          Open

                              $tag = new Tag($tag_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property song_count from undeclared class \Ampache\Repository\Model\Album
          Open

                      'childCount' => $album->song_count,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property album_artist from undeclared class \Ampache\Repository\Model\Album
          Open

                      'upnp:albumArtist' => $album->album_artist,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

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

                                  $counts = Catalog::get_videos_count(null, 'personal_video');
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Song
          Open

                      'id' => 'amp://music/songs/' . $song->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Album
          Open

                              $album->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property type from undeclared class \Ampache\Repository\Model\Video
          Open

                  $arrFileType    = $fileTypesByExt[$video->type];
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Parameter $album has undeclared type \Ampache\Repository\Model\Album
          Open

              private static function _itemAlbum($album, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_display from undeclared class \Ampache\Repository\Model\Tag
          Open

                      'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property tags from undeclared class \Ampache\Repository\Model\Song
          Open

                      'upnp:genre' => Tag::get_display($song->tags, false, 'song'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method play_url from undeclared class \Ampache\Repository\Model\Movie
          Open

                      'res' => $video->play_url('', 'api'),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method play_url from undeclared class \Ampache\Repository\Model\Song
          Open

                      'res' => $song->play_url('', 'api', true), // For upnp, use local
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property size from undeclared class \Ampache\Repository\Model\Movie
          Open

                      'size' => $video->size,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property url from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                      'res' => $radio->url,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Clip
          Open

                  $art_url     = Art::url($video->id, 'video', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property tags from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                      'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Parameter $episode has undeclared type \Ampache\Repository\Model\Podcast_Episode
          Open

              private static function _itemPodcastEpisode($episode, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                                  $season = new TVShow_Season((int)$pathreq[2]);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_episodes from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                                      $episode_ids                  = $season->get_episodes();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Tag
          Open

                      'id' => 'amp://music/tags/' . $tag->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\Tag
          Open

                      'dc:title' => self::_replaceSpecialSymbols($tag->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Search
          Open

                      'id' => 'amp://music/playlists/' . $playlist->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_items from undeclared class \Ampache\Repository\Model\Search
          Open

                      'childCount' => count($playlist->get_items()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property name from undeclared class \Ampache\Repository\Model\Search
          Open

                      'dc:title' => self::_replaceSpecialSymbols($playlist->name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Live_Stream
          Open

                  $art_url     = Art::url($radio->id, 'live_stream', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_seasons from undeclared class \Ampache\Repository\Model\TvShow
          Open

                      'childCount' => count($tvshow->get_seasons()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Parameter $season has undeclared type \Ampache\Repository\Model\TVShow_Season
          Open

              private static function _itemTVShowSeason($season, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                      'id' => 'amp://video/tvshows/' . $season->tvshow . '/' . $season->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Movie
          Open

                      'id' => $parent . '/' . $video->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property tags from undeclared class \Ampache\Repository\Model\Video
          Open

                      'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_time_h from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                      $ret['duration']     = $episode->f_time_h . '.0';
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Clip
          Open

                                      $video->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method isNew from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                                  if ($season->isNew() === false) {
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Song
          Open

                              $song->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Parameter $artist has undeclared type \Ampache\Repository\Model\Artist
          Open

              private static function _itemArtist($artist, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Parameter $tag has undeclared type \Ampache\Repository\Model\Tag
          Open

              private static function _itemTag($tag, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_name from undeclared class \Ampache\Repository\Model\Song
          Open

                      'dc:title' => self::_replaceSpecialSymbols($song->f_name),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property addition_time from undeclared class \Ampache\Repository\Model\Song
          Open

                      'dc:date' => date("c", (int) $song->addition_time),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property size from undeclared class \Ampache\Repository\Model\Song
          Open

                      'size' => $song->size,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_time_h from undeclared class \Ampache\Repository\Model\Song
          Open

                      'duration' => $song->f_time_h . '.0',
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_episodes from undeclared class \Ampache\Repository\Model\TVShow_Season
          Open

                      'childCount' => count($season->get_episodes()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property size from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                      'size' => $video->size,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property size from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                      'size' => $video->size,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property f_time_h from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                      'duration' => $video->f_time_h . '.0',
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method __construct from undeclared class \Ampache\Repository\Model\Video
          Open

                                          $video = new Video($episode_id);
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method format from undeclared class \Ampache\Repository\Model\Video
          Open

                                          $video->format();
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property track from undeclared class \Ampache\Repository\Model\Song
          Open

                      'upnp:originalTrackNumber' => $song->track,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method play_url from undeclared class \Ampache\Repository\Model\TVShow_Episode
          Open

                      'res' => $video->play_url('', 'api'),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

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

                      debug_event(self::class, 'Search returned no hits', 5);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property album from undeclared class \Ampache\Repository\Model\Song
          Open

                              $parent       = 'amp://music/albums/' . (string) $song->album;
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Search
          Open

                      'id' => 'amp://music/smartplaylists/' . $playlist->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property bitrate from undeclared class \Ampache\Repository\Model\Song
          Open

                      'bitrate' => $song->bitrate,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property rate from undeclared class \Ampache\Repository\Model\Song
          Open

                      'sampleFrequency' => $song->rate,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property type from undeclared class \Ampache\Repository\Model\Personal_Video
          Open

                  $arrFileType    = $fileTypesByExt[$video->type];
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property tags from undeclared class \Ampache\Repository\Model\Clip
          Open

                      'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property size from undeclared class \Ampache\Repository\Model\Video
          Open

                      'size' => $video->size,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_fullname from undeclared class \Ampache\Repository\Model\Podcast
          Open

                      'dc:title' => self::_replaceSpecialSymbols($podcast->get_fullname()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method get_display from undeclared class \Ampache\Repository\Model\Tag
          Open

                      'upnp:genre' => Tag::get_display($song->tags, false, 'song'),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Video
          Open

                  $art_url     = Art::url($video->id, 'video', $api_session);
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method play_url from undeclared class \Ampache\Repository\Model\Clip
          Open

                      'res' => $video->play_url('', 'api'),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          Reference to instance property id from undeclared class \Ampache\Repository\Model\Podcast
          Open

                      'id' => 'amp://music/podcasts/' . $podcast->id,
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phan

          Call to method getPodcastName from undeclared class \Ampache\Repository\Model\Podcast_Episode
          Open

                      'upnp:album' => self::_replaceSpecialSymbols($episode->getPodcastName()),
          Severity: Critical
          Found in src/Module/Api/Upnp_Api.php by phan

          This branch's code block is the same as the block for the branch on line 261.
          Open

                      } elseif ($headers['st'] == 'urn:schemas-upnp-org:service:ConnectionManager:1') {
                          self::sendResponse($delaytime, $actst, $address);
                      } elseif ($headers['st'] == 'urn:schemas-upnp-org:service:ContentDirectory:1') {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php by sonar-php

          Having two cases in a switch statement or two branches in an if chain with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if chain they should be combined, or for a switch, one should fall through to the other.

          Noncompliant Code Example

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:  // Noncompliant; duplicates case 1's implementation
              doSomething();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThing();  // Noncompliant; duplicates first condition
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doOneMoreThing(); // Noncompliant; duplicates then-branch
          }
          
          var b = a ? 12 > 4 : 4;  // Noncompliant; always results in the same value
          

          Compliant Solution

          switch ($i) {
            case 1:
            case 3:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            default:
              doTheRest();
          }
          
          if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else {
            doTheRest();
          }
          
          doOneMoreThing();
          
          b = 4;
          

          or

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:
              doThirdThing();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThirdThing();
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doTheRest();
          }
          
          int b = a ? 12 > 4 : 8;
          

          Exceptions

          Blocks in an if chain that contain a single line of code are ignored, as are blocks in a switch statement that contain a single line of code with or without a following break.

          This branch's code block is the same as the block for the branch on line 261.
          Open

                      } elseif ($headers['st'] == 'upnp:rootdevice') {
                          self::sendResponse($delaytime, $actst, $address);
                      } elseif ($headers['st'] == $new_usn) {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php by sonar-php

          Having two cases in a switch statement or two branches in an if chain with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if chain they should be combined, or for a switch, one should fall through to the other.

          Noncompliant Code Example

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:  // Noncompliant; duplicates case 1's implementation
              doSomething();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThing();  // Noncompliant; duplicates first condition
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doOneMoreThing(); // Noncompliant; duplicates then-branch
          }
          
          var b = a ? 12 > 4 : 4;  // Noncompliant; always results in the same value
          

          Compliant Solution

          switch ($i) {
            case 1:
            case 3:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            default:
              doTheRest();
          }
          
          if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else {
            doTheRest();
          }
          
          doOneMoreThing();
          
          b = 4;
          

          or

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:
              doThirdThing();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThirdThing();
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doTheRest();
          }
          
          int b = a ? 12 > 4 : 8;
          

          Exceptions

          Blocks in an if chain that contain a single line of code are ignored, as are blocks in a switch statement that contain a single line of code with or without a following break.

          This branch's code block is the same as the block for the branch on line 261.
          Open

                      } elseif ($headers['st'] == 'urn:schemas-upnp-org:service:ContentDirectory:1') {
                          self::sendResponse($delaytime, $actst, $address);
                      } elseif ($headers['st'] == 'upnp:rootdevice') {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php by sonar-php

          Having two cases in a switch statement or two branches in an if chain with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if chain they should be combined, or for a switch, one should fall through to the other.

          Noncompliant Code Example

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:  // Noncompliant; duplicates case 1's implementation
              doSomething();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThing();  // Noncompliant; duplicates first condition
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doOneMoreThing(); // Noncompliant; duplicates then-branch
          }
          
          var b = a ? 12 > 4 : 4;  // Noncompliant; always results in the same value
          

          Compliant Solution

          switch ($i) {
            case 1:
            case 3:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            default:
              doTheRest();
          }
          
          if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else {
            doTheRest();
          }
          
          doOneMoreThing();
          
          b = 4;
          

          or

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:
              doThirdThing();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThirdThing();
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doTheRest();
          }
          
          int b = a ? 12 > 4 : 8;
          

          Exceptions

          Blocks in an if chain that contain a single line of code are ignored, as are blocks in a switch statement that contain a single line of code with or without a following break.

          This branch's code block is the same as the block for the branch on line 261.
          Open

                      } elseif ($headers['st'] == $new_usn) {
                          self::sendResponse($delaytime, $actst, $address);
                      } elseif ($headers['st'] == 'ssdp:all') {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php by sonar-php

          Having two cases in a switch statement or two branches in an if chain with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if chain they should be combined, or for a switch, one should fall through to the other.

          Noncompliant Code Example

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:  // Noncompliant; duplicates case 1's implementation
              doSomething();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThing();  // Noncompliant; duplicates first condition
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doOneMoreThing(); // Noncompliant; duplicates then-branch
          }
          
          var b = a ? 12 > 4 : 4;  // Noncompliant; always results in the same value
          

          Compliant Solution

          switch ($i) {
            case 1:
            case 3:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            default:
              doTheRest();
          }
          
          if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else {
            doTheRest();
          }
          
          doOneMoreThing();
          
          b = 4;
          

          or

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:
              doThirdThing();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThirdThing();
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doTheRest();
          }
          
          int b = a ? 12 > 4 : 8;
          

          Exceptions

          Blocks in an if chain that contain a single line of code are ignored, as are blocks in a switch statement that contain a single line of code with or without a following break.

          This branch's code block is the same as the block for the branch on line 1476.
          Open

                  } elseif ($num_and > 0 && $num_or == 0) {
                      $data['operator'] = 'and';
                  } else {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php by sonar-php

          Having two cases in a switch statement or two branches in an if chain with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if chain they should be combined, or for a switch, one should fall through to the other.

          Noncompliant Code Example

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:  // Noncompliant; duplicates case 1's implementation
              doSomething();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThing();  // Noncompliant; duplicates first condition
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doOneMoreThing(); // Noncompliant; duplicates then-branch
          }
          
          var b = a ? 12 > 4 : 4;  // Noncompliant; always results in the same value
          

          Compliant Solution

          switch ($i) {
            case 1:
            case 3:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            default:
              doTheRest();
          }
          
          if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else {
            doTheRest();
          }
          
          doOneMoreThing();
          
          b = 4;
          

          or

          switch ($i) {
            case 1:
              doSomething();
              break;
            case 2:
              doSomethingDifferent();
              break;
            case 3:
              doThirdThing();
              break;
            default:
              doTheRest();
          }
          
          if ($a >= 0 && $a < 10) {
            doTheThing();
          else if ($a >= 10 && $a < 20) {
            doTheOtherThing();
          }
          else if ($a >= 20 && $a < 50) {
            doTheThirdThing();
          }
          else {
            doTheRest();
          }
          
          if ($b == 0) {
            doOneMoreThing();
          }
          else {
            doTheRest();
          }
          
          int b = a ? 12 > 4 : 8;
          

          Exceptions

          Blocks in an if chain that contain a single line of code are ignored, as are blocks in a switch statement that contain a single line of code with or without a following break.

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

                      case 'clips':
                          switch (count($pathreq)) {
                              case 1:
                                  $counts = Catalog::get_videos_count(null, 'clip');
                                  $meta   = array(
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 2 other locations - About 3 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 1083..1104
          src/Module/Api/Upnp_Api.php on lines 1105..1126

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 157.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'movies':
                          switch (count($pathreq)) {
                              case 1:
                                  $counts = Catalog::get_videos_count(null, 'movie');
                                  $meta   = array(
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 2 other locations - About 3 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 1061..1082
          src/Module/Api/Upnp_Api.php on lines 1105..1126

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 157.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'personal_videos':
                          switch (count($pathreq)) {
                              case 1:
                                  $counts = Catalog::get_videos_count(null, 'personal_video');
                                  $meta   = array(
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 2 other locations - About 3 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 1061..1082
          src/Module/Api/Upnp_Api.php on lines 1083..1104

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 157.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'songs':
                          switch (count($pathreq)) {
                              case 1:
                                  $meta   = array(
                                      'id' => $root . '/songs',
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 4 other locations - About 2 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 607..627
          src/Module/Api/Upnp_Api.php on lines 628..648
          src/Module/Api/Upnp_Api.php on lines 670..690
          src/Module/Api/Upnp_Api.php on lines 712..732

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 141.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'albums':
                          switch (count($pathreq)) {
                              case 1:
                                  $meta   = array(
                                      'id' => $root . '/albums',
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 4 other locations - About 2 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 607..627
          src/Module/Api/Upnp_Api.php on lines 649..669
          src/Module/Api/Upnp_Api.php on lines 670..690
          src/Module/Api/Upnp_Api.php on lines 712..732

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 141.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'playlists':
                          switch (count($pathreq)) {
                              case 1:
                                  $meta   = array(
                                      'id' => $root . '/playlists',
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 4 other locations - About 2 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 607..627
          src/Module/Api/Upnp_Api.php on lines 628..648
          src/Module/Api/Upnp_Api.php on lines 649..669
          src/Module/Api/Upnp_Api.php on lines 712..732

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 141.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'live_streams':
                          switch (count($pathreq)) {
                              case 1:
                                  $meta   = array(
                                      'id' => $root . '/live_streams',
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 4 other locations - About 2 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 607..627
          src/Module/Api/Upnp_Api.php on lines 628..648
          src/Module/Api/Upnp_Api.php on lines 649..669
          src/Module/Api/Upnp_Api.php on lines 670..690

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 141.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'artists':
                          switch (count($pathreq)) {
                              case 1:
                                  $meta   = array(
                                      'id' => $root . '/artists',
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 4 other locations - About 2 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 628..648
          src/Module/Api/Upnp_Api.php on lines 649..669
          src/Module/Api/Upnp_Api.php on lines 670..690
          src/Module/Api/Upnp_Api.php on lines 712..732

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 141.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                              case 3: // Get episode list
                                  $season = new TVShow_Season((int)$pathreq[2]);
                                  if ($season->isNew() === false) {
                                      $episode_ids                  = $season->get_episodes();
                                      [$maxCount, $episode_ids]     = self::_slice($episode_ids, $start, $count);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 1 other location - About 2 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 1175..1186

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 122.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                              case 2: // Get season list
                                  $tvshow = new TvShow((int)$pathreq[1]);
                                  if ($tvshow->isNew() === false) {
                                      $season_ids                  = $tvshow->get_seasons();
                                      [$maxCount, $season_ids]     = self::_slice($season_ids, $start, $count);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 1 other location - About 2 hrs to fix
          src/Module/Api/Upnp_Api.php on lines 1187..1198

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 122.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                                  if ($playlist->isNew() === false) {
                                      $items              = $playlist->get_items();
                                      [$maxCount, $items] = self::_slice($items, $start, $count);
                                      foreach ($items as $item) {
                                          if ($item['object_type'] == 'song') {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 1 other location - About 1 hr to fix
          src/Module/Api/Upnp_Api.php on lines 905..915

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 114.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                                  if ($playlist->isNew() === false) {
                                      $items              = $playlist->get_items();
                                      [$maxCount, $items] = self::_slice($items, $start, $count);
                                      foreach ($items as $item) {
                                          if ($item['object_type'] == 'song') {
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 1 other location - About 1 hr to fix
          src/Module/Api/Upnp_Api.php on lines 931..941

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 114.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'clips':
                          // Get clips list
                          if (count($pathreq) == 1) {
                              $videos              = Catalog::get_videos(null, 'clip');
                              [$maxCount, $videos] = self::_slice($videos, $start, $count);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 2 other locations - About 55 mins to fix
          src/Module/Api/Upnp_Api.php on lines 1212..1222
          src/Module/Api/Upnp_Api.php on lines 1223..1233

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 99.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'movies':
                          // Get movies list
                          if (count($pathreq) == 1) {
                              $videos              = Catalog::get_videos(null, 'movie');
                              [$maxCount, $videos] = self::_slice($videos, $start, $count);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 2 other locations - About 55 mins to fix
          src/Module/Api/Upnp_Api.php on lines 1201..1211
          src/Module/Api/Upnp_Api.php on lines 1223..1233

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 99.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      case 'personal_videos':
                          // Get personal_videos list
                          if (count($pathreq) == 1) {
                              $videos              = Catalog::get_videos(null, 'personal_video');
                              [$maxCount, $videos] = self::_slice($videos, $start, $count);
          Severity: Major
          Found in src/Module/Api/Upnp_Api.php and 2 other locations - About 55 mins to fix
          src/Module/Api/Upnp_Api.php on lines 1201..1211
          src/Module/Api/Upnp_Api.php on lines 1212..1222

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 99.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          The class Upnp_Api is not named in CamelCase.
          Open

          class Upnp_Api
          {
              /**
               * UPnP classes:
               * object.item.audioItem
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpmd

          CamelCaseClassName

          Since: 0.2

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

          Example

          class class_name {
          }

          Source

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

                  $dt = new DateTime('UTC');
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.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

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

              public static function _videoMetadata($prmPath): ?array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemPodcastEpisode($episode, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              public static function _musicMetadata($prmPath): ?array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              public static function _callSearch($criteria, $filter, $start, $count): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              public static function _musicChilds($prmPath, $prmQuery, $start, $count): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemPodcast($podcast, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              public static function _slice($items, $start, $count): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _replaceSpecialSymbols($title)
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              public static function _itemSong($song, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemTVShow($tvshow, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemTVShowSeason($season, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              public static function _itemLiveStream($radio, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemArtist($artist, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemSmartPlaylist($playlist, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              public static function _videoChilds($prmPath, $prmQuery, $start, $count): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemPlaylist($playlist, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemAlbum($album, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemVideo($video, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _itemTag($tag, $parent): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

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

              private static function _getFileTypes(): array
          Severity: Minor
          Found in src/Module/Api/Upnp_Api.php by phpcodesniffer

          Expected 0 spaces after opening bracket; newline found
          Open

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

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

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

          There are no issues that match your filters.

          Category
          Status