sensu/sensu-settings

View on GitHub

Showing 14 of 26 total issues

Class Loader has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Loader
      class Error < RuntimeError; end

      # @!attribute [r] warnings
      #   @return [Array] loader warnings.
Severity: Minor
Found in lib/sensu/settings/loader.rb - About 4 hrs to fix

    File loader.rb has 303 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "sensu/settings/validator"
    require "sensu/json"
    require "tmpdir"
    require "socket"
    require "digest"
    Severity: Minor
    Found in lib/sensu/settings/loader.rb - About 3 hrs to fix

      Method load_file has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_file(file, must_exist=true)
              if File.file?(file) && File.readable?(file)
                begin
                  warning("loading config file", :file => file)
                  contents = read_config_file(file)
      Severity: Minor
      Found in lib/sensu/settings/loader.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 validate_api_endpoints has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              def validate_api_endpoints(api)
                if is_an_array?(api[:endpoints])
                  api[:endpoints].each do |endpoint|
                    if is_a_hash?(endpoint)
                      if endpoint[:url]
      Severity: Minor
      Found in lib/sensu/settings/validators/api.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 validate_time_windows_days has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def validate_time_windows_days(definition, scope, attribute, days)
                valid_days = [:all, :sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday]
                if must_be_either(valid_days, days.keys)
                  days.each do |day, conditions|
                    if is_an_array?(conditions)
      Severity: Minor
      Found in lib/sensu/settings/validators/time_window.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 load_file has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def load_file(file, must_exist=true)
              if File.file?(file) && File.readable?(file)
                begin
                  warning("loading config file", :file => file)
                  contents = read_config_file(file)
      Severity: Minor
      Found in lib/sensu/settings/loader.rb - About 1 hr to fix

        Method validate_check_scheduling has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def validate_check_scheduling(check)
                  must_be_boolean_if_set(check[:publish]) ||
                    invalid(check, "check publish must be boolean")
                  unless check[:publish] == false
                    if check[:cron]
        Severity: Minor
        Found in lib/sensu/settings/validators/check.rb - 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

        Method validate_check_aggregate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def validate_check_aggregate(check)
                  if check[:aggregates]
                    if is_an_array?(check[:aggregates])
                      items_must_be_strings(check[:aggregates], /\A[\w\.:|-]+\z/) ||
                        invalid(check, "check aggregates items must be strings without spaces or special characters")
        Severity: Minor
        Found in lib/sensu/settings/validators/check.rb - 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

        Method validate_time_windows has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def validate_time_windows(definition, scope, attribute)
                  if is_a_hash?(definition[attribute])
                    days = definition[attribute][:days]
                    if is_a_hash?(days)
                      if !days.empty?
        Severity: Minor
        Found in lib/sensu/settings/validators/time_window.rb - 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

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

              def validate_categories(settings)
                CATEGORIES.each do |category|
                  if is_a_hash?(settings[category])
                    validate_method = ("validate_" + category.to_s.chop).to_sym
                    settings[category].each do |name, details|
        Severity: Minor
        Found in lib/sensu/settings/validator.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 validate_check_proxy_requests has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def validate_check_proxy_requests(check)
                  if is_a_hash?(check[:proxy_requests])
                    proxy_requests = check[:proxy_requests]
                    must_be_a_hash(proxy_requests[:client_attributes]) ||
                      invalid(check, "check proxy_requests client_attributes must be a hash")
        Severity: Minor
        Found in lib/sensu/settings/validators/check.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 load has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def load(options={})
                loader = Loader.new
                loader.load_env
                if options[:config_file]
                  loader.load_file(options[:config_file], false)
        Severity: Minor
        Found in lib/sensu/settings.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 deep_diff has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def deep_diff(hash_one, hash_two)
                keys = hash_one.keys.concat(hash_two.keys).uniq
                keys.inject(Hash.new) do |diff, key|
                  unless hash_one[key] == hash_two[key]
                    if hash_one[key].is_a?(Hash) && hash_two[key].is_a?(Hash)
        Severity: Minor
        Found in lib/sensu/settings/loader.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

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

                def validate_sensu_spawn(sensu)
                  spawn = sensu[:spawn]
                  if is_a_hash?(spawn)
                    if is_an_integer?(spawn[:limit])
                      spawn[:limit] > 0 ||
        Severity: Minor
        Found in lib/sensu/settings/validators/sensu.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

        Severity
        Category
        Status
        Source
        Language