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

Commit 00e49a5

Browse files
authored
Merge pull request #276 from codecov/dana/disable-file-fixes
disable file fixes
2 parents 31278f2 + 838b202 commit 00e49a5

File tree

6 files changed

+30
-2
lines changed

6 files changed

+30
-2
lines changed

codecov_cli/commands/upload.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def _turn_env_vars_into_dict(ctx, params, value):
6565
is_flag=True,
6666
default=False,
6767
),
68+
click.option(
69+
"--disable-file-fixes",
70+
help="Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets)",
71+
is_flag=True,
72+
default=False,
73+
),
6874
click.option(
6975
"-b",
7076
"--build",
@@ -178,6 +184,7 @@ def do_upload(
178184
coverage_files_search_exclude_folders: typing.List[pathlib.Path],
179185
coverage_files_search_explicitly_listed_files: typing.List[pathlib.Path],
180186
disable_search: bool,
187+
disable_file_fixes: bool,
181188
token: typing.Optional[uuid.UUID],
182189
plugin_names: typing.List[str],
183190
branch: typing.Optional[str],
@@ -218,6 +225,7 @@ def do_upload(
218225
git_service=git_service,
219226
enterprise_url=enterprise_url,
220227
disable_search=disable_search,
228+
disable_file_fixes=disable_file_fixes,
221229
handle_no_reports_found=handle_no_reports_found,
222230
)
223231
),
@@ -254,4 +262,5 @@ def do_upload(
254262
enterprise_url=enterprise_url,
255263
disable_search=disable_search,
256264
handle_no_reports_found=handle_no_reports_found,
265+
disable_file_fixes=disable_file_fixes,
257266
)

codecov_cli/commands/upload_process.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def upload_process(
3737
coverage_files_search_exclude_folders: typing.List[pathlib.Path],
3838
coverage_files_search_explicitly_listed_files: typing.List[pathlib.Path],
3939
disable_search: bool,
40+
disable_file_fixes: bool,
4041
token: typing.Optional[uuid.UUID],
4142
plugin_names: typing.List[str],
4243
branch: typing.Optional[str],
@@ -72,6 +73,7 @@ def upload_process(
7273
pull_request_number=pull_request_number,
7374
git_service=git_service,
7475
disable_search=disable_search,
76+
disable_file_fixes=disable_file_fixes,
7577
fail_on_error=fail_on_error,
7678
handle_no_reports_found=handle_no_reports_found,
7779
)
@@ -123,4 +125,5 @@ def upload_process(
123125
dry_run=dry_run,
124126
git_service=git_service,
125127
handle_no_reports_found=handle_no_reports_found,
128+
disable_file_fixes=disable_file_fixes,
126129
)

codecov_cli/services/upload/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def do_upload_logic(
5050
enterprise_url: typing.Optional[str],
5151
disable_search: bool = False,
5252
handle_no_reports_found: bool = False,
53+
disable_file_fixes: bool = False,
5354
):
5455
preparation_plugins = select_preparation_plugins(cli_config, plugin_names)
5556
coverage_file_selector = select_coverage_file_finder(
@@ -60,7 +61,7 @@ def do_upload_logic(
6061
)
6162
network_finder = select_network_finder(versioning_system)
6263
collector = UploadCollector(
63-
preparation_plugins, network_finder, coverage_file_selector
64+
preparation_plugins, network_finder, coverage_file_selector, disable_file_fixes
6465
)
6566
try:
6667
upload_data = collector.generate_upload_data()

codecov_cli/services/upload/upload_collector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ def __init__(
2929
preparation_plugins: typing.List[PreparationPluginInterface],
3030
network_finder: NetworkFinder,
3131
coverage_file_finder: CoverageFileFinder,
32+
disable_file_fixes: bool = False,
3233
):
3334
self.preparation_plugins = preparation_plugins
3435
self.network_finder = network_finder
3536
self.coverage_file_finder = coverage_file_finder
37+
self.disable_file_fixes = disable_file_fixes
3638

3739
def _produce_file_fixes_for_network(
3840
self, network: typing.List[str]
3941
) -> typing.List[UploadCollectionResultFileFixer]:
40-
if not network:
42+
if not network or self.disable_file_fixes:
4143
return []
4244
# patterns that we don't need to specify a reason for
4345
empty_line_regex = re.compile(r"^\s*$")

tests/commands/test_invoke_upload_process.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def test_upload_process_options(mocker):
9292
" --disable-search Disable search for coverage files. This is",
9393
" helpful when specifying what files you want to",
9494
" uload with the --file option.",
95+
" --disable-file-fixes Disable file fixes to ignore common lines from",
96+
" coverage (e.g. blank lines or empty brackets)",
9597
" -b, --build, --build-code TEXT Specify the build number manually",
9698
" --build-url TEXT The URL of the build where this is running",
9799
" --job-code TEXT",

tests/services/upload/test_upload_collector.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,14 @@ def test_fix_for_cpp_swift_vala(tmp_path):
9898
(7, "// LCOV_EXCL_START\n"),
9999
]
100100
)
101+
102+
103+
def test_fix_when_disabled_fixes(tmp_path):
104+
cpp_file = Path("tests/data/files_to_fix_examples/sample.cpp")
105+
106+
col = UploadCollector(None, None, None, True)
107+
108+
fixes = col._produce_file_fixes_for_network([str(cpp_file)])
109+
110+
assert len(fixes) == 0
111+
assert fixes == []

0 commit comments

Comments
 (0)