Showing 114 of 114 total issues
Function generateRandomKey
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function generateRandomKey($length = 32)
{
if (!is_int($length)) {
throw new \Exception('First parameter ($length) must be an integer');
}
- 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 save
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public static function save($key, array &$array, $value, $replace = true)
{
if ($key === '') {
$array[ $key ] = $value;
- 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 uFile has an overall complexity of 58 which is very high. The configured complexity threshold is 50. Open
class uFile
{
/**
* Return File Extension
- Exclude checks
The class uArray has an overall complexity of 72 which is very high. The configured complexity threshold is 50. Open
class uArray
{
/**
* Проверяет, является ли массив ассоциативным
- Exclude checks
Method parseAndValidateKeys
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function parseAndValidateKeys($key, array &$array, $mode = '')
{
$parseInfo = [
'keys' => [],
'lastKey' => '',
Method generateRandomKey
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateRandomKey($length = 32)
{
if (!is_int($length)) {
throw new \Exception('First parameter ($length) must be an integer');
}
Function parseAndValidateKeys
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private static function parseAndValidateKeys($key, array &$array, $mode = '')
{
$parseInfo = [
'keys' => [],
'lastKey' => '',
- 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 isAssociative
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function isAssociative($array, $allStrings = true)
{
if (!is_array($array) || empty($array)) {
return false;
}
- 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 save
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function save($key, array &$array, $value, $replace = true)
{
if ($key === '') {
$array[ $key ] = $value;
Avoid using short method names like uFile::ls(). The configured minimum method name length is 3. Open
public static function ls($dir)
{
$contents = [];
$flags = \FilesystemIterator::KEY_AS_PATHNAME
| \FilesystemIterator::CURRENT_AS_FILEINFO
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Method perms
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function perms($file, $perms = null)
{
if (null === $perms) {
if (!file_exists($file)) {
return false;
Function perms
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function perms($file, $perms = null)
{
if (null === $perms) {
if (!file_exists($file)) {
return false;
- 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 normalizePath
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function normalizePath($path, $slash = DIRECTORY_SEPARATOR)
{
$path = rtrim(strtr($path, '/\\', $slash . $slash), $slash);
if (strpos($slash . $path, "{$slash}.") === false && strpos($path, "{$slash}{$slash}") === false) {
return $path;
- 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
Avoid using undefined variables such as '$mCurSource' which will lead to PHP notices. Open
$mCurSource[ $key ] = [];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid variables with short names like $m. Configured minimum length is 3. Open
$m = floor($value % 60);
- 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
Avoid variables with short names like $to. Configured minimum length is 3. Open
public static function rangeList($from, $to, $step = 1)
- 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 uSecurity is not named in CamelCase. Open
class uSecurity
{
public function generateRandomKey($length = 32)
{
- 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 uTime is not named in CamelCase. Open
class uTime
{
/**
* Return time 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
Avoid variables with short names like $h. Configured minimum length is 3. Open
$h = floor($value / 60);
- 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 uFile is not named in CamelCase. Open
class uFile
{
/**
* Return File Extension
- 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 {
}