pug-php/installer

View on GitHub
src/Pug/Installer/Installer.php

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

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();
Severity: Minor
Found in src/Pug/Installer/Installer.php - About 1 hr to fix

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__;

Severity: Minor
Found in src/Pug/Installer/Installer.php - About 1 hr to fix

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();
Severity: Minor
Found in src/Pug/Installer/Installer.php by phpmd

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();
Severity: Minor
Found in src/Pug/Installer/Installer.php by phpmd

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');
Severity: Critical
Found in src/Pug/Installer/Installer.php by phan

Variable $directory is undeclared
Open

            foreach (scandir($directory) as $dependency) {
Severity: Minor
Found in src/Pug/Installer/Installer.php by phan

Parameter $event has undeclared type \Composer\EventDispatcher\Event
Open

    public static function onAutoloadDump(Event $event)
Severity: Minor
Found in src/Pug/Installer/Installer.php by phan

Call to method read from undeclared class \Composer\Json\JsonFile
Open

            $dependencyConfig = $json->read();
Severity: Critical
Found in src/Pug/Installer/Installer.php by phan

Variable $directory is undeclared
Open

                if ($dependency === '.' || $dependency === '..' || !is_dir($subDirectory = $directory . DIRECTORY_SEPARATOR . $dependency)) {
Severity: Minor
Found in src/Pug/Installer/Installer.php by phan

Call to method getComposer from undeclared class \Composer\EventDispatcher\Event
Open

        $composer = $event->getComposer();
Severity: Critical
Found in src/Pug/Installer/Installer.php by phan

Call to method getConfig from undeclared class \Composer\Composer
Open

        return realpath($composer->getConfig()->get('vendor-dir'));
Severity: Critical
Found in src/Pug/Installer/Installer.php by phan

Call to method getComposer from undeclared class \Composer\EventDispatcher\Event
Open

        $vendorDirectory = static::fallbackVendorDir(static::getComposerVendorDir($this->event->getComposer()));
Severity: Critical
Found in src/Pug/Installer/Installer.php by phan

Parameter $composer has undeclared type \Composer\Composer
Open

    protected static function getInstallerConfig(Composer $composer)
Severity: Minor
Found in src/Pug/Installer/Installer.php by phan

Property \Pug\Installer\Installer->event has undeclared type \Composer\EventDispatcher\Event
Open

    protected $event;
Severity: Minor
Found in src/Pug/Installer/Installer.php by phan

Parameter $event has undeclared type \Composer\EventDispatcher\Event
Open

    public function __construct(Event $event)
Severity: Minor
Found in src/Pug/Installer/Installer.php by phan

Variable $subDirectory is undeclared
Open

                static::appendConfig($installers, $subDirectory);
Severity: Minor
Found in src/Pug/Installer/Installer.php by phan

Call to method getIO from undeclared class \Composer\EventDispatcher\Event
Open

            $event->getIO()->write(
Severity: Critical
Found in src/Pug/Installer/Installer.php by phan

Parameter $composer has undeclared type \Composer\Composer
Open

    protected static function getComposerVendorDir(Composer $composer)
Severity: Minor
Found in src/Pug/Installer/Installer.php by phan

Line exceeds 120 characters; contains 127 characters
Open

        return shell_exec($composer . ' require --no-interaction ' . $repository . ($version ? ' ' . $version : '') . ' 2>&1');

Line exceeds 120 characters; contains 127 characters
Open

        include_once static::fallbackVendorDir(static::getComposerVendorDir($composer)) . DIRECTORY_SEPARATOR . 'autoload.php';

Line exceeds 120 characters; contains 131 characters
Open

            if ($namespace === '.' || $namespace === '..' || !is_dir($directory = $vendorDir . DIRECTORY_SEPARATOR . $namespace)) {

Line exceeds 120 characters; contains 141 characters
Open

                if ($dependency === '.' || $dependency === '..' || !is_dir($subDirectory = $directory . DIRECTORY_SEPARATOR . $dependency)) {

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"

There are no issues that match your filters.

Category
Status