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 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
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 $event
has undeclared type \Composer\EventDispatcher\Event
Open
public static function onAutoloadDump(Event $event)
- Exclude checks
Call to method read
from undeclared class \Composer\Json\JsonFile
Open
$dependencyConfig = $json->read();
- Exclude checks
Variable $directory
is undeclared Open
if ($dependency === '.' || $dependency === '..' || !is_dir($subDirectory = $directory . DIRECTORY_SEPARATOR . $dependency)) {
- Exclude checks
Call to method getComposer
from undeclared class \Composer\EventDispatcher\Event
Open
$composer = $event->getComposer();
- Exclude checks
Call to method getConfig
from undeclared class \Composer\Composer
Open
return realpath($composer->getConfig()->get('vendor-dir'));
- Exclude checks
Call to method getComposer
from undeclared class \Composer\EventDispatcher\Event
Open
$vendorDirectory = static::fallbackVendorDir(static::getComposerVendorDir($this->event->getComposer()));
- Exclude checks
Parameter $composer
has undeclared type \Composer\Composer
Open
protected static function getInstallerConfig(Composer $composer)
- Exclude checks
Property \Pug\Installer\Installer->event
has undeclared type \Composer\EventDispatcher\Event
Open
protected $event;
- Exclude checks
Parameter $event
has undeclared type \Composer\EventDispatcher\Event
Open
public function __construct(Event $event)
- Exclude checks
Variable $subDirectory
is undeclared Open
static::appendConfig($installers, $subDirectory);
- Exclude checks
Call to method getIO
from undeclared class \Composer\EventDispatcher\Event
Open
$event->getIO()->write(
- Exclude checks
Parameter $composer
has undeclared type \Composer\Composer
Open
protected static function getComposerVendorDir(Composer $composer)
- Exclude checks
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