1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 06:45:13 +01:00

build: Use workspace global lints

In relatively recent rust there's a nice way to globally
configure clippy lints for the whole workspace. We can
kill the `custom-lints` target because relatively
recently clippy has a lint for `todo!` and `dbg!` itself.

Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
Colin Walters
2024-07-17 13:31:07 -04:00
parent 298a3365b0
commit 63bcf63868
9 changed files with 23 additions and 24 deletions

View File

@@ -41,8 +41,6 @@ jobs:
run: cd lib && cargo check --no-default-features
- name: Individual checks
run: (cd cli && cargo check) && (cd lib && cargo check)
- name: Lints
run: cargo xtask custom-lints
- name: Run tests
run: cargo test -- --nocapture --quiet
- name: Manpage generation

View File

@@ -47,3 +47,14 @@ exclude-crate-paths = [ { name = "libz-sys", exclude = "src/zlib" },
{ name = "k8s-openapi", exclude = "src/v1_25" },
{ name = "k8s-openapi", exclude = "src/v1_27" },
]
[workspace.lints.rust]
# Require an extra opt-in for unsafe
unsafe_code = "deny"
# Absolutely must handle errors
unused_must_use = "forbid"
[workspace.lints.clippy]
# These should only be in local code
dbg_macro = "deny"
todo = "deny"

View File

@@ -24,3 +24,6 @@ tokio = { workspace = true, features = ["macros"] }
log = "0.4.21"
tracing = { workspace = true }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
[lints]
workspace = true

View File

@@ -1,7 +1,3 @@
// Good defaults
#![forbid(unused_must_use)]
#![deny(unsafe_code)]
use anyhow::Result;
async fn run() -> Result<()> {

View File

@@ -58,3 +58,5 @@ install = []
# Implementation detail of man page generation.
docgen = ["clap_mangen"]
[lints]
workspace = true

View File

@@ -7,11 +7,7 @@
// See https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![forbid(unused_must_use)]
#![deny(unsafe_code)]
#![cfg_attr(feature = "dox", feature(doc_cfg))]
#![deny(clippy::dbg_macro)]
#![deny(clippy::todo)]
// These two are in my experience the lints which are most likely
// to trigger, and among the least valuable to fix.
#![allow(clippy::needless_borrow)]

View File

@@ -24,3 +24,6 @@ serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
tempfile = { workspace = true }
xshell = { version = "0.2.6" }
[lints]
workspace = true

View File

@@ -19,3 +19,6 @@ fn-error-context = { workspace = true }
tempfile = { workspace = true }
mandown = "0.1.3"
xshell = { version = "0.2.6" }
[lints]
workspace = true

View File

@@ -1,5 +1,5 @@
use std::fs::File;
use std::io::{BufRead, BufReader, BufWriter, Cursor, Write};
use std::io::{BufRead, BufReader, BufWriter, Write};
use std::process::{Command, Stdio};
use anyhow::{anyhow, Context, Result};
@@ -23,7 +23,6 @@ const TASKS: &[(&str, fn(&Shell) -> Result<()>)] = &[
("package", package),
("package-srpm", package_srpm),
("spec", spec),
("custom-lints", custom_lints),
("test-tmt", test_tmt),
];
@@ -356,18 +355,6 @@ fn package_srpm(sh: &Shell) -> Result<()> {
Ok(())
}
fn custom_lints(sh: &Shell) -> Result<()> {
// Verify there are no invocations of the dbg macro.
let o = cmd!(sh, "git grep dbg\x21 *.rs").ignore_status().read()?;
if !o.is_empty() {
let mut stderr = std::io::stderr().lock();
std::io::copy(&mut Cursor::new(o.as_bytes()), &mut stderr)?;
eprintln!();
anyhow::bail!("Found dbg\x21 macro");
}
Ok(())
}
fn print_help(_sh: &Shell) -> Result<()> {
println!("Tasks:");
for (name, _) in TASKS {