cerner/cerner_splunk

View on GitHub

Showing 28 of 36 total issues

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

    def self.configure_alerts(node, hash)
      hash = hash.clone
      default_coords = CernerSplunk::DataBag.to_a node['splunk']['config']['alerts']
      bag = CernerSplunk::DataBag.load hash.delete('bag'), default: default_coords, secret: node['splunk']['data_bag_secret']

Severity: Minor
Found in libraries/alerts.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 process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.process(string, default, strip, default_empty)
      if string
        string.strip! if strip
        string = nil if string.empty? && default_empty
      end
Severity: Minor
Found in libraries/databag.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 install_from_tar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def install_from_tar(filename, expected_version, installed_version)
        temp_app_dir = "#{Chef::Config[:file_cache_path]}/#{new_resource.app}"
        Mixlib::Archive.new(filename).extract(Chef::Config[:file_cache_path])

        validate_downloaded temp_app_dir
Severity: Minor
Found in libraries/splunk_app.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 all_clusters_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.all_clusters_data(node)
    unless @all_cluster_data
      _head, *others = node['splunk']['config']['clusters']
      @all_cluster_data = [my_cluster_data(node)] + others.collect do |cluster|
        cluster_data = CernerSplunk::DataBag.load(cluster, secret: node['splunk']['data_bag_secret'])
Severity: Minor
Found in libraries/recipe_utils.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 should_install? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def should_install?(expected_version, installed_version, tar_version) # rubocop:disable Metrics/CyclomaticComplexity
        fail "Downloaded tarball for #{new_resource.app} does not contain a version in app.conf!" unless tar_version.version

        # If we specify an expected version (see warning in should download), the tar version must match exactly OR the expected version is the base version of the (prerelease) tar version
        if expected_version.version && tar_version != expected_version && !(expected_version.type == :base && tar_version.base == expected_version.base) # rubocop:disable Style/IfUnlessModifier
Severity: Minor
Found in libraries/splunk_app.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 action_create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def action_create
        download_and_install
        create_app_directories unless new_resource.updated_by_last_action?
        manage_metaconf unless new_resource.permissions.empty?
        manage_lookups unless new_resource.lookups.empty?
Severity: Minor
Found in libraries/splunk_app.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 existing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def self.existing(filename:, **_)
          @file_readers ||= Hash.new { |hash, key| hash[key] = CernerSplunk::ConfTemplate.ExistingValue.new key }
          existing_value = @file_readers[filename]
          proc { |stanza:, attribute: nil, **_| attribute.nil? ? existing_value[stanza] : (existing_value[stanza] || {})[attribute] }
        end
Severity: Minor
Found in libraries/conf_template.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 use_splunk_start_command? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.use_splunk_start_command?(node, previous_splunk_version)
    return false unless ::File.exist?(node['splunk']['systemd_file_location'])
    return false if previous_splunk_version.nil?

    previous_version = Gem::Version.new(previous_splunk_version)
Severity: Minor
Found in libraries/recipe_utils.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