diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index b8d05f2ecd..718ac2a0f5 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -72,6 +72,7 @@ def generated? generated_yarn_plugnplay? || godeps? || generated_by_zephir? || + htmlcov? || minified_files? || has_source_map? || source_map? || @@ -797,6 +798,15 @@ def generated_sorbet_rbi? lines[4].match?(/^# Please.*run.*`.*tapioca/) end + # Internal: Is this an HTML coverage report? + # + # Tools like coverage.py generate HTML reports under an `htmlcov` directory. + # + # Returns true or false. + def htmlcov? + !!name.match(/(?:^|\/)htmlcov\//) + end + # Internal: Extract a Hash of name/content pairs from an HTML tag def extract_html_meta(match) (match.last.sub(/\/\Z/, "").strip.scan(/ diff --git a/test/test_generated.rb b/test/test_generated.rb index eab1b5eedd..dc5ec9b846 100644 --- a/test/test_generated.rb +++ b/test/test_generated.rb @@ -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.