hendrikmaus/spas

View on GitHub

Showing 43 of 43 total issues

Missing class import via use statement (line '28', column '19').
Open

        throw new \Exception('Unknown client type requested');
Severity: Minor
Found in src/Request/HttpClientFactory.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

Missing class import via use statement (line '75', column '36').
Open

            sprintf('%s: %s', (new \ReflectionClass(static::class))->getShortName(), $msg),
Severity: Minor
Found in src/Hook/Hook.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

Avoid too many return statements within this method.
Open

        return $this->doRequest($request, $attempt);
Severity: Major
Found in src/Request/RequestProcessor.php - About 30 mins to fix

    Missing class import via use statement (line '9', column '20').
    Open

            $dom = new \DOMDocument();
    Severity: Minor
    Found in src/Formatter/XmlFormatter.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

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

        public function getFormatterByContentType(string $type) : Formatter
        {
            foreach ($this->formatters as $formatter) {
                foreach ($formatter->getContentTypes() as $contentType) {
                    if (strpos($type, $contentType) !== false) {
    Severity: Minor
    Found in src/Formatter/FormatterService.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

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

        public function format($data) : string
        {
            $result = [];
    
            /** @var Validator $validator */
    Severity: Minor
    Found in src/Formatter/ValidationErrorFormatter.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

    Avoid unused parameters such as '$event'.
    Open

        private function onBeforeAll(BeforeAll $event)
    Severity: Minor
    Found in src/Hook/HelloHookData.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 '$response'.
    Open

        public function validate(ParsedRequest $request, ParsedResponse $response)

    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 configure() has 100 lines of code. Current threshold is set to 100. Avoid really long methods.
    Open

        protected function configure()
        {
            $this
                ->setName('run')
                ->setDescription('Run test suite')
    Severity: Minor
    Found in src/Command/RunCommand.php by phpmd

    Avoid unused parameters such as '$event'.
    Open

        private function onBeforeAll(BeforeAll $event)
    Severity: Minor
    Found in src/Hook/EnableDisable.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 printRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $this->logger->info('{0} {1}', [
                    $request->getMethod(),
                    $request->getHref()
                ]);
    Severity: Minor
    Found in src/Request/RequestProcessor.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 '\React\EventLoop\Factory' in method 'create'.
    Open

                $loop    = Factory::create();
    Severity: Minor
    Found in src/Request/HttpClientFactory.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 printValidatorReport uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $this->report->passed();
                $this->logger->info('Passed');
            }
    Severity: Minor
    Found in src/Request/RequestProcessor.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 getRawHookData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $this->rawHookData = $hookdata;
            }
    Severity: Minor
    Found in src/Request/HookHandler.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 '$event'.
    Open

        protected function onBeforeAll(BeforeAll $event)
    Severity: Minor
    Found in src/Hook/Repeat.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 '\GuzzleHttp\HandlerStack' in method 'create'.
    Open

                    'handler' => HandlerStack::create($handler)
    Severity: Minor
    Found in src/Request/HttpClientFactory.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 local variables such as '$value'.
    Open

            foreach ($expected as $header => $value) {
    Severity: Minor
    Found in src/Validation/Validator/Header.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

    Avoid unused parameters such as '$output'.
    Open

        protected function execute(InputInterface $input, OutputInterface $output)
    Severity: Minor
    Found in src/Command/RunCommand.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 indent uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    if (($char == '}' || $char == ']') && $outOfQuotes) {
                        $result .= $newLine;
                        $pos--;
                        for ($j = 0; $j < $pos; $j++) {
    Severity: Minor
    Found in src/Formatter/JsonFormatter.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 '$event'.
    Open

        private function onBeforeEach(BeforeEach $event)
    Severity: Minor
    Found in src/Hook/HelloSharedData.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