mambax7/extgallery

View on GitHub
class/pear/Console/Help.php

Summary

Maintainability
A
0 mins
Test Coverage

The method setOptions() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    public function setOptions($optionsConfig)
    {
        $optionsConfig = (array)$optionsConfig;

        $padding  = str_repeat(' ', self::optionPadding);
Severity: Minor
Found in class/pear/Console/Help.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

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

    public function tidyArray($array, $tidyString = true)
Severity: Minor
Found in class/pear/Console/Help.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 alignLines uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            // the information on the left is longer than the padding size
            $firstLine = $addon;
        }
Severity: Minor
Found in class/pear/Console/Help.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 local variables such as '$callback'.
Open

        $callback = create_function('$string', "return '$padding' . \$string;");
Severity: Minor
Found in class/pear/Console/Help.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Console_GetoptPlus_Help
Severity: Minor
Found in class/pear/Console/Help.php by phpcodesniffer

The class Console_GetoptPlus_Help is not named in CamelCase.
Open

class Console_GetoptPlus_Help
{
    /**
     * The option name padding within the option descrition
     */
Severity: Minor
Found in class/pear/Console/Help.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Class constants must be uppercase; expected USAGE but found usage
Open

    const usage = 'Usage: ';
Severity: Minor
Found in class/pear/Console/Help.php by phpcodesniffer

Class constants must be uppercase; expected OPTIONPADDING but found optionPadding
Open

    const optionPadding = 30;
Severity: Minor
Found in class/pear/Console/Help.php by phpcodesniffer

Class constants must be uppercase; expected OPTIONS but found options
Open

    const options = 'Options:';
Severity: Minor
Found in class/pear/Console/Help.php by phpcodesniffer

Class constants must be uppercase; expected PARAMETERS but found parameters
Open

    const parameters = 'Parameters:';
Severity: Minor
Found in class/pear/Console/Help.php by phpcodesniffer

Constant usage should be defined in uppercase
Open

    const usage = 'Usage: ';
Severity: Minor
Found in class/pear/Console/Help.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant optionPadding should be defined in uppercase
Open

    const optionPadding = 30;
Severity: Minor
Found in class/pear/Console/Help.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant parameters should be defined in uppercase
Open

    const parameters = 'Parameters:';
Severity: Minor
Found in class/pear/Console/Help.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant options should be defined in uppercase
Open

    const options = 'Options:';
Severity: Minor
Found in class/pear/Console/Help.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Line exceeds 120 characters; contains 190 characters
Open

            empty($option['type']) or 'mandatory' == $option['type'] and $value = '<' . array_shift($desc) . '>' or 'optional' == $option['type'] and $value = '[' . array_shift($desc) . ']';
Severity: Minor
Found in class/pear/Console/Help.php by phpcodesniffer

Class name "Console_GetoptPlus_Help" is not in camel caps format
Open

class Console_GetoptPlus_Help
Severity: Minor
Found in class/pear/Console/Help.php by phpcodesniffer

There are no issues that match your filters.

Category
Status