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

Switch to Cargo.toml based lint configuration #239

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
[workspace]
resolver = "2"
members = ["buildpacks/ruby", "commons"]

[workspace.package]
edition = "2021"
rust-version = "1.74"

[workspace.lints.rust]
unused_crate_dependencies = "warn"

[workspace.lints.clippy]
pedantic = "warn"
module_name_repetitions = "allow"
7 changes: 5 additions & 2 deletions buildpacks/ruby/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name = "heroku-ruby-buildpack"
# This crate is not published, so the only version that is used is the one in buildpack.toml.
version = "0.0.0"
publish = false
edition = "2021"
rust-version = "1.66"
edition.workspace = true
rust-version.workspace = true

[lints]
workspace = true

[dependencies]
commons = { path = "../../commons" }
Expand Down
5 changes: 2 additions & 3 deletions buildpacks/ruby/src/bin/agentmon_loop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Enable Clippy lints that are disabled by default.
// https://rust-lang.github.io/rust-clippy/stable/index.html
#![warn(clippy::pedantic)]
// Required due to: https://github.com/rust-lang/rust/issues/95513
#![allow(unused_crate_dependencies)]

use clap::Parser;
use std::ffi::OsStr;
Expand Down
7 changes: 5 additions & 2 deletions buildpacks/ruby/src/bin/launch_daemon.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Required due to: https://github.com/rust-lang/rust/issues/95513
#![allow(unused_crate_dependencies)]

use clap::Parser;
use std::path::PathBuf;
use std::process::exit;
Expand Down Expand Up @@ -75,7 +78,7 @@ fn main() {
eprintln!(
"Could not write to log file {}. Reason: {error}",
log.display()
)
);
});

command.args(["--output", &log.to_string_lossy()]);
Expand All @@ -88,7 +91,7 @@ fn main() {
eprintln!(
"Could not write to log file {}. Reason: {error}",
log.display()
)
);
});
}

Expand Down
3 changes: 0 additions & 3 deletions buildpacks/ruby/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![warn(unused_crate_dependencies)]
#![warn(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
use commons::cache::CacheError;
use commons::gemfile_lock::GemfileLock;
use commons::metadata_digest::MetadataDigest;
Expand Down
3 changes: 2 additions & 1 deletion buildpacks/ruby/tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::pedantic)]
// Required due to: https://github.com/rust-lang/rust/issues/95513
#![allow(unused_crate_dependencies)]

use libcnb_test::{
assert_contains, assert_empty, BuildConfig, BuildpackReference, ContainerConfig,
Expand Down
6 changes: 5 additions & 1 deletion commons/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[package]
name = "commons"
version = "1.0.0"
edition = "2021"
publish = false
edition.workspace = true
rust-version.workspace = true

[[bin]]
name = "print_style_guide"
path = "bin/print_style_guide.rs"

[lints]
workspace = true

[dependencies]
byte-unit = "4"
fancy-regex = "0.12"
Expand Down
5 changes: 5 additions & 0 deletions commons/bin/print_style_guide.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Required due to: https://github.com/rust-lang/rust/issues/95513
#![allow(unused_crate_dependencies)]

use ascii_table::AsciiTable;
use commons::output::fmt::{self, DEBUG_INFO, HELP};
#[allow(clippy::wildcard_imports)]
use commons::output::{
build_log::*,
section_log::{log_step, log_step_stream, log_step_timed},
Expand All @@ -9,6 +13,7 @@ use indoc::formatdoc;
use std::io::stdout;
use std::process::Command;

#[allow(clippy::too_many_lines)]
fn main() {
println!(
"{}",
Expand Down
1 change: 0 additions & 1 deletion commons/src/cache.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(clippy::module_name_repetitions)]
mod app_cache;
mod app_cache_collection;
mod clean;
Expand Down
1 change: 0 additions & 1 deletion commons/src/cache/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use byte_unit::{n_mib_bytes, Byte};
use std::path::PathBuf;

/// Configure behavior of a cached path
#[allow(clippy::module_name_repetitions)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CacheConfig {
/// Path to the directory you want to cache
Expand Down
1 change: 0 additions & 1 deletion commons/src/cache/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::path::PathBuf;

#[allow(clippy::module_name_repetitions)]
#[derive(thiserror::Error, Debug)]
pub enum CacheError {
#[error("Cached path not in application directory: {0}")]
Expand Down
1 change: 0 additions & 1 deletion commons/src/layer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(clippy::module_name_repetitions)]
mod configure_env_layer;
mod default_env_layer;

Expand Down
3 changes: 0 additions & 3 deletions commons/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![warn(unused_crate_dependencies)]
#![warn(clippy::pedantic)]

// Used in both testing and printing the style guide
use indoc as _;

Expand Down
1 change: 0 additions & 1 deletion commons/src/output/build_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use std::time::{Duration, Instant};
///
/// For usage details run `cargo run --bin print_style_guide`

#[allow(clippy::module_name_repetitions)]
#[derive(Debug)]
pub struct BuildLog<T, W: Debug> {
pub(crate) io: W,
Expand Down
1 change: 0 additions & 1 deletion commons/src/output/warn_later.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ fn take() -> Option<Vec<String>> {
WARN_LATER.with(|cell| cell.replace(None))
}

#[allow(clippy::module_name_repetitions)]
#[derive(Debug)]
pub enum WarnLaterError {
MissingGuardForThread(ThreadId),
Expand Down