renoki-co/php-k8s

View on GitHub

Showing 18 of 198 total issues

Method loadKubeConfigFromArray has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function loadKubeConfigFromArray(array $kubeconfig, string $context = null)
    {
        /** @var \RenokiCo\PhpK8s\KubernetesCluster $this */

        // Compute the context from the method, or in case it is passed as null
Severity: Major
Found in src/Traits/Cluster/LoadsFromKubeConfig.php - About 3 hrs to fix

    Function loadKubeConfigFromArray has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function loadKubeConfigFromArray(array $kubeconfig, string $context = null)
        {
            /** @var \RenokiCo\PhpK8s\KubernetesCluster $this */
    
            // Compute the context from the method, or in case it is passed as null
    Severity: Minor
    Found in src/Traits/Cluster/LoadsFromKubeConfig.php - About 1 hr 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

    Method makeWsRequest has 38 lines of code (exceeds 25 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 1 hr to fix

      Method getWsClient has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getWsClient(string $url): array
          {
              $options = [
                  'timeout' => 20,
                  'tls' => [],
      Severity: Minor
      Found in src/Traits/Cluster/MakesWebsocketCalls.php - About 1 hr to fix

        Method buildStreamContextOptions has 27 lines of code (exceeds 25 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 1 hr to fix

          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

          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

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

          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

          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

          Avoid too many return statements within this method.
          Open

                  return $this;
          Severity: Major
          Found in src/Traits/Resource/HasAttributes.php - About 30 mins to fix

            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

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

              Severity
              Category
              Status
              Source
              Language