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

Consolidate standard lints into a cargo config file #3386

Merged
merged 4 commits into from
Jan 24, 2022

Conversation

teor2345
Copy link
Contributor

Motivation

In PR #3332, we added a Rust 2021 lint to Zebra's library crates. But we forgot to lint acceptance tests, examples, build scripts, and binaries. (These are technically separate crates.)

It would be much easier if we just had all of Zebra's standard lints in one place.

Specifications

We use cargo's hierarchical config structure to apply the lints to every crate:
https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure

This is similar to Embark Studio's lint configuration:
EmbarkStudios/rust-ecosystem#59
https://github.com/EmbarkStudios/rust-ecosystem/blob/main/lints.toml

Solution

  • move Zebra's standard lints to zebra/.cargo/config.toml
  • fix up some minor issues detected by the new lints
  • add some future incompatibility lints related to Rust 2021
  • ignore a lint that was just added in nightly and beta Rust

Review

@dconnolly or anyone else can review this PR.

It should be merged before #3377 by @gustavovalverde, because it changes the paths that are used for lint CI.

Reviewer Checklist

  • CI passes
  • Lint changes make sense

Follow Up Work

Add more lints over time.

@teor2345 teor2345 added A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup P-Low ❄️ A-diagnostics Area: Diagnosing issues or monitoring performance labels Jan 24, 2022
@teor2345 teor2345 self-assigned this Jan 24, 2022
@codecov
Copy link

codecov bot commented Jan 24, 2022

Codecov Report

Merging #3386 (6b201ce) into main (ebd94b2) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #3386   +/-   ##
=======================================
  Coverage   78.35%   78.36%           
=======================================
  Files         267      267           
  Lines       31523    31523           
=======================================
+ Hits        24701    24702    +1     
+ Misses       6822     6821    -1     

Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

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

It seemed weird that clippy reads arguments from rustflags, but it does work

@mergify mergify bot merged commit 00aa5d9 into main Jan 24, 2022
@mergify mergify bot deleted the consolidate-standard-lints branch January 24, 2022 16:25
gustavovalverde added a commit that referenced this pull request Jan 24, 2022
gustavovalverde added a commit that referenced this pull request Jan 25, 2022
* Segregate linting jobs from CI workflow

Lint on push to all branches, except for main, as this action will be required to merge.

Just run the lint action when a Rust file is changed, as it won't make sense to run it on other scenarios.

DRY with uneeded jobs

* Make actions dependable on changed files or folders

* Fix & add missing paths

* Revert changes removing cargo.lock and deny.toml checks

Also refactor this to use a more redable and change prone cargo-deny-action. And move this actions out of the clippy-deps job, as this are more related to CI than linting.

* Fix wrong indentation

* Add new configuration file from #3386

* Do not fail on licenses as this configuration is missing

* Do not add advisories features

Add advisories checks in a different PR

* Allow tests and coverage on PR series

If we only run CI on branches that are going to merge to main, then PR series become a lot harder to test. (Because each PR is based on the previous PR, not main.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Diagnosing issues or monitoring performance A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants