grodowski / undercover

undercover warns about methods, classes and blocks that were changed without tests, to help you easily find untested code and reduce the number of bugs. It does so by analysing data from git diffs, code structure and SimpleCov coverage reports
https://undercover-ci.com
MIT License
724 stars 28 forks source link

Lack of a formatters interface #178

Open Drowze opened 2 years ago

Drowze commented 2 years ago

Hello @grodowski 👋

First of all, I'd like to say thank you for this great project! I've been using it extensively for the past year on the CI of a few internal repositories and it's quite handy to me and my peers. Great work!

After some time with undercover however, I feel that it lacks a formatter interface. I see on this line a comment that even hints that a formatter interface was planned: https://github.com/grodowski/undercover/blob/master/lib/undercover/result.rb#L63

    # TODO: create a formatter interface instead and add some tests.

That said, this is something that concerns me so I'd like to help 😄 I've been actually working a bit on some changes (which you can check here) that aim de-couple the Result from Formatter - thus allowing other formatters to be used. I would personally like to see this being possible (which I think is exactly how rubocop handle this):

undercover --require $(pwd)/my_custom_formatter.rb --formatter MyCustomFormatter

# or if the formatter is on a gem and the gem is on the gemfile along with undercover:
bundle exec undercover --formtter MyCustomFormatter

I'm a bit concerned though as this would be a slightly big change - so I'd like to ask your opinion before opening my first PR on this project. What do you think @grodowski? Can I go ahead and try to tackle this one? 😄

grodowski commented 2 years ago

Hey @Drowze! Thank you for the kind words and your willingness to contribute to the project! This formatter TODO is really old and I couldn't find a good reason to get back to it and implement a formatter class.

I went through your changes and think there are two aspects: one being about decoupling Result and Formatter and the other to provide a formatter argument to the CLI.

I have been usually suggesting pronto and pronto-undercover which provides a --formatter option and comes with a suite of handy ones like github_pr already. So what are the benefits of adding a pretty similar interface to undercover itself? Do you have a use case in mind for when this new option would become available?