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

Add filter for hidden files and folders per default #721

Merged
merged 1 commit into from Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@

## Enhancements

* Per default filter hidden files and folders. See [#721](https://github.com/colszowka/simplecov/pull/721) (thanks [Renuo AG](https://www.renuo.ch))
* Print the exit status explicitly when it's not a successful build so it's easier figure out SimpleCov failed the build in the output.

## Bugfixes
Expand Down
2 changes: 2 additions & 0 deletions lib/simplecov/defaults.rb
Expand Up @@ -6,12 +6,14 @@
require "simplecov/profiles/root_filter"
require "simplecov/profiles/test_frameworks"
require "simplecov/profiles/bundler_filter"
require "simplecov/profiles/hidden_filter"
require "simplecov/profiles/rails"

# Default configuration
SimpleCov.configure do
formatter SimpleCov::Formatter::HTMLFormatter
load_profile "bundler_filter"
load_profile "hidden_filter"
# Exclude files outside of SimpleCov.root
load_profile "root_filter"
end
Expand Down
5 changes: 5 additions & 0 deletions lib/simplecov/profiles/hidden_filter.rb
@@ -0,0 +1,5 @@
# frozen_string_literal: true

SimpleCov.profiles.define "hidden_filter" do
add_filter %r{^/\..*}
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 could as well imagine to filter all hidden files and folders and not only the ones in the root folder. I didn't do it because it could be harder to debug.

end
12 changes: 12 additions & 0 deletions spec/filters_spec.rb
Expand Up @@ -173,6 +173,18 @@ def a_file(path)
it "filters vendor/bundle" do
expect(SimpleCov.filtered([a_file("vendor/bundle/foo.rb")]).count).to eq(0)
end

it "filters hidden folders" do
expect(SimpleCov.filtered([a_file(".semaphore-cache/lib.rb")]).count).to eq(0)
end

it "filters hidden files" do
expect(SimpleCov.filtered([a_file(".hidden_config.rb")]).count).to eq(0)
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please add a test to verify that we're not filtering hidden sub folders? I like your argument for not filtering so I think we should spec it as expected behaviour :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're totally right! I added the test.


it "doesn't filter hidden files further down the path" do
expect(SimpleCov.filtered([a_file("some_dir/.sneaky.rb")]).count).to eq(1)
end
end

context "outside the project" do
Expand Down