Class: QuietQuality::MessageFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/quiet_quality/message_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(changed_files:) ⇒ MessageFilter

Returns a new instance of MessageFilter.



3
4
5
# File 'lib/quiet_quality/message_filter.rb', line 3

def initialize(changed_files:)
  @changed_files = changed_files
end

Instance Method Details

#filter(messages) ⇒ Object



16
17
18
# File 'lib/quiet_quality/message_filter.rb', line 16

def filter(messages)
  Messages.new(messages.select { |m| relevant?(m) })
end

#relevant?(message) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
# File 'lib/quiet_quality/message_filter.rb', line 7

def relevant?(message)
  return false unless changed_files.include?(message.path)

  file = changed_files.file(message.path)
  return true if file.entire?

  relevant_lines?(message, file)
end