Showing 114 of 114 total issues
The class uColor is not named in CamelCase. Open
class uColor
{
/**
* Convert a hexa decimal color code to its RGB equivalent
- 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
The class uArray is not named in CamelCase. Open
class uArray
{
/**
* Проверяет, является ли массив ассоциативным
- 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 $m. Configured minimum length is 3. Open
function ($m) use (&$parseInfo, &$array) {
- 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
The class uString is not named in CamelCase. Open
class uString
{
/**
* Start string with $startStr
- 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
The class uList is not named in CamelCase. Open
class uList
{
/**
* Return range integer list
- 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
Function isIndexed
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function isIndexed(array $array, $consecutive = false)
{
if (empty($array)) {
return true;
}
- 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 closing brace for the class must go on the next line after the body Open
}
- Exclude checks
Function sizeFormat
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function sizeFormat($bytes, $decimals = 0)
{
$bytes = floatval($bytes);
if ($bytes < 1024) {
- 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 closing brace for the class must go on the next line after the body Open
}
- Exclude checks
The closing brace for the class must go on the next line after the body Open
}
- Exclude checks
The closing brace for the class must go on the next line after the body Open
}
- Exclude checks
Function get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function get($key, array $array, $default = null, $ignoreString = true)
{
if ($key === '') {
if (!array_key_exists((string)$key, $array)) {
return $default;
- 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 method isIndexed has a boolean flag argument $consecutive, which is a certain sign of a Single Responsibility Principle violation. Open
public static function isIndexed(array $array, $consecutive = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid too many return
statements within this method. Open
return number_format($bytes / pow(1024, 5), $decimals, '.', '') . ' PiB';
Remove error control operator '@' on line 69. Open
public function generateRandomKey($length = 32)
{
if (!is_int($length)) {
throw new \Exception('First parameter ($length) must be an integer');
}
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Avoid too many return
statements within this method. Open
return number_format($bytes / pow(1024, 4), $decimals, '.', '') . ' TiB';
The method isAssociative has a boolean flag argument $allStrings, which is a certain sign of a Single Responsibility Principle violation. Open
public static function isAssociative($array, $allStrings = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '229', column '55'). Open
$dirIter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, $flags));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '20', column '23'). Open
throw new \Exception('First parameter ($length) must be greater than 0');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '128', column '23'). Open
throw new \Exception('First parameter ($length) must be greater than 0');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}