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);
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);
- 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
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,
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 {
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])
- 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
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,
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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(
- 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 '129', column '38'). Open
$this->outputGenerator = new \Vaimo\ComposerPatches\Console\OutputGenerator($logger);
- 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 '136', column '35'). Open
$this->compExecutor = new \Vaimo\ComposerPatches\Compatibility\Executor();
- 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 '131', column '40'). Open
$this->patchListAnalyser = new \Vaimo\ComposerPatches\Patch\DefinitionList\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
Missing class import via use statement (line '132', column '43'). Open
$this->patchListTransformer = new \Vaimo\ComposerPatches\Patch\DefinitionList\Transformer();
- 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 '133', column '35'). Open
$this->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 '134', column '35'). Open
$this->packageUtils = new \Vaimo\ComposerPatches\Utils\PackageUtils();
- 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 '32'). Open
$this->dataUtils = new \Vaimo\ComposerPatches\Utils\DataUtils();
- 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 '310', column '27'). Open
throw new \Vaimo\ComposerPatches\Exceptions\PackageNotFound(
- 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
Parameter $composer
has undeclared type \Composer\Composer
Open
public function __construct(
- Exclude checks
Parameter $package
has undeclared type \Composer\Package\PackageInterface
Open
private function updatePackage(Package $package, Repository $repository, array $additions, array $removals)
- Exclude checks
Parameter $package
has undeclared type \Composer\Package\PackageInterface
Open
private function processPatchesForPackage(Repository $repository, Package $package, array $patchesQueue)
- Exclude checks
Parameter $repository
has undeclared type \Composer\Repository\WritableRepositoryInterface
Open
private function updatePackage(Package $package, Repository $repository, array $additions, array $removals)
- Exclude checks
Parameter $repository
has undeclared type \Composer\Repository\WritableRepositoryInterface
Open
private function processQueues(Package $package, Repository $repository, $additions, $removals)
- Exclude checks
Property \Vaimo\ComposerPatches\Repository\PatchesApplier->composer
has undeclared type \Composer\Composer
Open
private $composer;
- Exclude checks
Parameter $repository
has undeclared type \Composer\Repository\WritableRepositoryInterface
Open
public function apply(Repository $repository, array $patches)
- Exclude checks
Parameter $repository
has undeclared type \Composer\Repository\WritableRepositoryInterface
Open
private function processPatchesForPackage(Repository $repository, Package $package, array $patchesQueue)
- Exclude checks
Parameter $package
has undeclared type \Composer\Package\PackageInterface
Open
private function processQueues(Package $package, Repository $repository, $additions, $removals)
- Exclude checks
Argument 2 (callback)
is Closure(mixed):array
but \array_filter()
takes callable(mixed):bool|callable(mixed,mixed):bool
Open
function ($data) use ($changedTargets) {
- Exclude checks
Call to method getName
from undeclared class \Composer\Package\PackageInterface
Open
$packageName = $package->getName();
- Exclude checks