cerner/cerner_splunk

View on GitHub

Showing 38 of 38 total issues

Method configure_authentication has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

    def self.configure_authentication(node, hash) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, MethodLength
      hash = hash.clone
      auth_stanzas = { 'authentication' => hash }
      fail 'authSettings is managed by chef. Don\'t set it yourself!' if hash.key?('authSettings')

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

    def self.configure_outputs(node) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
      output_stanzas = {}

      if %i[search_head forwarder cluster_master shc_deployer].include? node['splunk']['node_type']
        output_stanzas['tcpout'] = {
Severity: Minor
Found in libraries/outputs.rb - About 6 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 iterate has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def iterate(callbacks = {}) # rubocop:disable PerceivedComplexity, CyclomaticComplexity
      @reader.rewind
      long_path = nil
      long_link = nil
      @reader.each do |entry|
Severity: Minor
Found in libraries/tarball.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 configure_roles has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def self.configure_roles(hash) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, MethodLength
      user_prefs = {}
      authorize = {}

      hash.each do |stanza, values|
Severity: Minor
Found in libraries/roles.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 configure_authentication has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.configure_authentication(node, hash) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, MethodLength
      hash = hash.clone
      auth_stanzas = { 'authentication' => hash }
      fail 'authSettings is managed by chef. Don\'t set it yourself!' if hash.key?('authSettings')

Severity: Major
Found in libraries/authentication.rb - About 3 hrs to fix

    Method load has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.load(string, options = {}) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
          opts = {
            pick_context: nil,
            handle_load_failure: false
          }.merge(options)
    Severity: Minor
    Found in libraries/databag.rb - About 3 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

    File splunk_app.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'chef/provider'
    require 'chef/resource'
    
    module CernerSplunk
      # Utilities to use with the splunk_app resource/provider
    Severity: Minor
    Found in libraries/splunk_app.rb - About 2 hrs to fix

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

            def self.convert_stanzas(input)
              (CernerSplunk::ConfTemplate.collapse_proc input || {}).inject({}) do |file_data, (stanza, stanza_value)|
                label = "Stanza #{stanza}"
                stanza_value = CernerSplunk::ConfTemplate.collapse_proc stanza_value, label: label, arguments: { stanza: stanza }
                fail "Unexpected value (#{stanza_value.class} '#{stanza_value}') for #{label}" unless stanza_value.nil? || stanza_value.is_a?(Hash)
      Severity: Minor
      Found in libraries/conf_template.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 configure_outputs has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.configure_outputs(node) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
            output_stanzas = {}
      
            if %i[search_head forwarder cluster_master shc_deployer].include? node['splunk']['node_type']
              output_stanzas['tcpout'] = {
      Severity: Minor
      Found in libraries/outputs.rb - About 1 hr to fix

        Method configure_roles has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.configure_roles(hash) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, MethodLength
              user_prefs = {}
              authorize = {}
        
              hash.each do |stanza, values|
        Severity: Minor
        Found in libraries/roles.rb - About 1 hr to fix

          Method merge_hashes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.merge_hashes(*hashes)
                hashes.collect(&:keys).flatten.uniq.each_with_object({}) do |app_name, result|
                  app_hash = {}
          
                  merger = proc { |_key, v1, v2| v1.is_a?(Hash) && v2.is_a?(Hash) ? v1.merge(v2, &merger) : v2 }
          Severity: Minor
          Found in libraries/splunk_app.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 to_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.to_value(array, _options = {}) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
                case array
                when nil
                  nil
                when Array
          Severity: Minor
          Found in libraries/databag.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 delayable_attribute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def delayable_attribute(attr_name, validation = {}) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
                  class_eval(<<-SHIM, __FILE__, __LINE__)
                    def #{attr_name}(arg=nil,&block)
                      _set_or_return_#{attr_name}(arg,block)
                    end
          Severity: Minor
          Found in libraries/lwrp.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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(version)
                @version = version.chomp.empty? ? nil : version.chomp unless version.nil?
                @base, @prerelease = @version.split(' ', 2) unless @version.nil?
                @type = @prerelease.nil? ? :base : :prerelease unless @version.nil?
              end
          Severity: Minor
          Found in libraries/splunk_app.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 insert_procs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def insert_procs(filename, contents)
                  return contents unless contents.is_a? Hash
                  contents.inject({}) do |retval, (stanza, attributes)|
                    retval[stanza] = attributes.inject({}) do |stanzavals, (key, value)|
                      stanzavals[key] =
          Severity: Minor
          Found in libraries/splunk_app.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 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.load(string, options = {}) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
                opts = {
                  pick_context: nil,
                  handle_load_failure: false
                }.merge(options)
          Severity: Minor
          Found in libraries/databag.rb - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

              if %i[index default].include?(stanza_type) && daily_mb && !hash.key?('maxTotalDataSizeMB')
                settings = CernerSplunk.my_cluster_data(node).fetch('settings', {})
                replication_factor = settings['replication_factor'] || 1
                indexer_count = settings['_cerner_splunk_indexer_count'] || 1
                # If the frozen time isn't specified, splunk defaults to 6 years
            Severity: Major
            Found in recipes/_configure_indexes.rb - About 1 hr to fix

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

                    def should_install?(expected_version, installed_version, tar_version) # rubocop:disable PerceivedComplexity, 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
                        fail "Expected version #{expected_version} does not match tar version #{tar_version} for #{new_resource.app}" unless expected_version.type == :base && tar_version.base == expected_version.base
              Severity: Minor
              Found in libraries/splunk_app.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 manage_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def manage_file(path, contents) # rubocop:disable Metrics/PerceivedComplexity
                      if contents.is_a?(Hash) && !contents.empty?
                        file = Chef::Resource::Template.new(path, run_context)
                        file.cookbook('cerner_splunk')
                        file.source('generic.conf.erb')
              Severity: Minor
              Found in libraries/splunk_app.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 process has a Cognitive Complexity of 8 (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 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

              Severity
              Category
              Status
              Source
              Language