uken/fluent-plugin-elasticsearch

View on GitHub
lib/fluent/plugin/elasticsearch_index_template.rb

Summary

Maintainability
D
1 day
Test Coverage

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 create_rollover_alias has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def create_rollover_alias(target_index, rollover_index, deflector_alias_name, app_name, index_date_pattern, index_separator, enable_ilm, ilm_policy_id, ilm_policy, ilm_policy_overwrite, host)
     # ILM request to create alias.
    if rollover_index || enable_ilm
      if !client.indices.exists_alias(:name => deflector_alias_name)
        if @logstash_format
Severity: Minor
Found in lib/fluent/plugin/elasticsearch_index_template.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 create_rollover_alias has 11 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def create_rollover_alias(target_index, rollover_index, deflector_alias_name, app_name, index_date_pattern, index_separator, enable_ilm, ilm_policy_id, ilm_policy, ilm_policy_overwrite, host)
Severity: Major
Found in lib/fluent/plugin/elasticsearch_index_template.rb - About 1 hr to fix

    Method template_custom_install has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def template_custom_install(template_name, template_file, overwrite, customize_template, enable_ilm, deflector_alias_name, ilm_policy_id, host, target_index, index_separator)
    Severity: Major
    Found in lib/fluent/plugin/elasticsearch_index_template.rb - About 1 hr to fix

      Method create_rollover_alias has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create_rollover_alias(target_index, rollover_index, deflector_alias_name, app_name, index_date_pattern, index_separator, enable_ilm, ilm_policy_id, ilm_policy, ilm_policy_overwrite, host)
           # ILM request to create alias.
          if rollover_index || enable_ilm
            if !client.indices.exists_alias(:name => deflector_alias_name)
              if @logstash_format
      Severity: Minor
      Found in lib/fluent/plugin/elasticsearch_index_template.rb - About 1 hr to fix

        Method template_install has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def template_install(name, template_file, overwrite, enable_ilm = false, deflector_alias_name = nil, ilm_policy_id = nil, host = nil, target_index = nil, index_separator = '-')
        Severity: Major
        Found in lib/fluent/plugin/elasticsearch_index_template.rb - About 1 hr to fix

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

            def retry_operate(max_retries, fail_on_retry_exceed = true, catch_trasport_exceptions = true)
              return unless block_given?
              retries = 0
              transport_errors = TRANSPORT_CLASS::Transport::Errors.constants.map{ |c| TRANSPORT_CLASS::Transport::Errors.const_get c } if catch_trasport_exceptions
              begin
          Severity: Minor
          Found in lib/fluent/plugin/elasticsearch_index_template.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 template_install has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def template_install(name, template_file, overwrite, enable_ilm = false, deflector_alias_name = nil, ilm_policy_id = nil, host = nil, target_index = nil, index_separator = '-')
              inject_template_name = get_template_name(enable_ilm, name, deflector_alias_name)
              if overwrite
                template_put(inject_template_name,
                             enable_ilm ? inject_ilm_settings_to_template(deflector_alias_name,
          Severity: Minor
          Found in lib/fluent/plugin/elasticsearch_index_template.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 inject_ilm_settings_to_template has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def inject_ilm_settings_to_template(deflector_alias, target_index, ilm_policy_id, template, index_separator)
          Severity: Minor
          Found in lib/fluent/plugin/elasticsearch_index_template.rb - About 35 mins to fix

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

              def template_exists?(name, host = nil)
                if @use_legacy_template
                  client(host).indices.get_template(:name => name)
                else
                  client(host).indices.get_index_template(:name => name)
            Severity: Minor
            Found in lib/fluent/plugin/elasticsearch_index_template.rb and 1 other location - About 30 mins to fix
            lib/fluent/plugin/out_elasticsearch_data_stream.rb on lines 175..183

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 32.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status