TikiWiki/tiki-manager

View on GitHub

Showing 2,238 of 2,238 total issues

The method execute uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $output->writeln('<comment>No instances available to access.</comment>');
        }
Severity: Minor
Found in src/Command/AccessInstanceCommand.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The method fixPermissions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $extraParameters = ['-n']; //by default detect the current user and do not ask

                    // detect (guess) if we should pass a given user to the command, normally when running as root
                    if ($access->user == 'root' && preg_match('/\/home\/([^\/]+)\/.*/', $instance->webroot, $matches)) {
Severity: Minor
Found in src/Application/Tiki.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The method applyPatch uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            // For packages installed via Tiki Package Manager
            $folder = 'vendor/';
            if (substr($patch->package, 0, strlen($folder)) === $folder) {
                $access->chdir($this->instance->getWebPath($patch->package));
Severity: Minor
Found in src/Application/Tiki.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\TikiManager\Command\Helper\CommandHelper' in method 'execute'.
Open

                CommandHelper::validateInstanceSelection($instancesOption, $instances);
Severity: Minor
Found in src/Command/AccessInstanceCommand.php by phpmd

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 '\TikiManager\Command\Helper\CommandHelper' in method 'interact'.
Open

                $selectedInstances = CommandHelper::validateInstanceSelection($answer, $instances);
Severity: Minor
Found in src/Command/ApplyPatchCommand.php by phpmd

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 assigning values to variables in if clauses and the like (line '661', column '21').
Open

    public function applyPatch(Patch $patch, $options)
    {
        $access = $this->instance->getBestAccess('scripting');
        $vcsType = $this->vcs_instance->getIdentifier();
        $can_patch = $access->hasExecutable('patch');
Severity: Minor
Found in src/Application/Tiki.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 using static access to class '\TikiManager\Libs\Audit\Checksum' in method 'recordFiles'.
Open

        return Checksum::addFiles($this->id, $hashFiles);
Severity: Minor
Found in src/Application/Version.php by phpmd

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 '\TikiManager\Command\Helper\CommandHelper' in method 'interact'.
Open

        $instances = CommandHelper::getInstances('tiki');
Severity: Minor
Found in src/Command/ApplyPatchCommand.php by phpmd

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 '\Symfony\Component\Process\Process' in method 'extractTo'.
Open

        $composerCmd = Process::fromShellCommandline("composer install -d $folder/vendor_bundled/ --no-interaction --prefer-dist --no-dev --quiet", null, null, null, 1800);
Severity: Minor
Found in src/Application/Tiki.php by phpmd

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 '\TikiManager\Command\Helper\CommandHelper' in method 'interact'.
Open

        $instancesInfo = CommandHelper::getInstancesInfo($instances);
Severity: Minor
Found in src/Command/ApplyPatchCommand.php by phpmd

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

The method findByBranchName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                return version_compare($tikiVersion, $requirement->getVersion(), '>=');
            }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\TikiManager\Libs\Helpers\ApplicationHelper' in method 'backupDatabase'.
Open

        if (!$access instanceof ShellPrompt || (ApplicationHelper::isWindows() && $this->instance->type == 'local')) {
Severity: Minor
Found in src/Application/Tiki.php by phpmd

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

The method installTikiPackages() has an NPath complexity of 216. The configured NPath complexity threshold is 200.
Open

    public function installTikiPackages(bool $update = false)
    {
        $instance = $this->instance;
        $access = $instance->getBestAccess();

Severity: Minor
Found in src/Application/Tiki.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

Avoid using static access to class '\TikiManager\Libs\Audit\Checksum' in method 'collectChecksumFromSource'.
Open

        return Checksum::saveChecksums($this->id, $result);
Severity: Minor
Found in src/Application/Version.php by phpmd

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

The method applyPatch uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $this->io->writeln("Patch already applied, skipping.");
                $result = false;
            }
Severity: Minor
Found in src/Application/Tiki.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\TikiManager\Libs\Audit\Checksum' in method 'collectChecksumFromSource'.
Open

        $result = Checksum::checksumSource($this, $app);
Severity: Minor
Found in src/Application/Version.php by phpmd

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 '\TikiManager\Command\Helper\CommandHelper' in method 'execute'.
Open

                CommandHelper::renderInstancesTable($output, $instancesInfo);
Severity: Minor
Found in src/Command/AccessInstanceCommand.php by phpmd

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

The method restoreDatabase uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $systemConfigFilePath = '';

            if (isset($this->instance->system_config_file)) {
                $srcSystemConfigFilePath = $this->instance->system_config_file;
Severity: Minor
Found in src/Application/Tiki.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\TikiManager\Libs\Audit\Checksum' in method 'hasChecksums'.
Open

        return Checksum::hasChecksums($this->id);
Severity: Minor
Found in src/Application/Version.php by phpmd

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 '\TikiManager\Command\Helper\CommandHelper' in method 'interact'.
Open

                    $selectedInstances = CommandHelper::validateInstanceSelection($answer, $instances);
Severity: Minor
Found in src/Command/BackupInstanceCommand.php by phpmd

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

Severity
Category
Status
Source
Language