vaimo/composer-patches

View on GitHub
src/Composer/Commands/ValidateCommand.php

Summary

Maintainability
B
5 hrs
Test Coverage

File ValidateCommand.php has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Copyright © Vaimo Group. All rights reserved.
 * See LICENSE_VAIMO.txt for license details.
 */
Severity: Minor
Found in src/Composer/Commands/ValidateCommand.php - About 2 hrs to fix

    Method collectPatchFilesFromPackages has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function collectPatchFilesFromPackages(array $matches, Config $pluginConfig)
        {
            $composer = $this->getComposer();
            $composerConfig = $composer->getConfig();
    
    
    Severity: Minor
    Found in src/Composer/Commands/ValidateCommand.php - About 1 hr to fix

      Method execute has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $output->writeln('<info>Scanning packages for orphan patches</info>');
      
              $composer = $this->getComposer();
      Severity: Minor
      Found in src/Composer/Commands/ValidateCommand.php - About 1 hr to fix

        Missing class import via use statement (line '57', column '34').
        Open

                $patchListAnalyser = new \Vaimo\ComposerPatches\Patch\DefinitionList\Analyser();

        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 '144', column '36').
        Open

                $configReaderFactory = new \Vaimo\ComposerPatches\Factories\PatcherConfigReaderFactory($composer);

        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 '207', column '33').
        Open

                $packageListUtils = new \Vaimo\ComposerPatches\Utils\PackageListUtils();

        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 '63', column '31').
        Open

                $contextFactory = new \Vaimo\ComposerPatches\Factories\ComposerContextFactory($composer);

        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 '206', column '35').
        Open

                $srcResolverFactory = new \Vaimo\ComposerPatches\Factories\SourcesResolverFactory($composer);

        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 '147', column '32').
        Open

                $fileSystemUtils = new \Vaimo\ComposerPatches\Utils\FileSystemUtils();

        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 '66', column '30').
        Open

                $configFactory = new \Vaimo\ComposerPatches\Factories\ConfigFactory($composerContext, array(

        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 '146', column '28').
        Open

                $filterUtils = new \Vaimo\ComposerPatches\Utils\FilterUtils();

        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 '213', column '32').
        Open

                $repositoryUtils = new \Vaimo\ComposerPatches\Utils\RepositoryUtils();

        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 '145', column '26').
        Open

                $dataUtils = new \Vaimo\ComposerPatches\Utils\DataUtils();

        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 '202', column '32').
        Open

                $packageResolver = new \Vaimo\ComposerPatches\Composer\Plugin\PackageResolver(

        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 '237', column '30').
        Open

                $loaderFactory = new \Vaimo\ComposerPatches\Factories\PatchesLoaderFactory($composer);

        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 using static access to class '\Vaimo\ComposerPatches\Utils\PathUtils' in method 'findWithMissingConfig'.
        Open

                        'path' => $config[Patch::URL] ?: PathUtils::reducePathLeft($path, $installPath)

        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 using static access to class '\Vaimo\ComposerPatches\Utils\PathUtils' in method 'findWithMissingFile'.
        Open

                        'path' => $config[Patch::URL] ?: PathUtils::reducePathLeft($path, $installPath)

        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

        Define a constant instead of duplicating this literal "issue" 3 times.
        Open

                        'issue' => 'NO CONFIG',

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::getComposer
        Open

                $composer = $this->getComposer();
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::getComposer
        Open

                $composer = $this->getComposer();
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::addOption
        Open

                $this->addOption(
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
        Open

                $output->writeln('<info>Scanning packages for orphan patches</info>');
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
        Open

                    $output->writeln($line);
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::setName
        Open

                $this->setName('patch:validate');
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Reference to constant VALUE_NONE from undeclared class \Symfony\Component\Console\Input\InputOption
        Open

                    InputOption::VALUE_NONE,
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::addOption
        Open

                $this->addOption(
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
        Open

                $output->writeln(
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Checking instanceof against undeclared class \Composer\Package\RootPackageInterface
        Open

                    $installPaths[$packageName] = $package instanceof \Composer\Package\RootPackageInterface
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

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

                $pluginName = $pluginPackage->getName();
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::getIO
        Open

                $appIO = $this->getIO();
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Parameter $output has undeclared type \Symfony\Component\Console\Output\OutputInterface
        Open

            private function outputOrphans(OutputInterface $output, array $groups)

        Reference to undeclared class \Composer\Command\BaseCommand
        Open

                parent::configure();
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Parameter $input has undeclared type \Symfony\Component\Console\Input\InputInterface
        Open

            protected function execute(InputInterface $input, OutputInterface $output)

        Call to method getCanonicalPackages from undeclared class \Composer\Repository\WritableRepositoryInterface
        Open

                    $repository->getCanonicalPackages(),
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::getComposer
        Open

                $composer = $this->getComposer();
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to method getOption from undeclared class \Symfony\Component\Console\Input\InputInterface
        Open

                    Config::PATCHER_FROM_SOURCE => (bool)$input->getOption('from-source')
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

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

            private function resolveValidationTargets(PackageRepository $repository, Config $pluginConfig)

        Class extends undeclared class \Composer\Command\BaseCommand
        Open

        class ValidateCommand extends \Composer\Command\BaseCommand
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Parameter $output has undeclared type \Symfony\Component\Console\Output\OutputInterface
        Open

            protected function execute(InputInterface $input, OutputInterface $output)

        Call to method getOption from undeclared class \Symfony\Component\Console\Input\InputInterface
        Open

                $localOnly = $input->getOption('local');
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::getComposer
        Open

                $composer = $this->getComposer();
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::getComposer
        Open

                $composer = $this->getComposer();
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ValidateCommand::setDescription
        Open

                $this->setDescription('Validate that all patches have proper target configuration');
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        Reference to constant VALUE_NONE from undeclared class \Symfony\Component\Console\Input\InputOption
        Open

                    InputOption::VALUE_NONE,
        Severity: Critical
        Found in src/Composer/Commands/ValidateCommand.php by phan

        There are no issues that match your filters.

        Category
        Status