fluent/fluentd

View on GitHub

Showing 664 of 664 total issues

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

    def plugin_root_dir
      return @_plugin_root_dir if @_plugin_root_dir
      return nil unless system_config.root_dir
      return nil unless plugin_id_configured?

Severity: Minor
Found in lib/fluent/plugin_id.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 parse_worker_id has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_worker_id(conf)
      worker_id_str = conf.arg

      if worker_id_str.empty?
        raise Fluent::ConfigError, 'Missing worker id on <worker> directive'
Severity: Minor
Found in lib/fluent/static_config_analysis.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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def configure(conf, strict_config_value=false)
      @config = conf

      logger = if self.respond_to?(:log)
                 self.log
Severity: Minor
Found in lib/fluent/configurable.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 socket_create_tcp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def socket_create_tcp(host, port, resolve_name: false, connect_timeout: nil, **kwargs, &block)
        sock = if connect_timeout
                 s = ::Socket.tcp(host, port, connect_timeout: connect_timeout)
                 s.autoclose = false # avoid GC triggered close
                 WrappedSocket::TCP.for_fd(s.fileno)
Severity: Minor
Found in lib/fluent/plugin_helper/socket.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 static_worker_analyse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def static_worker_analyse(conf)
      available_worker_ids = [*0...@workers]

      ret = []
      conf.elements(name: 'worker').each do |config|
Severity: Minor
Found in lib/fluent/static_config_analysis.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 server_attach has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def server_attach(title, proto, port, bind, shared, server)
Severity: Minor
Found in lib/fluent/plugin_helper/server.rb - About 45 mins to fix

    Method server_create_for_tcp_connection has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def server_create_for_tcp_connection(shared, bind, port, backlog, socket_option_setter, &block)
    Severity: Minor
    Found in lib/fluent/plugin_helper/server.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                        raise Fluent::ConfigError, "Mismatched quotes. Invalid syntax: #{orig_param}" unless param[0] == param[i]
      Severity: Major
      Found in lib/fluent/plugin_helper/record_accessor.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        logger.error "config error in:\n#{conf}" if logger
        Severity: Major
        Found in lib/fluent/config/section.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if prev_match.include?("\n") || eof? # support 'tag_mapped' like "without value" configuration
                        attrs[k] = ""
                      else
                        if k == '@include'
                          parse_include(attrs, elems)
          Severity: Major
          Found in lib/fluent/config/v1_parser.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            logger.error "config error in:\n#{conf}" if logger
            Severity: Major
            Found in lib/fluent/config/section.rb - About 45 mins to fix

              Method generate has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def self.generate(proxy, conf, logger, plugin_class, stack = [], strict_config_value = false)
              Severity: Minor
              Found in lib/fluent/config/section.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if !prev_match.start_with?('@')
                              @logger.warn "'include' is deprecated. Use '@include' instead" if @logger
                            end
                Severity: Major
                Found in lib/fluent/config/v1_parser.rb - About 45 mins to fix

                  Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                            def initialize(sock, socket_option_setter, close_callback, log, under_plugin_development, connect_callback)
                  Severity: Minor
                  Found in lib/fluent/plugin_helper/server.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                      raise Fluent::ConfigError, "missing array index in '[]'. Invalid syntax: #{param}" if index_value == ']'
                    Severity: Major
                    Found in lib/fluent/plugin_helper/record_accessor.rb - About 45 mins to fix

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

                            def error_sample
                              pos = @ss.pos
                      
                              lines = @ss.string.lines.to_a
                              lines.each_with_index { |line, ln|
                      Severity: Minor
                      Found in lib/fluent/config/basic_parser.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 scan_embedded_code has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def scan_embedded_code
                              src = '"#{'+@ss.rest+"\n=begin\n=end\n}"
                      
                              seek = -1
                              while (seek = src.index('}', seek + 1))
                      Severity: Minor
                      Found in lib/fluent/config/literal_parser.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 dump_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def dump_value(k, v, nindent)
                              return "#{nindent}#{k} xxxxxx\n" if secret_param?(k)
                              return "#{nindent}#{k} #{v}\n" unless @v1_config
                      
                              # for v1 config
                      Severity: Minor
                      Found in lib/fluent/config/element.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

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

                          INTEGER_TYPE = Proc.new { |val, opts = {}, name = nil|
                            if val.nil?
                              nil
                            elsif opts[:strict]
                              begin
                      Severity: Minor
                      Found in lib/fluent/config/types.rb and 1 other location - About 40 mins to fix
                      lib/fluent/config/types.rb on lines 151..162

                      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 37.

                      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

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

                          FLOAT_TYPE = Proc.new { |val, opts = {}, name = nil|
                            if val.nil?
                              nil
                            elsif opts[:strict]
                              begin
                      Severity: Minor
                      Found in lib/fluent/config/types.rb and 1 other location - About 40 mins to fix
                      lib/fluent/config/types.rb on lines 137..148

                      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 37.

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language