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

Mark files under htmlcov/ as generated #6491

Merged
merged 4 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def generated?
generated_yarn_plugnplay? ||
godeps? ||
generated_by_zephir? ||
coveragepy_htmlcov_file? ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: it makes more sense to name this htmlcov?, as the method doesn't involve anything more specific than pathname examination.

(If we checked for a substring like <!-- Generated by coverage.py v1.23 --> or what-have-you, then it might make more sense to tie this method to a specific utility).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks!

minified_files? ||
has_source_map? ||
source_map? ||
Expand Down Expand Up @@ -797,6 +798,15 @@ def generated_sorbet_rbi?
lines[4].match?(/^# Please.*run.*`.*tapioca/)
end

# Internal: Is this an HTML report generated by coverage.py?
#
# coverage.py generates HTML reports under an `htmlcov` directory.
#
# Returns true or false.
def coveragepy_htmlcov_file?
!!name.match(/(?:^|\/)htmlcov\//)
end
spenserblack marked this conversation as resolved.
Show resolved Hide resolved

# Internal: Extract a Hash of name/content pairs from an HTML <meta> tag
def extract_html_meta(match)
(match.last.sub(/\/\Z/, "").strip.scan(/
Expand Down
10 changes: 10 additions & 0 deletions test/test_generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ def test_check_generated

# pdm
generated_sample_without_loading_data("TOML/filenames/pdm.lock")

# coverage.py `coverage html` output
generated_sample_without_loading_data("htmlcov/index.html")
generated_sample_without_loading_data("htmlcov/coverage_html.js")
generated_sample_without_loading_data("htmlcov/style.css")
generated_sample_without_loading_data("htmlcov/status.json")
generated_sample_without_loading_data("Dummy/htmlcov/index.html")
generated_sample_without_loading_data("Dummy/htmlcov/coverage_html.js")
generated_sample_without_loading_data("Dummy/htmlcov/style.css")
generated_sample_without_loading_data("Dummy/htmlcov/status.json")
end

# We've whitelisted these files on purpose, even though they're machine-generated.
Expand Down