bluetree-service/filesystem

View on GitHub

Showing 83 of 83 total issues

The method processSplObjects has a boolean flag argument $reload, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function processSplObjects(callable $callback, bool $reload = true): void
Severity: Minor
Found in src/StaticObjects/Structure.php by phpmd

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 returnPaths has a boolean flag argument $reverse, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function returnPaths(bool $reverse = false): array
Severity: Minor
Found in src/StaticObjects/Structure.php by phpmd

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 '153', column '31').
Open

                $callback(new \SplFileInfo($path), $path);
Severity: Minor
Found in src/StaticObjects/Structure.php by phpmd

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 __construct has a boolean flag argument $recursive, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function __construct(string $path, bool $recursive = false)
Severity: Minor
Found in src/StaticObjects/Structure.php by phpmd

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(string $path, bool $recursive = false): array
Severity: Minor
Found in src/StaticObjects/Structure.php by phpmd

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 rename has a boolean flag argument $force, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function rename(string $source, string $target, bool $force = false): bool
Severity: Minor
Found in src/StaticObjects/Fs.php by phpmd

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 static function delete(string $path, bool $force = false): array
Severity: Minor
Found in src/StaticObjects/Fs.php by phpmd

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

Function mkfile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function mkfile(string $path, string $fileName, $data = null): bool
    {
        $status = false;

        self::triggerEvent(self::CREATE_FILE_BEFORE, [&$path, &$fileName, &$data]);
Severity: Minor
Found in src/StaticObjects/Fs.php - About 25 mins to fix

Cognitive Complexity

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

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

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

Further reading

The method move uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $bool = Fs::mkfile(
                $destination,
                $this->getFullName(),
                $this->getContent()
Severity: Minor
Found in src/File.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The method copy uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $bool = Fs::mkfile(
                $destination,
                $this->getFullName(),
                $this->getContent()
Severity: Minor
Found in src/File.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$path'.
Open

    public function copy($path, $target)
Severity: Minor
Found in src/Fs.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

The method load uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $this->createFileInstance($element, $totalSize, $files);
            }
Severity: Minor
Found in src/Directory.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$prefix'.
Open

    public function rename($newName, $prefix = null, $level = 0)
Severity: Minor
Found in src/Directory.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid using static access to class 'BlueFilesystem\Fs' in method 'move'.
Open

            $bool = Fs::mkfile(
                $destination,
                $this->getFullName(),
                $this->getContent()
            );
Severity: Minor
Found in src/File.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid unused parameters such as '$fileName'.
Open

    public function mkfile($path, $fileName, $data = null)
Severity: Minor
Found in src/Fs.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$target'.
Open

    public function rename($source, $target)
Severity: Minor
Found in src/Fs.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid using static access to class 'BlueFilesystem\StaticObjects\Structure' in method 'copyDir'.
Open

        if (!Structure::exist($target)) {
Severity: Minor
Found in src/StaticObjects/Fs.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method addChild uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $child = new Directory($child);
            }
Severity: Minor
Found in src/Directory.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class 'BlueFilesystem\Fs' in method 'move'.
Open

            $bool = Fs::move(
                $this->getFullPath(),
                $targetPath
            );
Severity: Minor
Found in src/File.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid unused parameters such as '$source'.
Open

    public function move($source, $target)
Severity: Minor
Found in src/Fs.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Severity
Category
Status
Source
Language