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

Don't show no-op regex-lint output. #14656

Merged
merged 2 commits into from Mar 1, 2022
Merged

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Mar 1, 2022

Other linters only display output if they acted on at least one file.
Previously, we would always show regex-lint output, even in the
no-op case of acting on no files. This change brings regex-lint
into line with the other linters.

[ci skip-rust]

[ci skip-build-wheels]

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Mar 1, 2022

Before, on a branch with no changes:

$ ./pants --changed-since=HEAD lint
20:35:13.00 [INFO] Completed: Lint with regex patterns - regex-lint succeeded.
0 files matched all required patterns.
0 files failed to match at least one required pattern.



✓ regex-lint succeeded.
$

After:

$ ./pants --changed-since=HEAD lint
$ 

Other linters only display output if they acted on at least one file.
Previously, we would always show regex-lint output, even in the
no-op case of acting on no files. This change brings regex-lint
into line with the other linters.

[ci skip-rust]

[ci skip-build-wheels]
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Great catch!

Comment on lines 218 to 219
if request_type.name in specified_names and specs_snapshot.snapshot.files
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Peformance nit: you can make this O(1) rather than O(n):

Suggested change
if request_type.name in specified_names and specs_snapshot.snapshot.files
)
if request_type.name in specified_names
) if specs_snapshot.snapshot.files else ()

(Black might not like this formatting, so better to manually apply the fix)

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@benjyw benjyw merged commit 7e97ef6 into pantsbuild:main Mar 1, 2022
@benjyw benjyw deleted the fix_regex_lint branch March 1, 2022 05:45
Eric-Arellano pushed a commit to Eric-Arellano/pants that referenced this pull request Mar 2, 2022
Other linters only display output if they acted on at least one file.
Previously, we would always show regex-lint output, even in the
no-op case of acting on no files. This change brings regex-lint
into line with the other linters.

[ci skip-rust]

[ci skip-build-wheels]
Eric-Arellano added a commit that referenced this pull request Mar 2, 2022
Other linters only display output if they acted on at least one file.
Previously, we would always show regex-lint output, even in the
no-op case of acting on no files. This change brings regex-lint
into line with the other linters.

[ci skip-rust]

[ci skip-build-wheels]

Co-authored-by: Benjy Weinberger <benjyw@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants