sensu-plugins/sensu-plugins-kubernetes

View on GitHub

Showing 19 of 19 total issues

Method run has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    services = parse_list(config[:service_list])
    failed_services = []
    s = client.get_services
    # TODO: come back and clean me up
Severity: Minor
Found in bin/check-kube-service-available.rb - About 1 day 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 run has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    pods_list = []
    failed_pods = []
    pods = []
    if config[:pod_filter].nil?
Severity: Minor
Found in bin/check-kube-pods-running.rb - About 7 hrs 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 run has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    pods_list = []
    restarted_pods = []
    pods = []
    if config[:pod_filter].nil?
Severity: Minor
Found in bin/check-kube-pods-restarting.rb - About 5 hrs 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 run has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    pods_list = []
    failed_pods = []
    pods = []
    if config[:pod_filter].nil?
Severity: Minor
Found in bin/check-kube-pods-pending.rb - About 5 hrs 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 kubeclient has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

        def kubeclient(options = {})
          raise(ArgumentError, 'options must be a hash') unless options.is_a?(Hash)

          if options[:kube_config]
            begin
Severity: Minor
Found in lib/sensu-plugins-kubernetes/client.rb - About 4 hrs 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 run has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    pods_list = []
    pods = []
    warn = false
    crit = false
Severity: Minor
Found in bin/check-kube-pods-runtime.rb - About 4 hrs 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 kubeclient has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def kubeclient(options = {})
          raise(ArgumentError, 'options must be a hash') unless options.is_a?(Hash)

          if options[:kube_config]
            begin
Severity: Major
Found in lib/sensu-plugins-kubernetes/client.rb - About 2 hrs to fix

    Method run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        failed_nodes = []
        client.get_nodes.each do |node|
          item = node.status.conditions.detect { |condition| condition.type == 'Ready' }
          if item.nil?
    Severity: Minor
    Found in bin/check-kube-nodes-ready.rb - About 2 hrs 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 run has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        services = parse_list(config[:service_list])
        failed_services = []
        s = client.get_services
        # TODO: come back and clean me up
    Severity: Minor
    Found in bin/check-kube-service-available.rb - About 2 hrs to fix

      Method run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          pods_list = []
          pods = []
          warn = false
          crit = false
      Severity: Minor
      Found in bin/check-kube-pods-runtime.rb - About 1 hr to fix

        Method run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run
            pods_list = []
            failed_pods = []
            pods = []
            if config[:pod_filter].nil?
        Severity: Minor
        Found in bin/check-kube-pods-running.rb - About 1 hr to fix

          Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def run
              pods_list = []
              restarted_pods = []
              pods = []
              if config[:pod_filter].nil?
          Severity: Minor
          Found in bin/check-kube-pods-restarting.rb - About 1 hr to fix

            Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def run
                pods_list = []
                failed_pods = []
                pods = []
                if config[:pod_filter].nil?
            Severity: Minor
            Found in bin/check-kube-pods-pending.rb - About 1 hr to fix

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

                  if config[:pod_filter].nil?
                    pods_list = parse_list(config[:pod_list])
                    pods = client.get_pods
                  else
                    pods = client.get_pods(label_selector: config[:pod_filter].to_s)
              Severity: Minor
              Found in bin/check-kube-pods-running.rb and 2 other locations - About 30 mins to fix
              bin/check-kube-pods-pending.rb on lines 108..116
              bin/check-kube-pods-restarting.rb on lines 107..115

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 32.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

                  if config[:pod_filter].nil?
                    pods_list = parse_list(config[:pod_list])
                    pods = client.get_pods
                  else
                    pods = client.get_pods(label_selector: config[:pod_filter].to_s)
              Severity: Minor
              Found in bin/check-kube-pods-pending.rb and 2 other locations - About 30 mins to fix
              bin/check-kube-pods-restarting.rb on lines 107..115
              bin/check-kube-pods-running.rb on lines 105..113

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 32.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

                  if config[:pod_filter].nil?
                    pods_list = parse_list(config[:pod_list])
                    pods = client.get_pods
                  else
                    pods = client.get_pods(label_selector: config[:pod_filter].to_s)
              Severity: Minor
              Found in bin/check-kube-pods-restarting.rb and 2 other locations - About 30 mins to fix
              bin/check-kube-pods-pending.rb on lines 108..116
              bin/check-kube-pods-running.rb on lines 105..113

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 32.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Method ready? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def ready?(pod)
                  failed = true
                  pod.status.conditions.each do |c|
                    if c.type == 'Ready'
                      failed = false if c.status == 'True'
              Severity: Minor
              Found in bin/check-kube-pods-running.rb - 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                        if options[:client_cert_file]
                          begin
                            ssl_options[:client_cert] = OpenSSL::X509::Certificate.new(File.read(options[:client_cert_file]))
                          rescue StandardError => e
                            raise e, "Unable to read client certificate: #{e}", e.backtrace
              Severity: Minor
              Found in lib/sensu-plugins-kubernetes/client.rb and 1 other location - About 25 mins to fix
              lib/sensu-plugins-kubernetes/client.rb on lines 92..97

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 29.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                        if options[:client_key_file]
                          begin
                            ssl_options[:client_key] = OpenSSL::PKey::RSA.new(File.read(options[:client_key_file]))
                          rescue StandardError => e
                            raise e, "Unable to read client key: #{e}", e.backtrace
              Severity: Minor
              Found in lib/sensu-plugins-kubernetes/client.rb and 1 other location - About 25 mins to fix
              lib/sensu-plugins-kubernetes/client.rb on lines 84..89

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 29.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language