Skip to content

Conversation

@wchargin
Copy link
Contributor

@wchargin wchargin commented Dec 28, 2020

Summary:
We run Clippy to catch common errors, but by default Clippy only runs on
non-test code. We noticed this in #4487, when Clippy would have caught a
real error (test doing nothing due to unit_cmp). This patch adds the
--tests flag to our Clippy invocation and fixes all existing warnings.

Test Plan:
The first draft of this PR included only the workflow change, and thus
properly failed on CI. Once the fixes were included, CI passed.

wchargin-branch: rust-clippy-tests

Summary:
We run Clippy to catch common errors, but by default Clippy only runs on
non-test code. We noticed this in #4487, when Clippy would have caught a
real error (test doing nothing due to `unit_cmp`). This patch adds the
`--tests` flag to our Clippy invocation and fixes all existing warnings.

Test Plan:
The first draft of this PR will include only the workflow change, and so
should fail…

wchargin-branch: rust-clippy-tests
wchargin-source: 3be9bc4b9c2084a9f9dda2b0082227f061989811
@wchargin wchargin added type:build/install core:rustboard //tensorboard/data/server/... labels Dec 28, 2020
@google-cla google-cla bot added the cla: yes label Dec 28, 2020
wchargin-branch: rust-clippy-tests
wchargin-source: 48d4d66fb8ad1a7450fa3036379fedcc4191e0e1
@wchargin wchargin requested a review from bileschi December 28, 2020 21:53
pub fn zero(x: f32) -> bool {
x == 0.0
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of this zero function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, unintentional; thanks for catching. (I added this while playing
around with different approaches to the float_cmp lint: I was trying
to set #![cfg_attr(test, allow(clippy::float_cmp))] to permit
floating-point comparisons in test code, but it didn’t do exactly what
I’d wanted.)

Copy link
Collaborator

@bileschi bileschi left a comment

Choose a reason for hiding this comment

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

Approved. Confused about the zero impl. Don't see anything in the lint about problems with lib.rs either?

wchargin-branch: rust-clippy-tests
wchargin-source: 1c901870ac667625b5b2332c8bf65492c0457e92
@wchargin wchargin merged commit 40df025 into master Jan 5, 2021
@wchargin wchargin deleted the wchargin-rust-clippy-tests branch January 5, 2021 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants