AJenbo/php-tracer-weaver

View on GitHub
src/PHPWeaver/Command/WeaveCommand.php

Summary

Maintainability
A
3 hrs
Test Coverage

Function getFilesToProcess has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function getFilesToProcess(array $pathsToWeave): array
    {
        $filesToWeave = [];

        foreach ($pathsToWeave as $pathToWeave) {
Severity: Minor
Found in src/PHPWeaver/Command/WeaveCommand.php - About 1 hr 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

Method setupFileProcesser has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function setupFileProcesser(Signatures $sigs): void
    {
        $this->scanner = new ScannerMultiplexer();
        $parametersScanner = new FunctionParametersScanner();
        $functionBodyScanner = new FunctionBodyScanner();
Severity: Minor
Found in src/PHPWeaver/Command/WeaveCommand.php - About 1 hr to fix

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

        private function parseTrace(string $tracefile): Signatures
        {
            $sigs = new Signatures();
            if (is_file($tracefile)) {
                $traceFile = new SplFileObject($tracefile);
    Severity: Minor
    Found in src/PHPWeaver/Command/WeaveCommand.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 transformFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private function transformFiles(array $filesToWeave, Signatures $sigs): void
        {
            $this->progressBarStart(count($filesToWeave), '<info>Updating source files …</info>');
    
            foreach ($filesToWeave as $fileToWeave) {
    Severity: Minor
    Found in src/PHPWeaver/Command/WeaveCommand.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 class WeaveCommand has a coupling between objects value of 26. Consider to reduce the number of dependencies under 13.
    Open

    class WeaveCommand extends Command
    {
        const RETURN_CODE_OK = 0;
        const RETURN_CODE_ERROR = 1;
        const REFRESH_RATE_INTERVAL = 0.033333334; // 30hz

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    There are no issues that match your filters.

    Category
    Status