Skip to content

Commit

Permalink
issue #504: set Layout/EndAlignment: EnforcedStyleAlignWith: variable…
Browse files Browse the repository at this point in the history
…; move LineLength to Layout namespace
  • Loading branch information
ColinDKelley committed Nov 27, 2020
1 parent f9afea2 commit b576ff6
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 40 deletions.
6 changes: 4 additions & 2 deletions .rubocop.yml
Expand Up @@ -18,10 +18,14 @@ Layout/EmptyLineAfterGuardClause:
Enabled: false
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Layout/EndAlignment:
EnforcedStyleAlignWith: variable
Layout/HashAlignment:
Enabled: false
Layout/HeredocIndentation:
Enabled: true
Layout/LineLength:
Max: 150
Layout/MultilineMethodCallBraceLayout:
Enabled: false
Layout/MultilineMethodCallIndentation:
Expand Down Expand Up @@ -99,8 +103,6 @@ Metrics/BlockLength:
- "**/*_spec.rb"
Metrics/CyclomaticComplexity:
Max: 10
Metrics/LineLength:
Max: 150
Metrics/MethodLength:
Max: 15
Metrics/ModuleLength:
Expand Down
8 changes: 4 additions & 4 deletions lib/listen/event/queue.rb
Expand Up @@ -31,10 +31,10 @@ def <<(args)
fail "Invalid path: #{path.inspect}" unless path.is_a?(String)

dir = if @config.relative?
_safe_relative_from_cwd(dir)
else
dir
end
_safe_relative_from_cwd(dir)
else
dir
end
@event_queue << [type, change, dir, path, options]
end

Expand Down
4 changes: 2 additions & 2 deletions lib/listen/fsm.rb
Expand Up @@ -113,8 +113,8 @@ def initialize(name, transitions, &block)
@name = name
@block = block
@transitions = if transitions
Array(transitions).map(&:to_sym)
end
Array(transitions).map(&:to_sym)
end
end

def call(obj)
Expand Down
25 changes: 13 additions & 12 deletions lib/listen/logger.rb
Expand Up @@ -16,18 +16,19 @@ def logger
private

def default_logger
level = case ENV['LISTEN_GEM_DEBUGGING'].to_s
when /debug|2/i
::Logger::DEBUG
when /info|true|yes|1/i
::Logger::INFO
when /warn/i
::Logger::WARN
when /fatal/i
::Logger::FATAL
else
::Logger::ERROR
end
level =
case ENV['LISTEN_GEM_DEBUGGING'].to_s
when /debug|2/i
::Logger::DEBUG
when /info|true|yes|1/i
::Logger::INFO
when /warn/i
::Logger::WARN
when /fatal/i
::Logger::FATAL
else
::Logger::ERROR
end

::Logger.new(STDERR, level: level)
end
Expand Down
8 changes: 4 additions & 4 deletions lib/listen/record.rb
Expand Up @@ -46,10 +46,10 @@ def file_data(rel_path)

def dir_entries(rel_path)
subtree = if [nil, '', '.'].include? rel_path.to_s
@tree
else
_sub_tree(rel_path)
end
@tree
else
_sub_tree(rel_path)
end

subtree.transform_values do |values|
# only get data for file entries
Expand Down
8 changes: 4 additions & 4 deletions lib/listen/thread.rb
Expand Up @@ -32,10 +32,10 @@ def rescue_and_log(method_name, *args, caller_stack: nil)

def _log_exception(exception, thread_name, caller_stack: nil)
complete_backtrace = if caller_stack
[*exception.backtrace, "--- Thread.new ---", *caller_stack]
else
exception.backtrace
end
[*exception.backtrace, "--- Thread.new ---", *caller_stack]
else
exception.backtrace
end
message = "Exception rescued in #{thread_name}:\n#{_exception_with_causes(exception)}\n#{complete_backtrace * "\n"}"
Listen.logger.error(message)
end
Expand Down
23 changes: 11 additions & 12 deletions spec/support/acceptance_helper.rb
Expand Up @@ -158,19 +158,18 @@ def initialize(callback, paths, *args)
# Isolate collected changes between tests/listener instances
@timed_changes = TimedChanges.new

@listener =
if callback
Listen.send(*args) do |modified, added, removed|
# Add changes to trigger frozen Hash error, making sure lag is enough
_add_changes(:modified, modified, changes)
_add_changes(:added, added, changes)
_add_changes(:removed, removed, changes)

callback.call(modified, added, removed) unless callback == :track_changes
end
else
Listen.send(*args)
@listener = if callback
Listen.send(*args) do |modified, added, removed|
# Add changes to trigger frozen Hash error, making sure lag is enough
_add_changes(:modified, modified, changes)
_add_changes(:added, added, changes)
_add_changes(:removed, removed, changes)

callback.call(modified, added, removed) unless callback == :track_changes
end
else
Listen.send(*args)
end
end

def changes
Expand Down

0 comments on commit b576ff6

Please sign in to comment.