File ListCommand.php
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Copyright © Vaimo Group. All rights reserved.
* See LICENSE_VAIMO.txt for license details.
*/
Method execute
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$isDevMode = !$input->getOption('no-dev');
Method configure
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function configure()
{
parent::configure();
$this->setName('patch:list');
Method composerFilteredPatchesList
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function composerFilteredPatchesList($patches, $additions, $removals, $withAffected, $filters, $statuses)
{
$hasFilers = (bool)array_filter($filters);
$listResolver = new ListResolvers\FilteredListResolver($filters);
Method composerFilteredPatchesList
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function composerFilteredPatchesList($patches, $additions, $removals, $withAffected, $filters, $statuses)
Function execute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$isDevMode = !$input->getOption('no-dev');
- Read upRead up
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 generateOutput
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function generateOutput(OutputInterface $output, array $list)
{
$statusConfig = new \Vaimo\ComposerPatches\Package\PatchApplier\StatusConfig();
$statusDecorators = $statusConfig->getLabels();
- Read upRead up
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 method execute() has 103 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$isDevMode = !$input->getOption('no-dev');
- Exclude checks
Missing class import via use statement (line '150', column '31'). Open
$patchListUtils = new \Vaimo\ComposerPatches\Utils\PatchListUtils();
- Read upRead up
- Exclude checks
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 '303', column '33'). Open
$packageCollector = new \Vaimo\ComposerPatches\Package\Collector(
- Read upRead up
- Exclude checks
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 '239', column '31'). Open
$patchListUtils = new \Vaimo\ComposerPatches\Utils\PatchListUtils();
- Read upRead up
- Exclude checks
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 '240', column '33'). Open
$patchListUpdater = new \Vaimo\ComposerPatches\Patch\DefinitionList\Updater();
- Read upRead up
- Exclude checks
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 '30'). Open
$loaderFactory = new \Vaimo\ComposerPatches\Factories\PatchesLoaderFactory($composer);
- Read upRead up
- Exclude checks
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 '325', column '30'). Open
$componentPool = new \Vaimo\ComposerPatches\Patch\DefinitionList\Loader\ComponentPool(
- Read upRead up
- Exclude checks
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 '151', column '33'). Open
$patchListUpdater = new \Vaimo\ComposerPatches\Patch\DefinitionList\Updater();
- Read upRead up
- Exclude checks
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 '282', column '31'). Open
$configDefaults = new \Vaimo\ComposerPatches\Config\Defaults();
- Read upRead up
- Exclude checks
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 '317', column '20'). Open
return new \Vaimo\ComposerPatches\Repository\PatchesApplier\QueueGenerator(
- Read upRead up
- Exclude checks
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 '127', column '31'). Open
$contextFactory = new \Vaimo\ComposerPatches\Factories\ComposerContextFactory($composer);
- Read upRead up
- Exclude checks
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 '164', column '28'). Open
$filterUtils = new \Vaimo\ComposerPatches\Utils\FilterUtils();
- Read upRead up
- Exclude checks
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 '307', column '20'). Open
return new \Vaimo\ComposerPatches\Repository\StateGenerator(
- Read upRead up
- Exclude checks
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 '340', column '29'). Open
$statusConfig = new \Vaimo\ComposerPatches\Package\PatchApplier\StatusConfig();
- Read upRead up
- Exclude checks
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 '268', column '32'). Open
$filterUtils = new \Vaimo\ComposerPatches\Utils\FilterUtils();
- Read upRead up
- Exclude checks
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 '296', column '30'). Open
$configFactory = new \Vaimo\ComposerPatches\Factories\ConfigFactory($composerContext);
- Read upRead up
- Exclude checks
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 '216', column '36'). Open
$packageInfoResolver = new \Vaimo\ComposerPatches\Package\InfoResolver(
- Read upRead up
- Exclude checks
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 '315', column '30'). Open
$stateAnalyser = new \Vaimo\ComposerPatches\Repository\State\Analyser();
- Read upRead up
- Exclude checks
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
The method execute uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->generateOutput($output, $patches);
}
- Read upRead up
- Exclude checks
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
Define a constant instead of duplicating this literal "excluded" 4 times. Open
$withExcluded = $input->getOption('excluded') || $input->getOption('with-excludes');
- Read upRead up
- Exclude checks
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\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Reference to constant VALUE_NONE
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_NONE,
- Exclude checks
Call to method getOption
from undeclared class \Symfony\Component\Console\Input\InputInterface
Open
$beBrief = $input->getOption('brief');
- Exclude checks
Call to method getPackage
from undeclared class \Composer\Composer
Open
array($composer->getPackage())
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::setName
Open
$this->setName('patch:list');
- Exclude checks
Reference to constant VALUE_NONE
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_NONE,
- Exclude checks
Reference to constant VALUE_IS_ARRAY
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
- Exclude checks
Call to method getOption
from undeclared class \Symfony\Component\Console\Input\InputInterface
Open
$withAffected = $input->getOption('with-affected');
- Exclude checks
Call to method writeln
from undeclared class \Symfony\Component\Console\Output\OutputInterface
Open
$output->writeln(json_encode($patches));
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::setDescription
Open
$this->setDescription('List all registered and eligible (based on project config) patches');
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Parameter $output
has undeclared type \Symfony\Component\Console\Output\OutputInterface
Open
protected function execute(InputInterface $input, OutputInterface $output)
- Exclude checks
Reference to undeclared class \Composer\Command\BaseCommand
Open
parent::configure();
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Call to method getArgument
from undeclared class \Symfony\Component\Console\Input\InputInterface
Open
Patch::TARGETS => $input->getArgument('targets')
- Exclude checks
Parameter $output
has undeclared type \Symfony\Component\Console\Output\OutputInterface
Open
private function generateOutput(OutputInterface $output, array $list)
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addArgument
Open
$this->addArgument(
- Exclude checks
Call to method writeln
from undeclared class \Symfony\Component\Console\Output\OutputInterface
Open
$output->writeln($owner ? sprintf(' ~ %s', $patchInfoLabel) : $patchInfoLabel);
- Exclude checks
Reference to constant IS_ARRAY
from undeclared class \Symfony\Component\Console\Input\InputArgument
Open
InputArgument::IS_ARRAY,
- Exclude checks
Reference to constant VALUE_NONE
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_NONE,
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Reference to constant VALUE_NONE
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_NONE,
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::getComposer
Open
$composer = $this->getComposer();
- Exclude checks
Call to method getOption
from undeclared class \Symfony\Component\Console\Input\InputInterface
Open
$isDevMode = !$input->getOption('no-dev');
- Exclude checks
Call to method getOption
from undeclared class \Symfony\Component\Console\Input\InputInterface
Open
array_filter((array)$input->getOption('status'))
- Exclude checks
Call to method writeln
from undeclared class \Symfony\Component\Console\Output\OutputInterface
Open
$output->writeln('');
- Exclude checks
Reference to constant VALUE_OPTIONAL
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Reference to constant VALUE_NONE
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_NONE,
- Exclude checks
Parameter $input
has undeclared type \Symfony\Component\Console\Input\InputInterface
Open
protected function execute(InputInterface $input, OutputInterface $output)
- Exclude checks
Reference to constant VALUE_NONE
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_NONE,
- Exclude checks
Call to method getOption
from undeclared class \Symfony\Component\Console\Input\InputInterface
Open
Patch::SOURCE => $input->getOption('filter'),
- Exclude checks
Call to method getOption
from undeclared class \Symfony\Component\Console\Input\InputInterface
Open
if ($input->getOption('json')) {
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::getIO
Open
$this->getIO(),
- Exclude checks
Reference to constant VALUE_OPTIONAL
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
- Exclude checks
Reference to undeclared constant \Vaimo\ComposerPatches\Composer\Commands\ListCommand::SUCCESS
Open
return self::SUCCESS;
- Exclude checks
Class extends undeclared class \Composer\Command\BaseCommand
Open
class ListCommand extends \Composer\Command\BaseCommand
- Exclude checks
Call to method getOption
from undeclared class \Symfony\Component\Console\Input\InputInterface
Open
$withExcluded = $input->getOption('excluded') || $input->getOption('with-excludes');
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Reference to constant VALUE_NONE
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_NONE,
- Exclude checks
Parameter $composer
has undeclared type \Composer\Composer
Open
private function createStateGenerator(Composer $composer)
- Exclude checks
Call to method writeln
from undeclared class \Symfony\Component\Console\Output\OutputInterface
Open
$output->writeln(sprintf('<info>%s</info>', $packageName));
- Exclude checks
Argument #1 of this call to \preg_match
is typically a literal or constant but isn't, but argument #2 (which is typically a variable) is a literal or constant. The arguments may be in the wrong order. Open
|| preg_match($filterUtils->composeRegex($statusFilters, '/'), 'excluded')
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Call to undeclared method \Vaimo\ComposerPatches\Composer\Commands\ListCommand::addOption
Open
$this->addOption(
- Exclude checks
Reference to constant VALUE_IS_ARRAY
from undeclared class \Symfony\Component\Console\Input\InputOption
Open
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
- Exclude checks
Call to method writeln
from undeclared class \Symfony\Component\Console\Output\OutputInterface
Open
$output->writeln(sprintf(' <comment>%s</comment>', $line));
- Exclude checks