renoki-co/php-k8s

View on GitHub

Showing 194 of 198 total issues

Function fromKubeConfigVariable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function fromKubeConfigVariable(string $context = null)
    {
        /** @var \RenokiCo\PhpK8s\KubernetesCluster $this */
        $cluster = new static;

Severity: Minor
Found in src/Traits/Cluster/LoadsFromKubeConfig.php - About 55 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 __call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function __call($method, $parameters)
    {
        // Proxy the ->get[Resource]ByName($name, $namespace = 'default')
        // For example, ->getConfigMapByName('settings')
        if (preg_match('/get(.+)ByName/', $method, $matches)) {
Severity: Minor
Found in src/KubernetesCluster.php - About 55 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 variables with short names like $ws. Configured minimum length is 3.
Open

        [$loop, $ws] = $this->getWsClient($url);

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Function buildStreamContextOptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function buildStreamContextOptions(): array
    {
        $sslOptions = $headers = [];

        if (is_bool($this->verify)) {
Severity: Minor
Found in src/Traits/Cluster/MakesWebsocketCalls.php - About 45 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

Terminating statement must be on a line by itself
Open

            case static::ATTACH_OP: return $this->attachPath($path, $payload, $query);
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

The DEFAULT body must start on the line following the statement
Open

            default: break;
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

The CASE body must start on the line following the statement
Open

            case static::WATCH_LOGS_OP: return $this->watchLogsPath($path, $payload, $query);
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

Terminating statement must be on a line by itself
Open

            default: break;
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

Terminating statement must be on a line by itself
Open

            case static::WATCH_LOGS_OP: return $this->watchLogsPath($path, $payload, $query);
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

Function addLabelSelectorRequirement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addLabelSelectorRequirement(array $expressions, array $fieldsExpressions, string $topologyKey)
    {
        foreach ($expressions as &$expression) {
            if ($expression instanceof Expression) {
                $expression = $expression->toArray();
Severity: Minor
Found in src/Instances/Affinity.php - About 35 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

The CASE body must start on the line following the statement
Open

            case static::WATCH_OP: return $this->watchPath($path, $payload, $query);
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

Terminating statement must be on a line by itself
Open

            case static::WATCH_OP: return $this->watchPath($path, $payload, $query);
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

Function addNodeSelectorPreference has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addNodeSelectorPreference(array $expressions, array $fieldsExpressions, int $weight = 1)
    {
        foreach ($expressions as &$expression) {
            if ($expression instanceof Expression) {
                $expression = $expression->toArray();
Severity: Minor
Found in src/Instances/Affinity.php - About 35 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 addNodeRequirement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addNodeRequirement(array $expressions, array $fieldsExpressions)
    {
        foreach ($expressions as &$expression) {
            if ($expression instanceof Expression) {
                $expression = $expression->toArray();
Severity: Minor
Found in src/Instances/Affinity.php - About 35 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

The CASE body must start on the line following the statement
Open

            case static::ATTACH_OP: return $this->attachPath($path, $payload, $query);
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

Function addPreference has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addPreference(array $expressions, array $fieldsExpressions, int $weight = 1)
    {
        foreach ($expressions as &$expression) {
            if ($expression instanceof Expression) {
                $expression = $expression->toArray();
Severity: Minor
Found in src/Instances/Affinity.php - About 35 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

The CASE body must start on the line following the statement
Open

            case static::EXEC_OP: return $this->execPath($path, $query);
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

Terminating statement must be on a line by itself
Open

            case static::EXEC_OP: return $this->execPath($path, $query);
Severity: Minor
Found in src/KubernetesCluster.php by phpcodesniffer

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

    public function allResourcesPath(bool $withNamespace = true): string
Severity: Minor
Found in src/Traits/RunsClusterOperations.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 getInitContainer has a boolean flag argument $asInstance, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getInitContainer(string $containerName, 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

Severity
Category
Status
Source
Language