librenms/librenms

View on GitHub
LibreNMS/Util/Debug.php

Summary

Maintainability
A
0 mins
Test Coverage

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

    public static function set($debug = true, bool $silence = false): bool
Severity: Minor
Found in LibreNMS/Util/Debug.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 disableErrorReporting has a boolean flag argument $silence, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function disableErrorReporting(bool $silence = false): void
Severity: Minor
Found in LibreNMS/Util/Debug.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 setVerbose has a boolean flag argument $verbose, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function setVerbose(bool $verbose = true): void
Severity: Minor
Found in LibreNMS/Util/Debug.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 setOnly has a boolean flag argument $debug, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function setOnly(bool $debug = true): bool
Severity: Minor
Found in LibreNMS/Util/Debug.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 set has a boolean flag argument $debug, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function set($debug = true, bool $silence = false): bool
Severity: Minor
Found in LibreNMS/Util/Debug.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 enableCliDebugOutput uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            putenv('LOG_CHANNEL=console_debug');
        }
Severity: Minor
Found in LibreNMS/Util/Debug.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 set uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            self::disableErrorReporting($silence);
            self::disableCliDebugOutput($silence);
            self::disableQueryDebug();
        }
Severity: Minor
Found in LibreNMS/Util/Debug.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 property $sql_debug_enabled is not named in camelCase.
Open

class Debug
{
    /** @var bool */
    private static $debug = false;
    /** @var bool */
Severity: Minor
Found in LibreNMS/Util/Debug.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

There are no issues that match your filters.

Category
Status