andreypostal/cli

View on GitHub
examples/ProgressBar/Service.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid unused parameters such as '$context'.
Wontfix

    public function process(Context $context): void
Severity: Minor
Found in examples/ProgressBar/Service.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

Call to undeclared method \Andrey\Cli\Examples\ProgressBar\Service::endProgressBar
Open

        $this->endProgressBar();
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Parameter $context has undeclared type \Andrey\Cli\Types\Context
Open

    public function process(Context $context): void
Severity: Minor
Found in examples/ProgressBar/Service.php by phan

Class uses undeclared trait \Andrey\Cli\Components\ProgressBar
Invalid

class Service
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Reference to constant INFO from undeclared class \Andrey\Cli\Types\ConsoleLevel
Open

        self::center('And we are done :)', ConsoleLevel::INFO);
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Call to undeclared method \Andrey\Cli\Examples\ProgressBar\Service::addProgress
Open

            $this->addProgress(2);
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Static call to undeclared method \Andrey\Cli\Examples\ProgressBar\Service::center
Open

        self::center('Check this really nice progress bar', ConsoleLevel::HIGHLIGHT);
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Class uses undeclared trait \Andrey\Cli\Utils\Output
Invalid

class Service
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Reference to constant HIGHLIGHT from undeclared class \Andrey\Cli\Types\ConsoleLevel
Open

        self::center('Check this really nice progress bar', ConsoleLevel::HIGHLIGHT);
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Static call to undeclared method \Andrey\Cli\Examples\ProgressBar\Service::center
Open

        self::center('Thanks for watching!');
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Static call to undeclared method \Andrey\Cli\Examples\ProgressBar\Service::center
Open

        self::center('And we are done :)', ConsoleLevel::INFO);
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Call to undeclared method \Andrey\Cli\Examples\ProgressBar\Service::initProgressBar
Open

        $this->initProgressBar($totalItems);
Severity: Critical
Found in examples/ProgressBar/Service.php by phan

Remove the unused function parameter "$context".
Wontfix

    public function process(Context $context): void
Severity: Major
Found in examples/ProgressBar/Service.php by sonar-php

Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

Noncompliant Code Example

function doSomething($a, $b) { // "$a" is unused
  return compute($b);
}

Compliant Solution

function doSomething($b) {
  return compute($b);
}

Exceptions

Functions in classes that override a class or implement interfaces are ignored.

class C extends B {

  function doSomething($a, $b) {     // no issue reported on $b
    compute($a);
  }

}

See

  • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
  • MISRA C:2012, 2.7 - There should be no unused parameters in functions
  • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
  • CERT, MSC12-CPP. - Detect and remove code that has no effect

There are no issues that match your filters.

Category
Status