Showing 83 of 83 total issues
The class Fs has an overall complexity of 57 which is very high. The configured complexity threshold is 50. Open
class Fs implements FsInterface
{
/**
* @var EventDispatcherInterface
*/
- Exclude checks
File Fs.php
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace BlueFilesystem\StaticObjects;
use BlueEvent\Event\Base\Interfaces\EventDispatcherInterface;
Avoid using undefined variables such as '$creationDir' which will lead to PHP notices. Open
$creationDir[] = $target . $dirToCopy . \str_replace($source, '', $dir);
- 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 using undefined variables such as '$creationDir' which will lead to PHP notices. Open
$creationDirRevert = \array_reverse($creationDir);
- 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 using undefined variables such as '$creationDir' which will lead to PHP notices. Open
$creationDir[] = $target . $dirToCopy;
- 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
Function readDirectoryRecursive
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function readDirectoryRecursive(string $path, bool $recursive): array
{
$list = [];
if (!self::exist($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 classes with short names like Fs. Configured minimum length is 3. Open
class Fs implements FsInterface
{
/**
* @var EventDispatcherInterface
*/
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Fs. Configured minimum length is 3. Open
class Fs
{
public function __construct($path, $register = null)
{
if (is_null($register)) {
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Function load
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function load()
{
// Loader::callEvent('load_directory_object_instance_before', $this);
if (!Fs::exist($this->getMainPath())) {
- 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 returnPathsRecursive
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function returnPathsRecursive(array $array): array
{
$pathList = [
'dir' => [],
'file' => [],
- 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 mkdir
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function mkdir(string $path): array
{
$newPath = '';
$operationList = [];
$bool = \preg_match(self::RESTRICTED_SYMBOLS, $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
Method buildDirStructure
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
array $dirPaths,
string $source,
string $target,
string $dirToCopy,
array $operationList
Function rename
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function rename(string $source, string $target, bool $force = false): bool
{
$status = true;
self::setForceMode([$source], $force);
- 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
Missing class import via use statement (line '73', column '25'). Open
$iterator = new \DirectoryIterator($path);
- 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
The method copy has a boolean flag argument $force, which is a certain sign of a Single Responsibility Principle violation. Open
public static function copy(string $source, string $target, bool $force = false): array
- 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
The method move has a boolean flag argument $force, which is a certain sign of a Single Responsibility Principle violation. Open
public static function move(string $source, string $target, bool $force = false): array
- 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
The method delete has a boolean flag argument $force, which is a certain sign of a Single Responsibility Principle violation. Open
public function delete($path, $force = 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
The method readDirectory has a boolean flag argument $recursive, which is a certain sign of a Single Responsibility Principle violation. Open
public function readDirectory($path, $recursive = 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
Remove error control operator '@' on line 96. Open
public function save()
{
// Loader::callEvent('save_file_object_instance_before', $this);
if (empty($this->_DATA)) {
- 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
The method returnPaths has a boolean flag argument $reverse, which is a certain sign of a Single Responsibility Principle violation. Open
public function returnPaths(array $array, $reverse = 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) {
}
}