Showing 38 of 38 total issues
Function getInstallerConfig
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected static function getInstallerConfig(Composer $composer)
{
$vendorDir = static::getComposerVendorDir($composer);
$installers = array();
- 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 fallbackVendorDir
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function fallbackVendorDir($vendorDirectory, $vendorName = 'vendor')
{
if (!static::looksVendorDir($vendorDirectory)) {
$vendorDirectory = __DIR__;
- 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
Avoid assigning values to variables in if clauses and the like (line '80', column '70'). Open
protected static function getInstallerConfig(Composer $composer)
{
$vendorDir = static::getComposerVendorDir($composer);
$installers = array();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid unused parameters such as '$io'. Open
public function deactivate(Composer $composer, IOInterface $io)
- 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
Avoid assigning values to variables in if clauses and the like (line '84', column '76'). Open
protected static function getInstallerConfig(Composer $composer)
{
$vendorDir = static::getComposerVendorDir($composer);
$installers = array();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid unused parameters such as '$composer'. Open
public function activate(Composer $composer, IOInterface $io)
- 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
Avoid unused parameters such as '$composer'. Open
public function uninstall(Composer $composer, IOInterface $io)
- 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
Avoid unused parameters such as '$composer'. Open
public function deactivate(Composer $composer, IOInterface $io)
- 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
Avoid unused parameters such as '$io'. Open
public function uninstall(Composer $composer, IOInterface $io)
- 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
Avoid using static access to class 'Pug\Installer\Installer' in method 'onAutoloadDump'. Open
Installer::onAutoloadDump($event);
- 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
Line exceeds 120 characters; contains 127 characters Open
return shell_exec($composer . ' require --no-interaction ' . $repository . ($version ? ' ' . $version : '') . ' 2>&1');
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
include_once static::fallbackVendorDir(static::getComposerVendorDir($composer)) . DIRECTORY_SEPARATOR . 'autoload.php';
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
if ($namespace === '.' || $namespace === '..' || !is_dir($directory = $vendorDir . DIRECTORY_SEPARATOR . $namespace)) {
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
if ($dependency === '.' || $dependency === '..' || !is_dir($subDirectory = $directory . DIRECTORY_SEPARATOR . $dependency)) {
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
"Warning: in order to use Pug\\Installer, you should add an \"extra\": {\"installer\": \"YourInstallerClass\"}' setting in your composer.json"
- Exclude checks
Call to method __construct
from undeclared class \Composer\Json\JsonFile
Open
$json = new JsonFile($directory . DIRECTORY_SEPARATOR . 'composer.json');
- Exclude checks
Variable $directory
is undeclared Open
foreach (scandir($directory) as $dependency) {
- Exclude checks
Parameter $composer
has undeclared type \Composer\Composer
Open
public function uninstall(Composer $composer, IOInterface $io)
- Exclude checks
Parameter $event
has undeclared type \Composer\EventDispatcher\Event
Open
public static function onAutoloadDump(Event $event)
- Exclude checks
Class implements undeclared interface \Composer\EventDispatcher\EventSubscriberInterface
Open
class ComposerPlugin implements PluginInterface, EventSubscriberInterface
- Exclude checks