Method process
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(array $patches, array $packagesByName)
{
$ownerName = $this->ownerPackage->getName();
$relativePath = PathUtils::composePath($ownerName, 'downloads');
$absolutePath = PathUtils::composePath($this->vendorDir, $relativePath);
Function process
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function process(array $patches, array $packagesByName)
{
$ownerName = $this->ownerPackage->getName();
$relativePath = PathUtils::composePath($ownerName, 'downloads');
$absolutePath = PathUtils::composePath($this->vendorDir, $relativePath);
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
\Composer\Composer $composer,
\Composer\Package\PackageInterface $ownerPackage,
\Composer\Downloader\FileDownloader $downloadManager,
\Vaimo\ComposerPatches\Console\Silencer $consoleSilencer,
$vendorDir,
Missing class import via use statement (line '156', column '24'). Open
$package = new \Composer\Package\Package($name, $version, $version);
- 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 '76', 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 '77', column '35'). Open
$this->errorHandler = new \Vaimo\ComposerPatches\ErrorHandlers\TransportErrorHandler($gracefulMode);
- 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
Avoid using static access to class '\Vaimo\ComposerPatches\Utils\PathUtils' in method 'process'. Open
$destinationFile = PathUtils::composePath($destDir, basename($source));
- Read upRead up
- Exclude checks
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 'process'. Open
$absolutePath = PathUtils::composePath($this->vendorDir, $relativePath);
- Read upRead up
- Exclude checks
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 'process'. Open
$relativePath = PathUtils::composePath($ownerName, 'downloads');
- Read upRead up
- Exclude checks
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 'process'. Open
$destDir = PathUtils::composePath($absolutePath, $sourceHash);
- Read upRead up
- Exclude checks
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
Rename "$compExecutor" which has the same name as the field declared at line 46. Open
$compExecutor = $this->compExecutor;
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Rename "$errorHandler" which has the same name as the field declared at line 51. Open
$errorHandler = $this->errorHandler;
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Avoid unused parameters such as '$packagesByName'. Open
public function process(array $patches, array $packagesByName)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Property \Vaimo\ComposerPatches\Patch\DefinitionList\LoaderComponents\DownloaderComponent->ownerPackage
has undeclared type \Composer\Package\PackageInterface
Open
private $ownerPackage;
- Exclude checks
Call to method getName
from undeclared class \Composer\Package\PackageInterface
Open
$ownerName = $this->ownerPackage->getName();
- Exclude checks
Call to method setInstallationSource
from undeclared class \Composer\Package\Package
Open
$package->setInstallationSource('dist');
- Exclude checks
Catching undeclared class \Composer\Downloader\TransportException
Open
} catch (\Composer\Downloader\TransportException $exception) {
- Exclude checks
Call to method setDistUrl
from undeclared class \Composer\Package\Package
Open
$package->setDistUrl($remoteFile);
- Exclude checks
Property \Vaimo\ComposerPatches\Patch\DefinitionList\LoaderComponents\DownloaderComponent->composer
has undeclared type \Composer\Composer
Open
private $composer;
- Exclude checks
Parameter $packagesByName
has undeclared type \Composer\Package\PackageInterface[]
Open
public function process(array $patches, array $packagesByName)
- Exclude checks
Call to method __construct
from undeclared class \Composer\Package\Package
Open
$package = new \Composer\Package\Package($name, $version, $version);
- Exclude checks
Parameter $ownerPackage
has undeclared type \Composer\Package\PackageInterface
Open
public function __construct(
- Exclude checks
Call to method setDistSha1Checksum
from undeclared class \Composer\Package\Package
Open
$package->setDistSha1Checksum($checksum);
- Exclude checks
Property \Vaimo\ComposerPatches\Patch\DefinitionList\LoaderComponents\DownloaderComponent->fileDownloader
has undeclared type \Composer\Downloader\FileDownloader
Open
private $fileDownloader;
- Exclude checks
Call to method setDistType
from undeclared class \Composer\Package\Package
Open
$package->setDistType('file');
- Exclude checks
Call to method setTargetDir
from undeclared class \Composer\Package\Package
Open
$package->setTargetDir($targetDir);
- Exclude checks
Parameter $composer
has undeclared type \Composer\Composer
Open
public function __construct(
- Exclude checks
Parameter $downloadManager
has undeclared type \Composer\Downloader\FileDownloader
Open
public function __construct(
- Exclude checks