Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Make CI fail if Clippy finds any warnings. #104

Merged
merged 11 commits into from
Nov 3, 2019
Merged

Make CI fail if Clippy finds any warnings. #104

merged 11 commits into from
Nov 3, 2019

Conversation

crsaracco
Copy link
Member

@crsaracco crsaracco commented Jul 14, 2019

Fail the CI tests if Clippy reports any warnings.

@crsaracco crsaracco changed the title [WIP] Make CI fail if Clippy finds any warnings. [PENDING #102] Make CI fail if Clippy finds any warnings. Jul 14, 2019
Copy link
Contributor

@askeksa askeksa left a comment

Choose a reason for hiding this comment

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

A few comments regarding the float comparison changes.

The rest of the changes seem pretty reasonable. At least they don't seem to break anything. :)

src/util/parameter_transfer.rs Outdated Show resolved Hide resolved
src/util/test_util.rs Outdated Show resolved Hide resolved
src/util/test_util.rs Outdated Show resolved Hide resolved
src/buffer.rs Outdated Show resolved Hide resolved
src/buffer.rs Outdated Show resolved Hide resolved
@crsaracco
Copy link
Member Author

@askeksa changes SGTM, I'll re-visit them and fix after #102 is merged in.

@askeksa
Copy link
Contributor

askeksa commented Aug 16, 2019

Actually, when looking closer, it looks to me like none of the approximate float comparisons are warranted. They are either checking if some value has changed since last time, checking against a specific value set in a test, or comparing with a value obtained by summing some integers. In all of these cases, exact comparison is the right thing to do.

@crsaracco crsaracco mentioned this pull request Nov 2, 2019
13 tasks
@crsaracco crsaracco changed the title [PENDING #102] Make CI fail if Clippy finds any warnings. Make CI fail if Clippy finds any warnings. Nov 3, 2019
@crsaracco crsaracco changed the title Make CI fail if Clippy finds any warnings. [WIP] Make CI fail if Clippy finds any warnings. Nov 3, 2019
@crsaracco
Copy link
Member Author

Actually, when looking closer, it looks to me like none of the approximate float comparisons are warranted. They are either checking if some value has changed since last time, checking against a specific value set in a test, or comparing with a value obtained by summing some integers. In all of these cases, exact comparison is the right thing to do.

Agreed. I think I was just blindly following clippy for that lint when I made this PR.

Reverted back to strict compares, added #[allow(clippy::float_cmp)] for those tests, and removed the test_util module I added since the functions weren't being used anymore.

@crsaracco crsaracco changed the title [WIP] Make CI fail if Clippy finds any warnings. Make CI fail if Clippy finds any warnings. Nov 3, 2019
Copy link
Contributor

@askeksa askeksa left a comment

Choose a reason for hiding this comment

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

Many of the Clippy suggestions are good, but some are really bad, making me wonder if enforcing no Clippy warnings across the repo is such a good idea after all. At least without a generous, crate-wide list of exceptions (which, it seems, is not yet possible).

Many of the changes in this PR are still fine, and could go into a "Fix some Clippy warnings" commit.

examples/dimension_expander.rs Outdated Show resolved Hide resolved
examples/ladder_filter.rs Outdated Show resolved Hide resolved
examples/transfer_and_smooth.rs Outdated Show resolved Hide resolved
src/buffer.rs Outdated Show resolved Hide resolved
src/plugin.rs Show resolved Hide resolved
src/plugin.rs Outdated Show resolved Hide resolved
src/util/parameter_transfer.rs Outdated Show resolved Hide resolved
@crsaracco
Copy link
Member Author

crsaracco commented Nov 3, 2019

Many of the Clippy suggestions are good, but some are really bad, making me wonder if enforcing no Clippy warnings across the repo is such a good idea after all. At least without a generous, crate-wide list of exceptions (which, it seems, is not yet possible).

I don't know, I think the Clippy suggestions are good enough to warrant enforcement in the general case, especially in the context of an open source project where anyone can make a PR. Even moreso when other projects in the ecosystem use Clippy to help identify ecosystem-wide issues. We have historically been terrible at checking the travis output to see if we broke any Clippy lints, so I'd rather enforce them up-front.

I think it's easy enough to chuck on a #[allow(clippy::whatever)] with justifications in the code review (I would even like the justifications in the comments, but anyways...)

Finally, if a particular lint is causing us too much trouble for what it's worth, we can decide to ignore it crate-wide in the CI file, like I did for "unreadable_literal"s in this PR.

Copy link
Contributor

@askeksa askeksa left a comment

Choose a reason for hiding this comment

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

There was one literal left (the unique_id in transfer_and_smooth) that I think should be reverted. And then float_cmp and needless_range_loop added to the Clippy exceptions. Then it looks good. :)

examples/transfer_and_smooth.rs Outdated Show resolved Hide resolved
src/buffer.rs Outdated Show resolved Hide resolved
@askeksa
Copy link
Contributor

askeksa commented Nov 3, 2019

And yes, I do agree that it makes sense to turn the warnings on, with appropriate exceptions. I think we should have the three mentioned. Two of them because they are "causing us too much trouble for what it's worth" as you say, and one because it is buggy (which together with just one false positive warrants disabling, IMO).

@crsaracco
Copy link
Member Author

So just to be explicit, the three crate-wide ignored warnings are going to be (as of this PR):

  • clippy::unreadable_literal
  • clippy::needless_range_loop
  • clippy::float_cmp

Right?

@askeksa
Copy link
Contributor

askeksa commented Nov 3, 2019

Yes, exactly. Good idea to add a comment about the buggy needless_range_loop, btw.

@crsaracco crsaracco merged commit 37ced4b into master Nov 3, 2019
@crsaracco crsaracco deleted the clippy-ci branch November 3, 2019 17:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants