fluent/fluentd

View on GitHub
lib/fluent/plugin_helper/child_process.rb

Summary

Maintainability
F
3 days
Test Coverage

Method child_process_execute_once has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

      def child_process_execute_once(
          title, command, arguments, subprocess_name, mode, stderr, env, unsetenv, chdir,
          internal_encoding, external_encoding, scrub, replace_string, wait_timeout, on_exit_callback, &block
      )
        spawn_args = if arguments || subprocess_name
Severity: Minor
Found in lib/fluent/plugin_helper/child_process.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 child_process_execute_once has 119 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def child_process_execute_once(
          title, command, arguments, subprocess_name, mode, stderr, env, unsetenv, chdir,
          internal_encoding, external_encoding, scrub, replace_string, wait_timeout, on_exit_callback, &block
      )
        spawn_args = if arguments || subprocess_name
Severity: Major
Found in lib/fluent/plugin_helper/child_process.rb - About 4 hrs to fix

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

          def child_process_execute(
              title, command,
              arguments: nil, subprocess_name: nil, interval: nil, immediate: false, parallel: false,
              mode: [:read, :write], stderr: :discard, env: {}, unsetenv: false, chdir: nil,
              internal_encoding: 'utf-8', external_encoding: 'ascii-8bit', scrub: true, replace_string: nil,
    Severity: Minor
    Found in lib/fluent/plugin_helper/child_process.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 child_process.rb has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'fluent/plugin_helper/thread'
    require 'fluent/plugin_helper/timer'
    require 'fluent/clock'
    
    require 'open3'
    Severity: Minor
    Found in lib/fluent/plugin_helper/child_process.rb - About 3 hrs to fix

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

            def shutdown
              @_child_process_mutex.synchronize{ @_child_process_processes.keys }.each do |pid|
                process_info = @_child_process_processes[pid]
                next if !process_info
                process_info.writeio && process_info.writeio.close rescue nil
      Severity: Minor
      Found in lib/fluent/plugin_helper/child_process.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 close has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def close
              while true
                pids = @_child_process_mutex.synchronize{ @_child_process_processes.keys }
                break if pids.size < 1
      
      
      Severity: Minor
      Found in lib/fluent/plugin_helper/child_process.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 child_process_execute_once has 16 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                title, command, arguments, subprocess_name, mode, stderr, env, unsetenv, chdir,
                internal_encoding, external_encoding, scrub, replace_string, wait_timeout, on_exit_callback, &block
      Severity: Major
      Found in lib/fluent/plugin_helper/child_process.rb - About 2 hrs to fix

        Method child_process_execute has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def child_process_execute(
                  title, command,
                  arguments: nil, subprocess_name: nil, interval: nil, immediate: false, parallel: false,
                  mode: [:read, :write], stderr: :discard, env: {}, unsetenv: false, chdir: nil,
                  internal_encoding: 'utf-8', external_encoding: 'ascii-8bit', scrub: true, replace_string: nil,
        Severity: Minor
        Found in lib/fluent/plugin_helper/child_process.rb - About 1 hr to fix

          Method child_process_kill has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def child_process_kill(pinfo, force: false)
                  return if !pinfo
                  pinfo.killed_at = Fluent::Clock.now unless force
          
                  pid = pinfo.pid
          Severity: Minor
          Found in lib/fluent/plugin_helper/child_process.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 shutdown has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def shutdown
                  @_child_process_mutex.synchronize{ @_child_process_processes.keys }.each do |pid|
                    process_info = @_child_process_processes[pid]
                    next if !process_info
                    process_info.writeio && process_info.writeio.close rescue nil
          Severity: Minor
          Found in lib/fluent/plugin_helper/child_process.rb - About 1 hr to fix

            There are no issues that match your filters.

            Category
            Status