uken/fluent-plugin-elasticsearch

View on GitHub

Showing 67 of 80 total issues

File out_elasticsearch.rb has 1022 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'date'
require 'excon'
require 'elasticsearch'
require 'set'
require 'json'
Severity: Major
Found in lib/fluent/plugin/out_elasticsearch.rb - About 2 days to fix

    Method configure has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
    Open

        def configure(conf)
          compat_parameters_convert(conf, :buffer)
    
          super
          if placeholder_substitution_needed_for_template?
    Severity: Minor
    Found in lib/fluent/plugin/out_elasticsearch.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 handle_error has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

      def handle_error(response, tag, chunk, bulk_message_count, extracted_values, unpacked_msg_arr)
        items = response['items']
        if items.nil? || !items.is_a?(Array)
          raise ElasticsearchVersionMismatch, "The response format was unrecognized: #{response}"
        end
    Severity: Minor
    Found in lib/fluent/plugin/elasticsearch_error_handler.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 write has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        def write(chunk)
          bulk_message = Hash.new { |h,k| h[k] = '' }
          dynamic_conf = @dynamic_config.clone
    
          headers = {
    Severity: Minor
    Found in lib/fluent/plugin/out_elasticsearch_dynamic.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 has 190 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def configure(conf)
          compat_parameters_convert(conf, :buffer)
    
          super
          if placeholder_substitution_needed_for_template?
    Severity: Major
    Found in lib/fluent/plugin/out_elasticsearch.rb - About 7 hrs to fix

      Class ElasticsearchOutput has 45 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class ElasticsearchOutput < Output
          class RecoverableRequestFailure < StandardError; end
          class UnrecoverableRequestFailure < Fluent::UnrecoverableError; end
          class RetryStreamEmitFailure < StandardError; end
      
      
      Severity: Minor
      Found in lib/fluent/plugin/out_elasticsearch.rb - About 6 hrs to fix

        Method process_message has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_message(tag, meta, header, time, record, affinity_target_indices, extracted_values)
              logstash_prefix, logstash_dateformat, index_name, type_name, _template_name, _customize_template, _deflector_alias, application_name, pipeline, _ilm_policy_id = extracted_values
        
              if @flatten_hashes
                record = flatten_record(record)
        Severity: Minor
        Found in lib/fluent/plugin/out_elasticsearch.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 get_connection_options has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_connection_options(con_host=nil)
        
              hosts = if con_host || @hosts
                (con_host || @hosts).split(',').map do |host_str|
                  # Support legacy hosts format host:port,host:port,host:port...
        Severity: Minor
        Found in lib/fluent/plugin/out_elasticsearch.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 write has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            def write(chunk)
              bulk_message_count = Hash.new { |h,k| h[k] = 0 }
              bulk_message = Hash.new { |h,k| h[k] = '' }
              header = {}
              meta = {}
        Severity: Minor
        Found in lib/fluent/plugin/out_elasticsearch.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 send_bulk has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

            def send_bulk(data, tag, chunk, bulk_message_count, extracted_values, info, unpacked_msg_arr)
              _logstash_prefix, _logstash_dateformat, index_name, _type_name, template_name, customize_template, deflector_alias, application_name, _pipeline, ilm_policy_id = extracted_values
              if deflector_alias
                template_installation(deflector_alias, template_name, customize_template, application_name, index_name, ilm_policy_id, info.host)
              else
        Severity: Minor
        Found in lib/fluent/plugin/out_elasticsearch.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

        Method handle_error has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def handle_error(response, tag, chunk, bulk_message_count, extracted_values, unpacked_msg_arr)
            items = response['items']
            if items.nil? || !items.is_a?(Array)
              raise ElasticsearchVersionMismatch, "The response format was unrecognized: #{response}"
            end
        Severity: Major
        Found in lib/fluent/plugin/elasticsearch_error_handler.rb - About 3 hrs to fix

          Method write has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def write(chunk)
                data_stream_name = @data_stream_name
                data_stream_template_name = @data_stream_template_name
                data_stream_ilm_name = @data_stream_ilm_name
                host = nil
          Severity: Minor
          Found in lib/fluent/plugin/out_elasticsearch_data_stream.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

          Method process_message has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def process_message(tag, meta, header, time, record, affinity_target_indices, extracted_values)
                logstash_prefix, logstash_dateformat, index_name, type_name, _template_name, _customize_template, _deflector_alias, application_name, pipeline, _ilm_policy_id = extracted_values
          
                if @flatten_hashes
                  record = flatten_record(record)
          Severity: Major
          Found in lib/fluent/plugin/out_elasticsearch.rb - About 3 hrs to fix

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

                def get_connection_options(con_host)
                  raise "`password` must be present if `user` is present" if @user && !@password
            
                  hosts = if con_host || @hosts
                    (con_host || @hosts).split(',').map do |host_str|
            Severity: Minor
            Found in lib/fluent/plugin/out_elasticsearch_dynamic.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

            Method write has 79 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def write(chunk)
                  bulk_message = Hash.new { |h,k| h[k] = '' }
                  dynamic_conf = @dynamic_config.clone
            
                  headers = {
            Severity: Major
            Found in lib/fluent/plugin/out_elasticsearch_dynamic.rb - About 3 hrs to fix

              Method inject_ilm_settings_to_template has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                def inject_ilm_settings_to_template(deflector_alias, target_index, ilm_policy_id, template, index_separator)
                  log.debug("Overwriting index patterns when Index Lifecycle Management is enabled.")
                  template['index_patterns'] = "#{target_index}#{index_separator}*"
                  if @use_legacy_template
                    template.delete('template') if template.include?('template')
              Severity: Minor
              Found in lib/fluent/plugin/elasticsearch_index_template.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

              Method template_installation_actual has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  def template_installation_actual(deflector_alias, template_name, customize_template, application_name, target_index, ilm_policy_id, host=nil)
                    if template_name && @template_file
                      if !@logstash_format && (deflector_alias.nil? || (@alias_indexes.include? deflector_alias)) && (@template_names.include? template_name)
                        if deflector_alias
                          log.debug("Index alias #{deflector_alias} and template #{template_name} already exist (cached)")
              Severity: Minor
              Found in lib/fluent/plugin/out_elasticsearch.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

              Method get_connection_options has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_connection_options(con_host=nil)
              
                    hosts = if con_host || @hosts
                      (con_host || @hosts).split(',').map do |host_str|
                        # Support legacy hosts format host:port,host:port,host:port...
              Severity: Minor
              Found in lib/fluent/plugin/in_elasticsearch.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

              Method validate_data_stream_parameters has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_data_stream_parameters
                    {"data_stream_name" => @data_stream_name,
                     "data_stream_template_name"=> @data_stream_template_name,
                     "data_stream_ilm_name" => @data_stream_ilm_name}.each do |parameter, value|
                      unless valid_data_stream_parameters?(value)
              Severity: Minor
              Found in lib/fluent/plugin/out_elasticsearch_data_stream.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

              File in_elasticsearch.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'elasticsearch'
              
              require 'faraday/excon'
              require 'fluent/log-ext'
              require 'fluent/plugin/input'
              Severity: Minor
              Found in lib/fluent/plugin/in_elasticsearch.rb - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language