renoki-co/php-k8s

View on GitHub

Showing 194 of 198 total issues

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

    public function addData(string $name, $value, $encode = true)
Severity: Minor
Found in src/Kinds/K8sSecret.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

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

    public function getWebhook(string $webhookName, bool $asInstance = true)
Severity: Minor
Found in src/Traits/Resource/HasWebhooks.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

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

    public function getJobTemplate(bool $asInstance = true)
Severity: Minor
Found in src/Kinds/K8sCronJob.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

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

    public function getNodeAffinity(bool $asInstance = true)
Severity: Minor
Found in src/Kinds/K8sPod.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

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

    public function getWebhooks(bool $asInstance = true): array
Severity: Minor
Found in src/Traits/Resource/HasWebhooks.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

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

    public function getContainers(bool $asInstance = true): array
Severity: Minor
Found in src/Kinds/K8sPod.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 too many return statements within this method.
Open

        return $this->makeRequest($method, $path, $payload, $query);
Severity: Major
Found in src/KubernetesCluster.php - About 30 mins to fix

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

        public function getInitContainerStatuses(bool $asInstance = true): array
    Severity: Minor
    Found in src/Kinds/K8sPod.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

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

        public function getVolumeClaims(bool $asInstance = true)
    Severity: Minor
    Found in src/Kinds/K8sStatefulSet.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

    Remove error control operator '@' on line 116.
    Open

        protected function makeRequest(string $method, string $path, string $payload = '', array $query = ['pretty' => 1])
        {
            $resourceClass = $this->resourceClass;
    
            $response = $this->call($method, $path, $payload, $query);
    Severity: Minor
    Found in src/Traits/Cluster/MakesHttpCalls.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

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

        public function getRules(bool $asInstance = true): array
    Severity: Minor
    Found in src/Traits/Resource/HasRules.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

    Function getClient has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getClient()
        {
            $options = [
                RequestOptions::HEADERS => [
                    'Content-Type' => 'application/json',
    Severity: Minor
    Found in src/Traits/Cluster/MakesHttpCalls.php - About 25 mins 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 getWsClient has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getWsClient(string $url): array
        {
            $options = [
                'timeout' => 20,
                'tls' => [],
    Severity: Minor
    Found in src/Traits/Cluster/MakesWebsocketCalls.php - About 25 mins 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 runOperation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function runOperation(string $operation, string $path, $payload = '', array $query = ['pretty' => 1])
        {
            switch ($operation) {
                case static::WATCH_OP: return $this->watchPath($path, $payload, $query);
                    break;
    Severity: Minor
    Found in src/KubernetesCluster.php - About 25 mins 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 makeWsRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function makeWsRequest(string $path, Closure $callback = null, array $query = ['pretty' => 1])
        {
            $url = $this->getCallableUrl($path, $query);
    
            // Replace the HTTP protocol prefixes with WS protocols.
    Severity: Minor
    Found in src/Traits/Cluster/MakesWebsocketCalls.php - About 25 mins 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 '111', column '15').
    Open

        public function getLastSchedule()
        {
            if (! $lastSchedule = $this->getStatus('lastScheduleTime')) {
                return null;
            }
    Severity: Minor
    Found in src/Kinds/K8sCronJob.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 '\Carbon\Carbon' in method 'getCompletionTime'.
    Open

            return $time ? Carbon::parse($time) : null;
    Severity: Minor
    Found in src/Kinds/K8sJob.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 '\Illuminate\Support\Str' in method '__call'.
    Open

                $resource = Str::singular($resourcePlural);
    Severity: Minor
    Found in src/KubernetesCluster.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 '\Illuminate\Support\Str' in method 'getPlural'.
    Open

            return strtolower(Str::plural(static::getKind()));
    Severity: Minor
    Found in src/Kinds/K8sResource.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 '36', column '34').
    Open

        public static function fromYaml($cluster, string $yaml)
        {
            $instances = collect(yaml_parse($yaml, -1))->reduce(function ($classes, $yaml) use ($cluster) {
                $kind = $yaml['kind'];
                $apiVersion = $yaml['apiVersion'];
    Severity: Minor
    Found in src/K8s.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

    Severity
    Category
    Status
    Source
    Language