File Upnp_Api.php
has 1534 lines of code (exceeds 500 allowed). Consider refactoring. Open
<?php
declare(strict_types=0);
/**
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();
- Read upRead up
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:
- Read upRead up
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) {
- Read upRead up
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);
- Read upRead up
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
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'),
- Read upRead up
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();
- Read upRead up
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) {
- Read upRead up
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
- Read upRead up
- Exclude checks
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
- Exclude checks
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
- Read upRead up
- Exclude checks
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);
- Read upRead up
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) {
- Read upRead up
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++) {
- Read upRead up
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
- Read upRead up
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
Method createSOAPEnvelope
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$prmDIDL,
$prmNumRet,
$prmTotMatches,
$prmResponseType = 'u:BrowseResponse',
$prmUpdateID = '0'
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
- Exclude checks
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();
- Read upRead up
- Exclude checks
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:
- Exclude checks
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'),
- Read upRead up
- Exclude checks
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) {
- Exclude checks
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) {
- Exclude checks
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'),
- Exclude checks
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:
- Read upRead up
- Exclude checks
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();
- Exclude checks
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();
- Exclude checks
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);
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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++) {
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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'),
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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');
}
- Read upRead up
- Exclude checks
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
}
- Read upRead up
- Exclude checks
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);
}
}
- Read upRead up
- Exclude checks
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';
}
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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] = '';
}
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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') {
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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' ||
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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";
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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,
- Read upRead up
- Exclude checks
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';
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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';
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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++) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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 );
- Read upRead up
- Exclude checks
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++) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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";
- Read upRead up
- Exclude checks
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' ) ){
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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'),
- Read upRead up
- Exclude checks
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' ||
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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";
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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',
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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';
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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']) {
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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',
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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':
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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'],
- Read upRead up
- Exclude checks
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',
- Read upRead up
- Exclude checks
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:*',),
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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++) {
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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)) {
- Read upRead up
- Exclude checks
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)
- Exclude checks
TODO found Open
// TODO patched out for now: creates problems in search results
- Exclude checks
XXX found Open
'restricted' => 'false', // XXX
- Exclude checks
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);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\TvShow
Open
if ($tvshow->isNew() === false) {
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->isNew() === false) {
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
$video->format();
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Clip
Open
$video = new Clip((int)$pathreq[1]);
- Exclude checks
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);
- Exclude checks
Call to method get_server_counts
from undeclared class \Ampache\Repository\Model\Catalog
Open
$counts = Catalog::get_server_counts(0);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Artist
Open
if ($artist->isNew() === false) {
- Exclude checks
Call to method get_catalogs
from undeclared class \Ampache\Repository\Model\Catalog
Open
$catalogs = Catalog::get_catalogs();
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Song
Open
$song->format();
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
$season = new TVShow_Season((int)$pathreq[2]);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
if (isset($episode->id)) {
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Song
Open
$song = new Song($item['object_id']);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$radio = new Live_Stream($radio_id);
- Exclude checks
Call to method getEpisodeIds
from undeclared class \Ampache\Repository\Model\Podcast
Open
$episodes = $podcast->getEpisodeIds();
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, $item, 5);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
if (isset($album->id)) {
- Exclude checks
Call to method get_items
from undeclared class \Ampache\Repository\Model\Search
Open
$items = $playlist->get_items();
- Exclude checks
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);
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, 'item is not array', 2);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$radio = new Live_Stream((int)$pathreq[1]);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
if ($radio->isNew() === false) {
- Exclude checks
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);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Album
Open
$album->format();
- Exclude checks
Call to method get_searches
from undeclared class \Ampache\Repository\Model\Search
Open
$searches = Search::get_searches();
- Exclude checks
Call to method get_tvshows
from undeclared class \Ampache\Repository\Model\Catalog
Open
$counts = count(Catalog::get_tvshows());
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
$video = new TVShow_Episode((int)$pathreq[3]);
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, $str, 5);
- Exclude checks
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);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Song
Open
if ($song->isNew() === false) {
- Exclude checks
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);
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, 'MusicChilds4: [' . $pathreq[0] . ']', 5);
- Exclude checks
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);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$radio->format();
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$episode = new Podcast_Episode($episode_id);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist->format();
- Exclude checks
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]);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Search
Open
$playlist = new Search($search['id'], 'song');
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Search
Open
if ($playlist->isNew() === false) {
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
$season->format();
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Search
Open
$playlist = new Search((int)$pathreq[1], 'song');
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Search
Open
$playlist->format();
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$episode->format();
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Artist
Open
$album_ids = static::getAlbumRepository()->getAlbumByArtist($artist->id);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Song
Open
$song->format();
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Song
Open
$song = new Song($item['object_id']);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Search
Open
$playlist = new Search((int)$pathreq[1], 'song');
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
if ($video->isNew() === false) {
- Exclude checks
Call to method get_videos_count
from undeclared class \Ampache\Repository\Model\Catalog
Open
$counts = Catalog::get_videos_count(null, 'clip');
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Album
Open
$album->format();
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Album
Open
$album->format();
- Exclude checks
Argument 2 (value)
is int
but \DOMDocument::createElement()
takes string
Open
$ndNumRet = $doc->createElement('NumberReturned', $prmNumRet);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Song
Open
$song = new Song($song_id);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album((int)$pathreq[1]);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Search
Open
if ($playlist->isNew() === false) {
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist = new Artist((int)$pathreq[1]);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\TvShow
Open
$tvshow->format();
- Exclude checks
Possibly zero references to use statement for classlike/namespace Podcast
(\Ampache\Repository\Model\Podcast)
Open
use Ampache\Repository\Model\Podcast;
- Exclude checks
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);
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, '(Sent)', 5);
- Exclude checks
Possibly zero references to use statement for classlike/namespace User
(\Ampache\Repository\Model\User)
Open
use Ampache\Repository\Model\User;
- Exclude checks
Call to method get_server_counts
from undeclared class \Ampache\Repository\Model\Catalog
Open
$counts = Catalog::get_server_counts(0);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$episode = new Podcast_Episode((int)$pathreq[2]);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->isNew()) {
- Exclude checks
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]);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
if ($season->isNew() === false) {
- Exclude checks
Call to method get_albums
from undeclared class \Ampache\Repository\Model\Catalog
Open
$album_ids = Catalog::get_albums($count, $start);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist = new Artist((int)$pathreq[1]);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album((int)$pathreq[1]);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Song
Open
$song->format();
- Exclude checks
Call to method get_artists
from undeclared class \Ampache\Repository\Model\Catalog
Open
$artists = Catalog::get_artists(null, $count, $start);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
$song_ids = static::getSongRepository()->getByAlbum($album->id);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Artist
Open
if ($artist->isNew() === false) {
- Exclude checks
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(
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$episode->format();
- Exclude checks
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);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Song
Open
$song = new Song((int)$pathreq[1]);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$radio->format();
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->isNew()) {
- Exclude checks
Call to method create_from_id
from undeclared class \Ampache\Repository\Model\Catalog
Open
$catalog = Catalog::create_from_id($catalog_id);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Song
Open
$song->format();
- Exclude checks
Call to method get_podcasts
from undeclared class \Ampache\Repository\Model\Catalog
Open
$podcasts = Catalog::get_podcasts();
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\TvShow
Open
$tvshow = new TvShow((int)$pathreq[1]);
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, 'Discovery request from ' . $address, 5);
- Exclude checks
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);
- Exclude checks
Reference to instance property album_count
from undeclared class \Ampache\Repository\Model\Artist
Open
'childCount' => $artist->album_count,
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Clip
Open
if ($video->isNew() === false) {
- Exclude checks
Reference to instance property f_artist
from undeclared class \Ampache\Repository\Model\Song
Open
'dc:creator' => self::_replaceSpecialSymbols($song->f_artist),
- Exclude checks
Parameter $radio
has undeclared type \Ampache\Repository\Model\Live_Stream
Open
public static function _itemLiveStream($radio, $parent): array
- Exclude checks
Call to method get_videos
from undeclared class \Ampache\Repository\Model\Catalog
Open
$videos = Catalog::get_videos(null, 'clip');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
'id' => 'amp://music/live_streams/' . $radio->id,
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Artist
Open
if ($artist->isNew()) {
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
'dc:title' => self::_replaceSpecialSymbols($video->f_name),
- Exclude checks
Call to method get_items
from undeclared class \Ampache\Repository\Model\Search
Open
'childCount' => count($playlist->get_items()),
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
'dc:title' => self::_replaceSpecialSymbols($video->f_name),
- Exclude checks
Parameter $song
has undeclared type \Ampache\Repository\Model\Song
Open
public static function _itemSong($song, $parent): array
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\Video
Open
'dc:title' => self::_replaceSpecialSymbols($video->f_name),
- Exclude checks
Reference to instance property f_album
from undeclared class \Ampache\Repository\Model\Song
Open
'upnp:album' => self::_replaceSpecialSymbols($song->f_album),
- Exclude checks
Reference to instance property tags
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Clip
Open
'size' => $video->size,
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
$arrFileType = $fileTypesByExt[$video->type];
- Exclude checks
Call to method play_url
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$ret['res'] = $episode->play_url('', 'api');
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\TvShow
Open
$tvshow = new TvShow((int)$pathreq[1]);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
$season = new TVShow_Season($season_id);
- Exclude checks
Call to method get_videos
from undeclared class \Ampache\Repository\Model\Catalog
Open
$videos = Catalog::get_videos(null, 'personal_video');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
'id' => 'amp://music/albums/' . $album->id,
- Exclude checks
Parameter $playlist
has undeclared type \Ampache\Repository\Model\Search
Open
private static function _itemSmartPlaylist($playlist, $parent): array
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
'id' => $parent . '/' . $video->id,
- Exclude checks
Reference to instance property f_time_h
from undeclared class \Ampache\Repository\Model\Movie
Open
'duration' => $video->f_time_h . '.0',
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
if ($video->isNew() === false) {
- Exclude checks
Call to method get_tvshows
from undeclared class \Ampache\Repository\Model\Catalog
Open
$tvshows = Catalog::get_tvshows();
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist->format();
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->id
Open
'id' => 'amp://music/playlists/' . $playlist->id,
- Exclude checks
Reference to instance property comment
from undeclared class \Ampache\Repository\Model\Song
Open
'description' => self::_replaceSpecialSymbols($song->comment),
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\TvShow
Open
'id' => 'amp://video/tvshows/' . $tvshow->id,
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Movie
Open
$arrFileType = $fileTypesByExt[$video->type];
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
'id' => $parent . '/' . $video->id,
- Exclude checks
Call to method get_episodes
from undeclared class \Ampache\Repository\Model\Podcast
Open
'childCount' => count($podcast->get_episodes()),
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Movie
Open
$video = new Movie((int)$pathreq[1]);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->isNew()) {
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Tag
Open
$tag->format();
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Album
Open
'dc:title' => self::_replaceSpecialSymbols($album->get_fullname()),
- Exclude checks
Reference to instance property name
from undeclared class \Ampache\Repository\Model\Search
Open
'dc:title' => self::_replaceSpecialSymbols($playlist->name),
- Exclude checks
Call to method get_videos_count
from undeclared class \Ampache\Repository\Model\Catalog
Open
$counts = Catalog::get_videos_count(null, 'movie');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Movie
Open
$art_url = Art::url($video->id, 'video', $api_session);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
$video->format();
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\Movie
Open
'dc:title' => self::_replaceSpecialSymbols($video->f_name),
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist = new Artist($artist_id);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Song
Open
$arrFileType = $fileTypesByExt[$song->type];
- Exclude checks
Reference to instance property name
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
'dc:title' => self::_replaceSpecialSymbols($radio->name),
- Exclude checks
Reference to instance property tvshow
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
'id' => 'amp://video/tvshows/' . $season->tvshow . '/' . $season->id,
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
'dc:title' => self::_replaceSpecialSymbols($season->f_name),
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
$art_url = Art::url($video->id, 'video', $api_session);
- Exclude checks
Reference to instance property f_time_h
from undeclared class \Ampache\Repository\Model\Video
Open
'duration' => $video->f_time_h . '.0',
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
'dc:title' => self::_replaceSpecialSymbols($episode->get_fullname()),
- Exclude checks
Call to method get_videos
from undeclared class \Ampache\Repository\Model\Catalog
Open
$videos = Catalog::get_videos(null, 'movie');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Artist
Open
'id' => 'amp://music/artists/' . $artist->id,
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Artist
Open
'dc:title' => self::_replaceSpecialSymbols($artist->get_fullname()),
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
$art_url = Art::url($album->id, 'album', $api_session);
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\TvShow
Open
'dc:title' => self::_replaceSpecialSymbols($tvshow->f_name),
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Clip
Open
'id' => $parent . '/' . $video->id,
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\Clip
Open
'dc:title' => self::_replaceSpecialSymbols($video->f_name),
- Exclude checks
Reference to instance property f_time_h
from undeclared class \Ampache\Repository\Model\Clip
Open
'duration' => $video->f_time_h . '.0',
- Exclude checks
Reference to instance property podcast
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$art_url = Art::url($episode->podcast, 'podcast', $api_session);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
'id' => 'amp://music/podcasts/' . $episode->podcast . '/' . $episode->id,
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$ret['size'] = $episode->size;
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->name
Open
'dc:title' => self::_replaceSpecialSymbols($playlist->name),
- Exclude checks
Reference to instance property f_artist
from undeclared class \Ampache\Repository\Model\Song
Open
'upnp:artist' => self::_replaceSpecialSymbols($song->f_artist),
- Exclude checks
Reference to instance property codec
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$arrFileType = $fileTypesByExt[$radio->codec];
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
$art_url = Art::url($video->id, 'video', $api_session);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Video
Open
'id' => $parent . '/' . $video->id,
- Exclude checks
Call to method play_url
from undeclared class \Ampache\Repository\Model\Video
Open
'res' => $video->play_url('', 'api'),
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Movie
Open
$video->format();
- Exclude checks
Call to method get_seasons
from undeclared class \Ampache\Repository\Model\TvShow
Open
$season_ids = $tvshow->get_seasons();
- Exclude checks
Call to method run
from undeclared class \Ampache\Repository\Model\Search
Open
$ids = Search::run($data); // return a list of IDs
- Exclude checks
Reference to instance property album
from undeclared class \Ampache\Repository\Model\Song
Open
$art_url = Art::url($song->album, 'album', $api_session);
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Clip
Open
$arrFileType = $fileTypesByExt[$video->type];
- Exclude checks
Reference to instance property tags
from undeclared class \Ampache\Repository\Model\Movie
Open
'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
- Exclude checks
Call to method play_url
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
'res' => $video->play_url('', 'api'),
- Exclude checks
Reference to instance property f_time_h
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
'duration' => $video->f_time_h . '.0',
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$arrFileType = (!empty($episode->type)) ? $fileTypesByExt[$episode->type] : array();
- Exclude checks
Reference to instance property podcast
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
'id' => 'amp://music/podcasts/' . $episode->podcast . '/' . $episode->id,
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Movie
Open
if ($video->isNew() === false) {
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
$video = new Personal_Video((int)$pathreq[1]);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\TvShow
Open
if ($tvshow->isNew() === false) {
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
$season->format();
- Exclude checks
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);
- Exclude checks
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);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Song
Open
$song = new Song($song_id);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Tag
Open
$tag = new Tag($tag_id);
- Exclude checks
Reference to instance property song_count
from undeclared class \Ampache\Repository\Model\Album
Open
'childCount' => $album->song_count,
- Exclude checks
Reference to instance property album_artist
from undeclared class \Ampache\Repository\Model\Album
Open
'upnp:albumArtist' => $album->album_artist,
- Exclude checks
Call to method get_videos_count
from undeclared class \Ampache\Repository\Model\Catalog
Open
$counts = Catalog::get_videos_count(null, 'personal_video');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Song
Open
'id' => 'amp://music/songs/' . $song->id,
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Album
Open
$album->format();
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Video
Open
$arrFileType = $fileTypesByExt[$video->type];
- Exclude checks
Parameter $album
has undeclared type \Ampache\Repository\Model\Album
Open
private static function _itemAlbum($album, $parent): array
- Exclude checks
Call to method get_display
from undeclared class \Ampache\Repository\Model\Tag
Open
'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
- Exclude checks
Reference to instance property tags
from undeclared class \Ampache\Repository\Model\Song
Open
'upnp:genre' => Tag::get_display($song->tags, false, 'song'),
- Exclude checks
Call to method play_url
from undeclared class \Ampache\Repository\Model\Movie
Open
'res' => $video->play_url('', 'api'),
- Exclude checks
Call to method play_url
from undeclared class \Ampache\Repository\Model\Song
Open
'res' => $song->play_url('', 'api', true), // For upnp, use local
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Movie
Open
'size' => $video->size,
- Exclude checks
Reference to instance property url
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
'res' => $radio->url,
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Clip
Open
$art_url = Art::url($video->id, 'video', $api_session);
- Exclude checks
Reference to instance property tags
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
- Exclude checks
Parameter $episode
has undeclared type \Ampache\Repository\Model\Podcast_Episode
Open
private static function _itemPodcastEpisode($episode, $parent): array
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
$season = new TVShow_Season((int)$pathreq[2]);
- Exclude checks
Call to method get_episodes
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
$episode_ids = $season->get_episodes();
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Tag
Open
'id' => 'amp://music/tags/' . $tag->id,
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\Tag
Open
'dc:title' => self::_replaceSpecialSymbols($tag->f_name),
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Search
Open
'id' => 'amp://music/playlists/' . $playlist->id,
- Exclude checks
Call to method get_items
from undeclared class \Ampache\Repository\Model\Search
Open
'childCount' => count($playlist->get_items()),
- Exclude checks
Reference to instance property name
from undeclared class \Ampache\Repository\Model\Search
Open
'dc:title' => self::_replaceSpecialSymbols($playlist->name),
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$art_url = Art::url($radio->id, 'live_stream', $api_session);
- Exclude checks
Call to method get_seasons
from undeclared class \Ampache\Repository\Model\TvShow
Open
'childCount' => count($tvshow->get_seasons()),
- Exclude checks
Parameter $season
has undeclared type \Ampache\Repository\Model\TVShow_Season
Open
private static function _itemTVShowSeason($season, $parent): array
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
'id' => 'amp://video/tvshows/' . $season->tvshow . '/' . $season->id,
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Movie
Open
'id' => $parent . '/' . $video->id,
- Exclude checks
Reference to instance property tags
from undeclared class \Ampache\Repository\Model\Video
Open
'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
- Exclude checks
Reference to instance property f_time_h
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$ret['duration'] = $episode->f_time_h . '.0';
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Clip
Open
$video->format();
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
if ($season->isNew() === false) {
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Song
Open
$song->format();
- Exclude checks
Parameter $artist
has undeclared type \Ampache\Repository\Model\Artist
Open
private static function _itemArtist($artist, $parent): array
- Exclude checks
Parameter $tag
has undeclared type \Ampache\Repository\Model\Tag
Open
private static function _itemTag($tag, $parent): array
- Exclude checks
Reference to instance property f_name
from undeclared class \Ampache\Repository\Model\Song
Open
'dc:title' => self::_replaceSpecialSymbols($song->f_name),
- Exclude checks
Reference to instance property addition_time
from undeclared class \Ampache\Repository\Model\Song
Open
'dc:date' => date("c", (int) $song->addition_time),
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Song
Open
'size' => $song->size,
- Exclude checks
Reference to instance property f_time_h
from undeclared class \Ampache\Repository\Model\Song
Open
'duration' => $song->f_time_h . '.0',
- Exclude checks
Call to method get_episodes
from undeclared class \Ampache\Repository\Model\TVShow_Season
Open
'childCount' => count($season->get_episodes()),
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
'size' => $video->size,
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
'size' => $video->size,
- Exclude checks
Reference to instance property f_time_h
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
'duration' => $video->f_time_h . '.0',
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Video
Open
$video = new Video($episode_id);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Video
Open
$video->format();
- Exclude checks
Reference to instance property track
from undeclared class \Ampache\Repository\Model\Song
Open
'upnp:originalTrackNumber' => $song->track,
- Exclude checks
Call to method play_url
from undeclared class \Ampache\Repository\Model\TVShow_Episode
Open
'res' => $video->play_url('', 'api'),
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, 'Search returned no hits', 5);
- Exclude checks
Reference to instance property album
from undeclared class \Ampache\Repository\Model\Song
Open
$parent = 'amp://music/albums/' . (string) $song->album;
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Search
Open
'id' => 'amp://music/smartplaylists/' . $playlist->id,
- Exclude checks
Reference to instance property bitrate
from undeclared class \Ampache\Repository\Model\Song
Open
'bitrate' => $song->bitrate,
- Exclude checks
Reference to instance property rate
from undeclared class \Ampache\Repository\Model\Song
Open
'sampleFrequency' => $song->rate,
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Personal_Video
Open
$arrFileType = $fileTypesByExt[$video->type];
- Exclude checks
Reference to instance property tags
from undeclared class \Ampache\Repository\Model\Clip
Open
'upnp:genre' => Tag::get_display($video->tags, false, 'video'),
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Video
Open
'size' => $video->size,
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Podcast
Open
'dc:title' => self::_replaceSpecialSymbols($podcast->get_fullname()),
- Exclude checks
Call to method get_display
from undeclared class \Ampache\Repository\Model\Tag
Open
'upnp:genre' => Tag::get_display($song->tags, false, 'song'),
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Video
Open
$art_url = Art::url($video->id, 'video', $api_session);
- Exclude checks
Call to method play_url
from undeclared class \Ampache\Repository\Model\Clip
Open
'res' => $video->play_url('', 'api'),
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Podcast
Open
'id' => 'amp://music/podcasts/' . $podcast->id,
- Exclude checks
Call to method getPodcastName
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
'upnp:album' => self::_replaceSpecialSymbols($episode->getPodcastName()),
- Exclude checks
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') {
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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') {
- Read upRead up
- Exclude checks
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') {
- Read upRead up
- Exclude checks
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 {
- Read upRead up
- Exclude checks
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(
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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(
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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(
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
case 'songs':
switch (count($pathreq)) {
case 1:
$meta = array(
'id' => $root . '/songs',
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
case 'albums':
switch (count($pathreq)) {
case 1:
$meta = array(
'id' => $root . '/albums',
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
case 'playlists':
switch (count($pathreq)) {
case 1:
$meta = array(
'id' => $root . '/playlists',
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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',
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
case 'artists':
switch (count($pathreq)) {
case 1:
$meta = array(
'id' => $root . '/artists',
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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') {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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') {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
The class Upnp_Api is not named in CamelCase. Open
class Upnp_Api
{
/**
* UPnP classes:
* object.item.audioItem
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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
- Exclude checks
Method name "_itemPodcastEpisode" should not be prefixed with an underscore to indicate visibility Open
private static function _itemPodcastEpisode($episode, $parent): array
- Exclude checks
Method name "_musicMetadata" should not be prefixed with an underscore to indicate visibility Open
public static function _musicMetadata($prmPath): ?array
- Exclude checks
Method name "_callSearch" should not be prefixed with an underscore to indicate visibility Open
public static function _callSearch($criteria, $filter, $start, $count): array
- Exclude checks
Method name "_musicChilds" should not be prefixed with an underscore to indicate visibility Open
public static function _musicChilds($prmPath, $prmQuery, $start, $count): array
- Exclude checks
Method name "_itemPodcast" should not be prefixed with an underscore to indicate visibility Open
private static function _itemPodcast($podcast, $parent): array
- Exclude checks
Method name "_slice" should not be prefixed with an underscore to indicate visibility Open
public static function _slice($items, $start, $count): array
- Exclude checks
Method name "_replaceSpecialSymbols" should not be prefixed with an underscore to indicate visibility Open
private static function _replaceSpecialSymbols($title)
- Exclude checks
Method name "_itemSong" should not be prefixed with an underscore to indicate visibility Open
public static function _itemSong($song, $parent): array
- Exclude checks
Method name "_itemTVShow" should not be prefixed with an underscore to indicate visibility Open
private static function _itemTVShow($tvshow, $parent): array
- Exclude checks
Method name "_itemTVShowSeason" should not be prefixed with an underscore to indicate visibility Open
private static function _itemTVShowSeason($season, $parent): array
- Exclude checks
Method name "_itemLiveStream" should not be prefixed with an underscore to indicate visibility Open
public static function _itemLiveStream($radio, $parent): array
- Exclude checks
Method name "_itemArtist" should not be prefixed with an underscore to indicate visibility Open
private static function _itemArtist($artist, $parent): array
- Exclude checks
Method name "_itemSmartPlaylist" should not be prefixed with an underscore to indicate visibility Open
private static function _itemSmartPlaylist($playlist, $parent): array
- Exclude checks
Method name "_videoChilds" should not be prefixed with an underscore to indicate visibility Open
public static function _videoChilds($prmPath, $prmQuery, $start, $count): array
- Exclude checks
Method name "_itemPlaylist" should not be prefixed with an underscore to indicate visibility Open
private static function _itemPlaylist($playlist, $parent): array
- Exclude checks
Method name "_itemAlbum" should not be prefixed with an underscore to indicate visibility Open
private static function _itemAlbum($album, $parent): array
- Exclude checks
Method name "_itemVideo" should not be prefixed with an underscore to indicate visibility Open
private static function _itemVideo($video, $parent): array
- Exclude checks
Method name "_itemTag" should not be prefixed with an underscore to indicate visibility Open
private static function _itemTag($tag, $parent): array
- Exclude checks
Method name "_getFileTypes" should not be prefixed with an underscore to indicate visibility Open
private static function _getFileTypes(): array
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks
Class name "Upnp_Api" is not in camel caps format Open
class Upnp_Api
- Exclude checks