TikiWiki/tiki-manager

View on GitHub
src/Libs/Host/SSHSeclibAdapter.php

Summary

Maintainability
A
1 hr
Test Coverage

getExtHandle accesses the super-global variable $_ENV.
Open

    private function getExtHandle()
    {
        $host = $this->host;
        $user = $this->user;
        $port = $this->port;
Severity: Minor
Found in src/Libs/Host/SSHSeclibAdapter.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Method runCommand has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function runCommand($command, $options = [])
    {
        $handle = self::getExtHandle();
        $cwd = !empty($options['cwd']) ? $options['cwd'] : $this->location;
        $env = !empty($options['env']) ? $options['env'] : $this->env;
Severity: Minor
Found in src/Libs/Host/SSHSeclibAdapter.php - About 1 hr to fix

    The method runCommands has a boolean flag argument $output, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function runCommands($commands, $output = false)
    Severity: Minor
    Found in src/Libs/Host/SSHSeclibAdapter.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Avoid using static access to class '\phpseclib3\Crypt\PublicKeyLoader' in method 'getExtHandle'.
    Open

            if (!$handle->login($user, PublicKeyLoader::load(file_get_contents($_ENV['SSH_KEY'])))) {
    Severity: Minor
    Found in src/Libs/Host/SSHSeclibAdapter.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 unused private methods such as 'getEnv'.
    Open

        private function getEnv()
        {
            return $this->env;
        }
    Severity: Minor
    Found in src/Libs/Host/SSHSeclibAdapter.php by phpmd

    UnusedPrivateMethod

    Since: 0.2

    Unused Private Method detects when a private method is declared but is unused.

    Example

    class Something
    {
        private function foo() {} // unused
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

    Avoid unused private methods such as 'getHost'.
    Open

        private function getHost()
        {
            return $this->host;
        }
    Severity: Minor
    Found in src/Libs/Host/SSHSeclibAdapter.php by phpmd

    UnusedPrivateMethod

    Since: 0.2

    Unused Private Method detects when a private method is declared but is unused.

    Example

    class Something
    {
        private function foo() {} // unused
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

    Avoid unused private methods such as 'getUser'.
    Open

        private function getUser()
        {
            return $this->user;
        }
    Severity: Minor
    Found in src/Libs/Host/SSHSeclibAdapter.php by phpmd

    UnusedPrivateMethod

    Since: 0.2

    Unused Private Method detects when a private method is declared but is unused.

    Example

    class Something
    {
        private function foo() {} // unused
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

    Avoid unused private methods such as 'getLocation'.
    Open

        private function getLocation()
        {
            return $this->location;
        }
    Severity: Minor
    Found in src/Libs/Host/SSHSeclibAdapter.php by phpmd

    UnusedPrivateMethod

    Since: 0.2

    Unused Private Method detects when a private method is declared but is unused.

    Example

    class Something
    {
        private function foo() {} // unused
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

    Avoid unused private methods such as 'getPort'.
    Open

        private function getPort()
        {
            return $this->port;
        }
    Severity: Minor
    Found in src/Libs/Host/SSHSeclibAdapter.php by phpmd

    UnusedPrivateMethod

    Since: 0.2

    Unused Private Method detects when a private method is declared but is unused.

    Example

    class Something
    {
        private function foo() {} // unused
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

    Call with 2 arg(s) to \TikiManager\Libs\Host\SSHSeclibAdapter::setEnv() which only takes 1 arg(s) defined at /code/src/Libs/Host/SSHSeclibAdapter.php:164
    Open

            $this->setenv('HTTP_ACCEPT_ENCODING', '');
    Severity: Info
    Found in src/Libs/Host/SSHSeclibAdapter.php by phan

    There are no issues that match your filters.

    Category
    Status