vaimo/composer-patches

View on GitHub
src/Repository/PatchesApplier.php

Summary

Maintainability
B
6 hrs
Test Coverage

Method apply has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function apply(Repository $repository, array $patches)
    {
        $packages = $this->packageCollector->collect($repository);
        $packagesUpdated = false;
        $repositoryState = $this->repoStateGenerator->generate($repository);
Severity: Major
Found in src/Repository/PatchesApplier.php - About 2 hrs to fix

    Function apply has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function apply(Repository $repository, array $patches)
        {
            $packages = $this->packageCollector->collect($repository);
            $packagesUpdated = false;
            $repositoryState = $this->repoStateGenerator->generate($repository);
    Severity: Minor
    Found in src/Repository/PatchesApplier.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 __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            \Composer\Composer $composer,
            \Vaimo\ComposerPatches\Package\Collector $packageCollector,
            \Vaimo\ComposerPatches\Managers\RepositoryManager $repositoryManager,
            \Vaimo\ComposerPatches\Package\PatchApplier $patchApplier,
            \Vaimo\ComposerPatches\Repository\PatchesApplier\QueueGenerator $queueGenerator,
    Severity: Major
    Found in src/Repository/PatchesApplier.php - About 1 hr to fix

      Method processPatchesForPackage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function processPatchesForPackage(Repository $repository, Package $package, array $patchesQueue)
          {
              $processIndentation = $this->logger->push('~');
      
              try {
      Severity: Minor
      Found in src/Repository/PatchesApplier.php - About 1 hr to fix

        Function updateStatusLabels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function updateStatusLabels(array $queue, array $labels)
            {
                foreach ($queue as $target => $group) {
                    foreach ($group as $path => $item) {
                        $status = isset($item[Patch::STATUS])
        Severity: Minor
        Found in src/Repository/PatchesApplier.php - About 35 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

        This function has 9 parameters, which is greater than the 7 authorized.
        Open

            public function __construct(
                \Composer\Composer $composer,
                \Vaimo\ComposerPatches\Package\Collector $packageCollector,
                \Vaimo\ComposerPatches\Managers\RepositoryManager $repositoryManager,
                \Vaimo\ComposerPatches\Package\PatchApplier $patchApplier,
        Severity: Major
        Found in src/Repository/PatchesApplier.php by sonar-php

        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

        Noncompliant Code Example

        With a maximum number of 4 parameters:

        function doSomething($param1, $param2, $param3, $param4, $param5) {
        ...
        }
        

        Compliant Solution

        function doSomething($param1, $param2, $param3, $param4) {
        ...
        }
        

        Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
        Open

            public function apply(Repository $repository, array $patches)
        Severity: Critical
        Found in src/Repository/PatchesApplier.php by sonar-php

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Missing class import via use statement (line '125', column '41').
        Open

                $this->repoStateGenerator = new \Vaimo\ComposerPatches\Repository\StateGenerator(
        Severity: Minor
        Found in src/Repository/PatchesApplier.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 '129', column '38').
        Open

                $this->outputGenerator = new \Vaimo\ComposerPatches\Console\OutputGenerator($logger);
        Severity: Minor
        Found in src/Repository/PatchesApplier.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 '136', column '35').
        Open

                $this->compExecutor = new \Vaimo\ComposerPatches\Compatibility\Executor();
        Severity: Minor
        Found in src/Repository/PatchesApplier.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 '131', column '40').
        Open

                $this->patchListAnalyser = new \Vaimo\ComposerPatches\Patch\DefinitionList\Analyser();
        Severity: Minor
        Found in src/Repository/PatchesApplier.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 '132', column '43').
        Open

                $this->patchListTransformer = new \Vaimo\ComposerPatches\Patch\DefinitionList\Transformer();
        Severity: Minor
        Found in src/Repository/PatchesApplier.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 '133', column '35').
        Open

                $this->statusConfig = new \Vaimo\ComposerPatches\Package\PatchApplier\StatusConfig();
        Severity: Minor
        Found in src/Repository/PatchesApplier.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 '134', column '35').
        Open

                $this->packageUtils = new \Vaimo\ComposerPatches\Utils\PackageUtils();
        Severity: Minor
        Found in src/Repository/PatchesApplier.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 '135', column '32').
        Open

                $this->dataUtils = new \Vaimo\ComposerPatches\Utils\DataUtils();
        Severity: Minor
        Found in src/Repository/PatchesApplier.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 '310', column '27').
        Open

                        throw new \Vaimo\ComposerPatches\Exceptions\PackageNotFound(
        Severity: Minor
        Found in src/Repository/PatchesApplier.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

        Parameter $composer has undeclared type \Composer\Composer
        Open

            public function __construct(
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Parameter $package has undeclared type \Composer\Package\PackageInterface
        Open

            private function updatePackage(Package $package, Repository $repository, array $additions, array $removals)
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Parameter $package has undeclared type \Composer\Package\PackageInterface
        Open

            private function processPatchesForPackage(Repository $repository, Package $package, array $patchesQueue)
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Parameter $repository has undeclared type \Composer\Repository\WritableRepositoryInterface
        Open

            private function updatePackage(Package $package, Repository $repository, array $additions, array $removals)
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Parameter $repository has undeclared type \Composer\Repository\WritableRepositoryInterface
        Open

            private function processQueues(Package $package, Repository $repository, $additions, $removals)
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Property \Vaimo\ComposerPatches\Repository\PatchesApplier->composer has undeclared type \Composer\Composer
        Open

            private $composer;
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Parameter $repository has undeclared type \Composer\Repository\WritableRepositoryInterface
        Open

            public function apply(Repository $repository, array $patches)
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Parameter $repository has undeclared type \Composer\Repository\WritableRepositoryInterface
        Open

            private function processPatchesForPackage(Repository $repository, Package $package, array $patchesQueue)
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Parameter $package has undeclared type \Composer\Package\PackageInterface
        Open

            private function processQueues(Package $package, Repository $repository, $additions, $removals)
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Argument 2 (callback) is Closure(mixed):array but \array_filter() takes callable(mixed):bool|callable(mixed,mixed):bool
        Open

                        function ($data) use ($changedTargets) {
        Severity: Minor
        Found in src/Repository/PatchesApplier.php by phan

        Call to method getName from undeclared class \Composer\Package\PackageInterface
        Open

                $packageName = $package->getName();
        Severity: Critical
        Found in src/Repository/PatchesApplier.php by phan

        There are no issues that match your filters.

        Category
        Status