Showing 26 of 32 total issues

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

    def self.match_files(guard, files)
      return [] if files.empty?

      files.inject([]) do |paths, file|
        guard.watchers.each do |watcher|
Severity: Minor
Found in lib/guard/watcher.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

Class Engine has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Engine
    extend Forwardable
    include Internals::Helpers

    # @private
Severity: Minor
Found in lib/guard/engine.rb - About 3 hrs to fix

    Class PryWrapper has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class PryWrapper < Base
          # The default Ruby script to configure Guard Pry if the option `:guard_rc`
          # is not defined.
    
          GUARD_RC = if ENV["XDG_CONFIG_HOME"] && File.exist?(ENV["XDG_CONFIG_HOME"] + "/guard/guardrc")
    Severity: Minor
    Found in lib/guard/jobs/pry_wrapper.rb - About 3 hrs to fix

      Method notifiers has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def notifiers
            supported = Notifier.supported
            Notifier.connect(notify: true, silent: true)
            detected = Notifier.detected
            Notifier.disconnect
      Severity: Minor
      Found in lib/guard/dsl_describer.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

      Class Session has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Session
            attr_reader :plugins, :groups
      
            DEFAULT_OPTIONS = {
              clear: false,
      Severity: Minor
      Found in lib/guard/internals/session.rb - About 2 hrs to fix

        Method show has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def show
              objects = []
              empty_plugin = ["", { "" => nil }]
        
              guardfile_result.groups.each do |group_name, options|
        Severity: Minor
        Found in lib/guard/dsl_describer.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 run_on_changes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def run_on_changes(modified, added, removed)
              types = {
                MODIFICATION_TASKS => modified,
                ADDITION_TASKS => added,
                REMOVAL_TASKS => removed
        Severity: Minor
        Found in lib/guard/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 clear has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def clear(opts = {})
                return unless engine
                return unless engine.session.clear?
        
                fail "UI not set up!" if clearable.nil?
        Severity: Minor
        Found in lib/guard/ui.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 show has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def show
              objects = []
              empty_plugin = ["", { "" => nil }]
        
              guardfile_result.groups.each do |group_name, options|
        Severity: Minor
        Found in lib/guard/dsl_describer.rb - About 1 hr to fix

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

                def color_enabled?
                  @color_enabled_initialized ||= false
                  @color_enabled = nil unless @color_enabled_initialized
                  @color_enabled_initialized = true
                  return @color_enabled unless @color_enabled.nil?
          Severity: Minor
          Found in lib/guard/ui.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 notifiers has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def notifiers
                supported = Notifier.supported
                Notifier.connect(notify: true, silent: true)
                detected = Notifier.detected
                Notifier.disconnect
          Severity: Minor
          Found in lib/guard/dsl_describer.rb - About 1 hr to fix

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

                def logger(options)
                  logger_options = options.dup
            
                  if logger_options.key?(:level)
                    level = logger_options.delete(:level).to_sym
            Severity: Minor
            Found in lib/guard/dsl.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_guardfile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def initialize_guardfile(
                      plugin_names = [],
                      evaluator: Guardfile::Evaluator.new(options),
                      generator: Guardfile::Generator.new
                    )
            Severity: Minor
            Found in lib/guard/cli/environments/write.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 start has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def start
                  setup
            
                  _initialize_listener
                  _initialize_signal_traps
            Severity: Minor
            Found in lib/guard/engine.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 _add_row has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def _add_row(rows, name, available, used, option, value)
            Severity: Minor
            Found in lib/guard/dsl_describer.rb - About 45 mins to fix

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

                  def plugin_class
                    const = _plugin_constant
                    fail TypeError, "no constant: #{_constant_name}" unless const
              
                    @plugin_class ||= Guard.const_get(const)
              Severity: Minor
              Found in lib/guard/plugin_util.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 pause has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def pause(expected = nil)
                    states = { paused: true, unpaused: false, toggle: !paused? }
                    key = expected || :toggle
              
                    raise ArgumentError, "invalid mode: #{expected.inspect}" unless states.key?(key)
              Severity: Minor
              Found in lib/guard/engine.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 color has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def color(text, *color_options)
                      color_code = ""
                      color_options.each do |color_option|
                        color_option = color_option.to_s
                        next if color_option == ""
              Severity: Minor
              Found in lib/guard/ui.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 group has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def group(*args)
                    options = args.last.is_a?(Hash) ? args.pop : {}
                    group = args.pop.to_sym
              
                    if block_given?
              Severity: Minor
              Found in lib/guard/dsl.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 match has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def match(file)
                        _watches.map do |expr, block|
                          next unless (match = file.match(expr))
              
                          block.nil? ? [file] : block.call([file] + match.captures)
              Severity: Minor
              Found in lib/guard/test_helpers.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

              Severity
              Category
              Status
              Source
              Language