I am trying to create a report in simplecov to report on rogue actions within my application. Basically I want a tab that reports any and only files that use the :nocov:
parameter to prevent simplecov from reporting it. Now, I know these may not be all bad, so I only want to filter them to a tab and not affect the overall score.
Currently I have the custom tab setup, but the filter does not filter the files correctly. Can anyone point me in the right direction?
Sample simple cov ignored method:
# :nocov:
def my_debug_method
do_something
end
# :nocov:
Here is my current .simplecov
setup:
class IgnoredCodeFilter < SimpleCov::Filter
def matches?(src_file)
src_file.grep(/:nocov:/).size > 0
end
end
SimpleCov.start do
add_group "Ignored Code" do |src_file|
IgnoredCodeFilter.new(src_file)
end
end
Current error message:
Formatter SimpleCov::Formatter::HTMLFormatter failed with NoMethodError: undefined method `grep' for #<SimpleCov::SourceFile:0x007f920e166fa0> (.simplecov:13:in `block (2 levels) in <top (required)>')
Here is how I ultimately solved this issue in case others are looking for it.
Just add this to your .simplecov
configuration file:
SimpleCov.start do
add_group "Ignored Code" do |src_file|
open(src_file.filename).grep(/:nocov:/).any?
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.