Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters out duplicate offences for Github formatters #44

Merged
merged 2 commits into from
Nov 11, 2014

Conversation

edk
Copy link
Contributor

@edk edk commented Nov 11, 2014

When the same exact message is repeated on the same line,
this change removes the duplicates. The test was updated
to reflect this changed behavior as well.

Hi @mmozuras! This PR is now in a branch (sorry I didn't read the contributing guidelines before making the first PR against master) and fixes the failing test.

@edk edk closed this Nov 11, 2014
@edk edk reopened this Nov 11, 2014
@@ -2,6 +2,13 @@ module Pronto
module Formatter
class GithubFormatter
def format(messages, repo)
messages = messages.each_with_object(Hash.new { |h, k| h[k] = [] }) { |msg, memo|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe #uniq could be used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally used uniq with a block, but I thought that could have been more inefficient than the avoidance check.

I'd be happy to use uniq if you think it's better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, you mean a uniq check inside the each_with_object loop, right? Or is there a way to use uniq on messages that could detect duplicate messages per line, but not across all messages?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edk what about something like this:

messages.uniq { |message| [message.msg, message.line.new_line] }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! I didn't think of that! Let me try it and update the PR 👍

When the same exact message is repeated on the same line,
this change removes the duplicates.  The test was updated
to reflect this changed behavior as well.
@edk edk force-pushed the github_formatter_filter_duplicates branch from 47e15fe to 24f3019 Compare November 11, 2014 17:55
@edk
Copy link
Contributor Author

edk commented Nov 11, 2014

Updated with sweet refactor, courtesy of @mmozuras :)

@mmozuras
Copy link
Member

@edk looks good. Could you also update CHANGELOG? Put it under ## Unreleased -> ### Changes.

@edk
Copy link
Contributor Author

edk commented Nov 11, 2014

Changelog updated.

@mmozuras
Copy link
Member

@edk thanks, 👍

mmozuras added a commit that referenced this pull request Nov 11, 2014
Filters out duplicate offences for Github formatters
@mmozuras mmozuras merged commit 603ffef into prontolabs:master Nov 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants