sensu-plugins/sensu-plugins-graphite

View on GitHub

Showing 23 of 33 total issues

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

  def handle
    json_config = config[:json_config]
    port = settings[json_config]['port'] ? settings[json_config]['port'].to_s : '2003'
    graphite = Graphite.new(host: settings[json_config]['host'], port: port)
    return unless graphite
Severity: Minor
Found in bin/handler-graphite-notify.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 retrieve_data! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def retrieve_data!
        unless @raw_data
          begin
            unless config[:server].start_with?('https://', 'http://')
              config[:server].prepend('http://')
Severity: Minor
Found in lib/sensu-plugins-graphite/graphite_proxy/proxy.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

Avoid too many return statements within this method.
Open

          return [1, "#{metric['target']} is #{avg}"]
Severity: Major
Found in bin/check-graphite-stats.rb - About 30 mins to fix
    Severity
    Category
    Status
    Source
    Language