Skip to content

[ci] enable clippy #62

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

Merged
merged 2 commits into from
Nov 2, 2017
Merged

[ci] enable clippy #62

merged 2 commits into from
Nov 2, 2017

Conversation

gnzlbg
Copy link
Contributor

@gnzlbg gnzlbg commented Sep 28, 2017

Closes #110 .

@gnzlbg gnzlbg force-pushed the enable_clippy branch 3 times, most recently from 95ab8a0 to 5fabb5a Compare September 28, 2017 10:55
@BurntSushi
Copy link
Member

BurntSushi commented Sep 28, 2017

I'm not sure that I want this, primarily because it targets Rust's unstable plugin API and is therefore prone to breakage. Case in point, this PR is failing because Clippy doesn't compile. I personally will get pretty annoyed pretty quickly if we can't merge PRs because of this.

I also generally feel like most of the code in this crate is pretty simplistic, so the bang-to-buck ratio here isn't that great IMO.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Sep 28, 2017

I'm not sure that I want this, primarily because it targets Rust's unstable plugin API and is therefore prone to breakage. Case in point, this PR is failing because Clippy doesn't compile. I personally will get pretty annoyed pretty quickly if we can't merge PRs because of this.

Clippy is currently broken on nightly. I've added cargo clippy as the last test to be able to manually check if all other tests pass when clippy breaks. This should get better when clippy works with stable.

An alternative could be to add some extra builds to travis and appveyor to just run clippy. That way it is easy to see if clippy is broken, and we can still merge PRs.

I also generally feel like most of the code in this crate is pretty simplistic, so the bang-to-buck ratio here isn't that great IMO.

I've fixed some clippy errors locally but if I commit them would like to have somehow clippy enabled as a sanity test.

@alexcrichton
Copy link
Member

I'm personally not a huge fan and I feel like an "essentially auto generated" crate such as this probably won't benefit too much?

@gnzlbg gnzlbg force-pushed the enable_clippy branch 3 times, most recently from cb3b0a3 to 537ed6d Compare October 11, 2017 18:21
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 11, 2017

So I've fixed all the clippy warnings that I considered relevant, that is, some shifts by zero, a duplicated function in the runtime that felt through the code-review cracks, etc.

I've silenced all of the lints that do not apply to this library, but I've also silenced one lint that I cannot fix right now but we should probably improve on (missing_docs_in_private_items).

Now I hope that travis marks this as green and let me know what you think. IMO it did not found a lot of issues, but it found some beginner issues. I think that if this doesn't break CI all the time (I've put it in an allow_failure build) maybe we can just "try our bests" to keep it green.

@gnzlbg gnzlbg force-pushed the enable_clippy branch 3 times, most recently from 8156e7b to 7b83e03 Compare October 12, 2017 07:57
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 12, 2017

@BurntSushi and @alexcrichton so I've documented all missing items and enabled the clippy lint. IMO PR's for intrinsics should require documentation, clippy will complain if this isn't the case.

.travis.yml Outdated
@@ -16,9 +16,14 @@ matrix:
script: ci/run.sh
- install: true
script: ci/dox.sh

- env: CLIPPY=On TARGET=x86_64-unknown-linux-gnu NO_ADD=1
Copy link
Member

Choose a reason for hiding this comment

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

I think the CLIPPY env var isn't needed here?

Copy link
Member

Choose a reason for hiding this comment

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

Er nvmd, this is needed to distinguish it in allow_failures

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes that's right, I should add a comment, I did the same for the RUSTFMT=On variable, I just left it there so that one can tell the builds appart, maybe there is a better way to name the builds?

@alexcrichton
Copy link
Member

I'm personally not a huge fan of all the #[allow] directives, but otherwise seems fine to me!

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 12, 2017

@alexcrichton me neither, AFAIK there isn't a way to specify which lints are allowed in the clippy.toml file. Not all lints apply to all projects, and I'd rather have them in a clippy.toml than in the lib.rs. Maybe I should file a clippy issue.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 14, 2017

@llogiq any tips on how to set up clippy in CI ?

@llogiq
Copy link
Contributor

llogiq commented Oct 14, 2017

I assume you are on nightly already. So, you should be able to cargo install clippy -f && cargo clippy || true to allow failures (this means you'll need to look into the logs). You can deactivate lints via -A lint_name, but you need to precede cargo clippy's args with a double dash.

I personally don't think it makes much sense to even let a successful clippy run break the build at the moment. We are still adding more lints, so even when there is no breakage, every new clippy might uncover new warnings.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 14, 2017

An advantage of the allow_failure approach is that you immediately see in the build matrix if there is any issue with clippy, while doing it in the way @llogiq proposes we would need to look into the logs of green builds for that. In both cases the travis build remains green if clippy either introduces new lints or cannot build, so we can just try to keep it green on a best effort basis.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 26, 2017

@BurntSushi I will update this once the formatting commit is merged, hope we can merge this as well.

@gnzlbg gnzlbg force-pushed the enable_clippy branch 4 times, most recently from 104917d to abb71f9 Compare November 1, 2017 23:24
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Nov 2, 2017

@alexcrichton I've rebased this :)

@alexcrichton
Copy link
Member

Looks like CI may be failing?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Nov 2, 2017

@alexcrichton done!

@alexcrichton alexcrichton merged commit 1cbd309 into rust-lang:master Nov 2, 2017
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.

4 participants