piotrmurach/tty-command

View on GitHub

Showing 9 of 9 total issues

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

      def spawn(cmd)
        process_opts = normalize_redirect_options(cmd.options)
        binmode = cmd.options[:binmode] || false
        pty     = cmd.options[:pty] || false
        verbose = cmd.options[:verbose]
Severity: Minor
Found in lib/tty/command/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 initialize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(env_or_cmd, *args)
        opts = args.last.respond_to?(:to_hash) ? args.pop : {}
        if env_or_cmd.respond_to?(:to_hash)
          @env = env_or_cmd
          unless command = args.shift
Severity: Minor
Found in lib/tty/command/cmd.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 spawn has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def spawn(cmd)
        process_opts = normalize_redirect_options(cmd.options)
        binmode = cmd.options[:binmode] || false
        pty     = cmd.options[:pty] || false
        verbose = cmd.options[:verbose]
Severity: Minor
Found in lib/tty/command/child_process.rb - About 1 hr to fix

    Method write_stream has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def write_stream(stream, input)
            start = Time.now
            writers = [input && stream].compact
    
            while writers.any?
    Severity: Minor
    Found in lib/tty/command/process_runner.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 read_stream has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def read_stream(stream, handler)
            Thread.new do
              if Thread.current.respond_to?(:report_on_exception)
                Thread.current.report_on_exception = false
              end
    Severity: Minor
    Found in lib/tty/command/process_runner.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def initialize(env_or_cmd, *args)
            opts = args.last.respond_to?(:to_hash) ? args.pop : {}
            if env_or_cmd.respond_to?(:to_hash)
              @env = env_or_cmd
              unless command = args.shift
    Severity: Minor
    Found in lib/tty/command/cmd.rb - About 1 hr to fix

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

              def write(cmd, message, data = nil)
                cmd_set_uuid = cmd.options.fetch(:uuid, true)
                uuid_needed = cmd.options[:uuid].nil? ? @uuid : cmd_set_uuid
                out = []
                if uuid_needed
      Severity: Minor
      Found in lib/tty/command/printers/pretty.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 wait has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def wait(*args)
            pattern = args.pop
            unless pattern
              raise ArgumentError, "Please provide condition to wait for"
            end
      Severity: Minor
      Found in lib/tty/command.rb - About 35 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 read_streams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def read_streams(stdout, stderr)
              stdout_data = []
              stderr_data = Truncator.new
      
              out_handler = ->(data) {
      Severity: Minor
      Found in lib/tty/command/process_runner.rb - About 25 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