sensu-plugins/sensu-plugins-docker

View on GitHub

Showing 9 of 9 total issues

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

  def run
    @client = DockerApi.new(config[:docker_host])
    path = "/containers/#{config[:container]}/json"
    response = @client.call(path, false)
    if response.code.to_i == 404
Severity: Minor
Found in bin/check-container.rb - 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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    @timestamp = Time.now.to_i
    @client = DockerApi.new(config[:docker_host])

    list = if config[:container] != ''
Severity: Minor
Found in bin/metrics-docker-stats.rb - 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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    @client = DockerApi.new(config[:docker_host])
    problem = []
    problem_string = nil
    path = "/containers/json?all=#{config[:check_all]}"
Severity: Minor
Found in bin/check-container-logs.rb - 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 container_metrics has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def container_metrics
    cgroup = "#{config[:cgroup_path]}/#{config[:cgroup_template]}"

    timestamp = Time.now.to_i
    ps = Sys::ProcTable.ps.group_by(&:pid)
Severity: Minor
Found in bin/metrics-docker-container.rb - About 1 hr to fix

    Method output_stats has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def output_stats(container, stats)
        dotted_stats = Hash.to_dotted_hash stats
        dotted_stats.each do |key, value|
          next if key == 'read' # unecessary timestamp
          next if value.is_a?(Array)
    Severity: Minor
    Found in bin/metrics-docker-stats.rb - 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 run has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        @client = DockerApi.new(config[:docker_host])
        path = "/containers/#{config[:container]}/json"
        response = @client.call(path, false)
        if response.code.to_i == 404
    Severity: Minor
    Found in bin/check-container.rb - About 1 hr to fix

      Method call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def call(path, halt = true, limit = 10)
          raise ArgumentError, "HTTP redirect too deep. Last url called : #{path}" if limit.zero?
          if %r{^unix:///} =~ @docker_uri
            request = Net::HTTP::Get.new path.to_s
          else
      Severity: Minor
      Found in lib/sensu-plugins-docker/client_helpers.rb - 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

      Method evaluate_count has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def evaluate_count(count)
          # #YELLOW
          if config.key?(:crit_under) && count < config[:crit_under]
            critical under_message(config[:crit_under], count)
          # #YELLOW
      Severity: Minor
      Found in bin/check-docker-container.rb - 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

      Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(uri = nil)
          @client = nil
          @docker_uri = uri || ENV['DOCKER_URL'] || ENV['DOCKER_HOST'] || '/var/run/docker.sock'
          if @docker_uri.sub!(%r{^(unix://)?/}, '')
            @docker_uri = 'unix:///' + @docker_uri
      Severity: Minor
      Found in lib/sensu-plugins-docker/client_helpers.rb - 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

      Severity
      Category
      Status
      Source
      Language