Skip to content

Commit cf8ac89

Browse files
committed
remove duplicates
1 parent c94019d commit cf8ac89

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

lib/suppressions_populator.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def initialize(tokens)
1919
end
2020

2121
def populate
22-
"#{HEADER}\n#{@tokens.map(&:to_suppression).join("\n")}\n\n#{FOOTER}"
22+
"#{HEADER}\n#{@tokens.uniq do |token|
23+
[token.file_name, token.offense]
24+
end.map(&:to_suppression).join("\n")}\n\n#{FOOTER}"
2325
end
2426
end

test/checkstyle_output_token_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ def test_initialize
1010
assert_equal 'WARNING', token.severity
1111
assert_equal 'file.java', token.file_name
1212
assert_equal 'WhitespaceAround', token.offense
13-
assert_equal " <suppress checks=\"WhitespaceAround\" files=\"file.java\"/>", token.to_suppression
13+
assert_equal ' <suppress checks="WhitespaceAround" files="file.java"/>', token.to_suppression
1414
end
1515
end

test/suppressions_populator_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class SuppressionsPopulatorTest < Minitest::Test
66
def setup
77
@tokens = [
8+
CheckstyleOutputToken.new(['', 'WARNING', 'file1.java', 'Offense1']),
89
CheckstyleOutputToken.new(['', 'WARNING', 'file1.java', 'Offense1']),
910
CheckstyleOutputToken.new(['', 'ERROR', 'file2.java', 'Offense2']),
1011
CheckstyleOutputToken.new(['', 'WARNING', 'file3.java', 'Offense3'])

0 commit comments

Comments
 (0)