renoki-co/php-k8s

View on GitHub
src/KubernetesCluster.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    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

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

        protected function watchPath(string $path, Closure $callback, array $query = ['pretty' => 1])
        {
            $resourceClass = $this->resourceClass;
            $sock = $this->createSocketConnection($this->getCallableUrl($path, $query));
            $data = null;
    Severity: Minor
    Found in src/KubernetesCluster.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

    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 '__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 'RenokiCo\PhpK8s\K8s' in method '__call'.
    Open

            return K8s::{$method}($this, ...$parameters);
    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

    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

    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

    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

    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

    Line exceeds 120 characters; contains 138 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sService getServiceByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 133 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllPersistentVolumeClaims(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 146 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sStatefulSet getStatefulSetByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 121 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllHorizontalPodAutoscalersFromAllNamespaces(array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 141 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllValidatingWebhookConfiguration(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 139 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllMutatingWebhookConfiguration(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 134 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sEvent getEventByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 152 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sServiceAccount getServiceAccountByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 141 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sResource|array[\RenokiCo\PhpK8s\Kinds\K8sResource] fromYamlFile(string $path, \Closure $callback = null)
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 132 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sNode getNodeByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 122 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllDeployments(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 123 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllClusterRoles(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 146 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sRoleBinding getRoleBindingByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 123 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllRoleBindings(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 123 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllStatefulSets(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 126 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllServiceAccounts(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 162 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sPodDisruptionBudget getPodDisruptionBudgetByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 184 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sValidatingWebhookConfiguration getValidatingWebhookConfigurationByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 128 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllValidatingWebhookConfigurationsFromAllNamespaces(array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 126 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllMutatingWebhookConfigurationsFromAllNamespaces(array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 142 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sConfigMap getConfigmapByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 170 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sHorizontalPodAutoscaler getHorizontalPodAutoscalerByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 130 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sJob getJobByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 180 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sMutatingWebhookConfiguration getMutatingWebhookConfigurationByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 125 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllStorageClasses(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 148 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sStorageClass getStorageClassByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 142 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sNamespace getNamespaceByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 156 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sPersistentVolume getPersistentVolumeByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 135 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllHorizontalPodAutoscalers(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 142 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sDaemonSet getDaemonSetByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 160 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sClusterRoleBinding getClusterRoleBindingByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 166 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sResource|array[\RenokiCo\PhpK8s\Kinds\K8sResource] fromTemplatedYamlFile(string $path, array $replace, \Closure $callback = null)
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 121 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllConfigmaps(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 128 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllPersistentVolumes(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 138 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sCronJob getCronjobByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 132 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sRole getRoleByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 121 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllNamespaces(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 136 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sSecret getSecretByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 146 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sClusterRole getClusterRoleByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 122 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sValidatingWebhookConfiguration validatingWebhookConfiguration(array $attributes = [])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 166 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sPersistentVolumeClaim getPersistentVolumeClaimByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 130 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sPod getPodByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 144 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sDeployment getDeploymentByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 121 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllDaemonSets(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 131 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllPodDisruptionBudgets(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 138 characters
    Open

     * @method \RenokiCo\PhpK8s\Kinds\K8sIngress getIngressByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Line exceeds 120 characters; contains 130 characters
    Open

     * @method \RenokiCo\PhpK8s\ResourcesList getAllClusterRoleBindings(string $namespace = 'default', array $query = ['pretty' => 1])
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Expected 0 spaces after opening bracket; newline found
    Open

                if (
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Closing brace 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

    Closing brace 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

    Closing brace 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

    Expected 0 spaces after opening bracket; newline found
    Open

                if (
    Severity: Minor
    Found in src/KubernetesCluster.php by phpcodesniffer

    Closing brace must be on a line by itself
    Open

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

    Closing brace 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

    There are no issues that match your filters.

    Category
    Status