Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Conversation

@cball
Copy link
Contributor

@cball cball commented Sep 26, 2013

  • Allow configuration of a branch to report coverage on (all is the default)
  • Allow disable of warnings ("Not reporting to Code Climate..." - showing warnings is the default)

Since Code Climate only runs analysis on one branch, it seemed reasonable to be able to specify a branch for the coverage as well.

Configuration is a pretty standard setup (and obviously needs to be called before start):

with a block:

CodeClimate::TestReporter.configure do |config|
  config.branch = :master                      
  config.show_warnings = false                 
end                                                         
CodeClimate::TestReporter.start

individual lines:

CodeClimate::TestReporter.configuration.branch = :master
CodeClimate::TestReporter.configuration.show_warnings = false
CodeClimate::TestReporter.start

* Allow configuration of a branch to run coverage on (all is default)
* Allow disable of warnings ("Not reporting to Code Climate...")
@brynary
Copy link
Member

brynary commented Sep 26, 2013

Thanks. I think this is useful functionality.

For the branch, we actually have to use a bit of logic in order to work out the "effective branch" (since the CI system and Git may have different information about the branch name). This is in the Formatter#compute_branch method, and is what we display and use.

So I think the branch filtering should use the result from Formatter#compute_branch for robustness, although that logic may be better moved somewhere else. (Perhaps a separate class.)

For the show_warnings piece: I anticipate we'll be adding more debug information down the road. It probably makes sense to allow people to set the log level. The default logger would be Logger.new($stderr). Then we'd emit the "Not reporting..." message on e.g. info level, and the default would be to log info and up, but you could override and say you want e.g. warnings and up. Sound ok?

@cball
Copy link
Contributor Author

cball commented Oct 2, 2013

@brynary sorry for the delay getting back to you on this. I totally missed Formatter#compute_branch, that makes perfect sense... as does the log level idea. I'll see what I can do on that.

@cball
Copy link
Contributor Author

cball commented Oct 12, 2013

@brynary added changes you suggested, including breaking out git operations to a separate class. Let me know if that's what you had in mind.

@brynary
Copy link
Member

brynary commented Oct 12, 2013

Thanks, Chris. This looks really good. Can you please update the README with examples of configuring the logger and the branch, and I'll merge.

I noticed the Configuration class exposes a log_level attr_accessor in addition to log. Is that intended? For changing the log level, I was thinking you'd just do config.logger.level = Logger::WARN. If you have the log_level attr_accessor, and someone sets it, I think you'd need to update the logger, and I don't see that code.

@cball
Copy link
Contributor Author

cball commented Oct 12, 2013

README updated. Good catch on the unneeded attr_accessor... I forgot to remove that.

brynary added a commit that referenced this pull request Oct 15, 2013
…warnings

Add configuration class, ability to specify a branch to run coverage on, and ability to silence warnings
@brynary brynary merged commit 3e41418 into codeclimate:master Oct 15, 2013
@brynary
Copy link
Member

brynary commented Oct 15, 2013

Merged. Thanks!

@cball
Copy link
Contributor Author

cball commented Oct 15, 2013

Thanks, Bryan. Glad I could help out!

@dogweather
Copy link

Anyone having luck silencing warnings? I'm still getting them in dev/test modes.

@dogweather
Copy link

Ok, config.show_warnings = false is unrecognized, but setting the log level to WARN does work.

@brynary
Copy link
Member

brynary commented Nov 19, 2013

@dogweather what does your config block look like?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants