guard/listen

View on GitHub

Showing 18 of 18 total issues

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

    def self.change(record, rel_path)
      path = Pathname.new(record.root) + rel_path
      lstat = path.lstat

      data = { mtime: lstat.mtime.to_f, mode: lstat.mode, size: lstat.size }
Severity: Minor
Found in lib/listen/file.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 start has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def start
      logger.info 'Starting listen...'

      directory = @options[:directory]
      relative = @options[:relative]
Severity: Minor
Found in lib/listen/cli.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 scan has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def self.scan(snapshot, rel_path, options)
      record = snapshot.record
      dir = Pathname.new(record.root)
      previous = record.dir_entries(rel_path)

Severity: Minor
Found in lib/listen/directory.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 change has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.change(record, rel_path)
      path = Pathname.new(record.root) + rel_path
      lstat = path.lstat

      data = { mtime: lstat.mtime.to_f, mode: lstat.mode, size: lstat.size }
Severity: Minor
Found in lib/listen/file.rb - About 1 hr to fix

    Method scan has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.scan(snapshot, rel_path, options)
          record = snapshot.record
          dir = Pathname.new(record.root)
          previous = record.dir_entries(rel_path)
    
    
    Severity: Minor
    Found in lib/listen/directory.rb - About 1 hr to fix

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

          def invalidate(type, rel_path, options)
            watched_dir = Pathname.new(record.root)
      
            change = options[:change]
            cookie = options[:cookie]
      Severity: Minor
      Found in lib/listen/change.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 _process_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def _process_event(dir, event)
              # NOTE: avoid using event.absolute_name since new API
              # will need to have a custom recursion implemented
              # to properly match events to configured directories
              path = Pathname.new(event.watcher.path) + event.name
      Severity: Minor
      Found in lib/listen/adapter/linux.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 dir_entries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def dir_entries(rel_path)
            rel_path_s = rel_path.to_s
            subtree = if empty_dirname?(rel_path_s)
              @tree
            else
      Severity: Minor
      Found in lib/listen/record.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 << has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def <<(args)
              type, change, dir, path, options = *args
              fail "Invalid type: #{type.inspect}" unless [:dir, :file].include? type
              fail "Invalid change: #{change.inspect}" unless change.is_a?(Symbol)
              fail "Invalid path: #{path.inspect}" unless path.is_a?(String)
      Severity: Minor
      Found in lib/listen/event/queue.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 _calculate_add_remove_difference has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _calculate_add_remove_difference(actions, path, default_if_exists)
            added = actions.count { |x| x == :added }
            removed = actions.count { |x| x == :removed }
            diff = added - removed
      
      
      Severity: Minor
      Found in lib/listen/queue_optimizer.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              listener,
              event_queue,
              queue_optimizer,
              wait_for_delay,
              &block
      Severity: Minor
      Found in lib/listen/event/config.rb - About 35 mins to fix

        Avoid too many return statements within this method.
        Open

              return if /1|true/ =~ ENV['LISTEN_GEM_DISABLE_HASHING']
        Severity: Major
        Found in lib/listen/file.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return unless inaccurate_mac_time?(lstat)
          Severity: Major
          Found in lib/listen/file.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return if data[:mtime].to_i + 2 <= Time.now.to_f
            Severity: Major
            Found in lib/listen/file.rb - About 30 mins to fix

              Method _process_event has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def _process_event(dir, event)
                      Listen.logger.debug "wdm - callback: #{event.inspect}"
              
                      type, change = event
              
              
              Severity: Minor
              Found in lib/listen/adapter/windows.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

              Method validate_and_sanitize_new_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_and_sanitize_new_state(new_state_name)
                    return nil if @state == new_state_name
              
                    if current_state && !current_state.valid_transition?(new_state_name)
                      valid = current_state.transitions.map(&:to_s).join(', ')
              Severity: Minor
              Found in lib/listen/fsm.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

              Method stop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def stop
                    while (listener = @listeners.deq(true))
                      begin
                        listener.stop
                      rescue WeakRef::RefError
              Severity: Minor
              Found in lib/listen.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

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

                  def editor_modified?(changes)
                    return unless changes.size == 2
              
                    from_type = from = nil
                    to_type = to_dir = to = nil
              Severity: Minor
              Found in lib/listen/queue_optimizer.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