cerner/cerner_splunk

View on GitHub

Showing 36 of 36 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, Metrics/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 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, Metrics/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, Metrics/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 Metrics/CyclomaticComplexity, Metrics/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 295 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'chef/provider'
    require 'chef/resource'
    require 'fileutils'
    require 'mixlib/archive'
    
    
    Severity: Minor
    Found in libraries/splunk_app.rb - About 3 hrs to fix

      Method manage_lookups has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def manage_lookups
              new_resource.lookups.each do |file_name, value|
                if value && !value.empty?
                  fail "Unsupported lookup file format for #{file_name} in the app #{new_resource.app}" unless file_name =~ /\.(?:csv\.gz|csv|kmz)$/i
      
      
      Severity: Minor
      Found in libraries/splunk_app.rb - About 2 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

      Consider simplifying this complex logical expression.
      Open

        if %i[index default].include?(stanza_type) && daily_mb && ((!s2_enabled_index && !hash.key?('maxTotalDataSizeMB')) || (s2_enabled_index && !hash.key?('maxGlobalDataSizeMB')))
          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: Critical
      Found in recipes/_configure_indexes.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, Metrics/MethodLength
                user_prefs = {}
                authorize = {}
          
                hash.each do |stanza, values|
          Severity: Minor
          Found in libraries/roles.rb - About 1 hr to fix

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

                def self.to_value(array, _options = {}) # rubocop:disable Metrics/CyclomaticComplexity
                  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 merge_hashes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.merge_hashes(*hashes) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
                  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 delayable_attribute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def delayable_attribute(attr_name, validation = {})
                    class_eval(<<-SHIM, __FILE__, __LINE__ + 1)
                      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)|
            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 Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
                  opts = {
                    pick_context: nil,
                    handle_load_failure: false
                  }.merge(options)
            Severity: Minor
            Found in libraries/databag.rb - About 1 hr to fix

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

                    def manage_file(path, contents)
                      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 convert_monitors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.convert_monitors(monitors, default_index = nil, base = {})
                    monitors.inject(base) do |stanzas, element|
                      type = element['type'] || element[:type] || 'monitor'
                      path = element['path'] || element[:path]
              
              
              Severity: Minor
              Found in libraries/lwrp.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 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

              Severity
              Category
              Status
              Source
              Language