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

Enable and fix a lot more Clippy warnings. #2

Merged
merged 7 commits into from
Apr 3, 2024
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
5 changes: 0 additions & 5 deletions .envrc.local

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# direnv
/.direnv
/.envrc.local

# testing
/tmp/empty
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ package.license = "Apache-2.0"
members = [
"crates/*",
]

[workspace.lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
# disable certain pedantic warnings
doc_markdown = { level = "allow" }
missing_errors_doc = { level = "allow" }
missing_panics_doc = { level = "allow" }
module_name_repetitions = { level = "allow" }
must_use_candidate = { level = "allow" }
wildcard_imports = { level = "allow" }
3 changes: 3 additions & 0 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version.workspace = true
edition.workspace = true
license.workspace = true

[lints]
workspace = true

[lib]
name = "ndc_sdk"
path = "src/lib.rs"
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub async fn main() -> ExitCode {
match default_main::<Example>().await {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
eprintln!("{}", err);
eprintln!("{err}");
ExitCode::FAILURE
}
}
Expand Down
7 changes: 3 additions & 4 deletions crates/sdk/src/check_health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ pub enum HealthCheckError {
impl std::fmt::Display for HealthCheckError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
HealthCheckError::ParseError(inner) => write!(f, "URL parse error: {}", inner),
HealthCheckError::RequestError(inner) => write!(f, "request error: {}", inner),
HealthCheckError::ParseError(inner) => write!(f, "URL parse error: {inner}"),
HealthCheckError::RequestError(inner) => write!(f, "request error: {inner}"),
HealthCheckError::UnsuccessfulResponse { status, body } => {
write!(
f,
"unsuccessful response with status code: {}\nbody:\n{}",
status, body
"unsuccessful response with status code: {status}\nbody:\n{body}"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Display for InvalidNode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}, at ", self.file_path.display())?;
for segment in &self.node_path {
write!(f, ".{}", segment)?;
write!(f, ".{segment}")?;
}
write!(f, ": {}", self.message)?;
Ok(())
Expand Down
12 changes: 6 additions & 6 deletions crates/sdk/src/default_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ where
);

let address = net::SocketAddr::new(serve_command.host, serve_command.port);
println!("Starting server on {}", address);
println!("Starting server on {address}");
axum::Server::bind(&address)
.serve(router.into_make_service())
.with_graceful_shutdown(async {
// wait for a SIGINT, i.e. a Ctrl+C from the keyboard
let sigint = async {
tokio::signal::ctrl_c()
.await
.expect("unable to install signal handler")
.expect("unable to install signal handler");
};
// wait for a SIGTERM, i.e. a normal `kill` command
#[cfg(unix)]
Expand All @@ -263,7 +263,7 @@ where
// block until either of the above happens
#[cfg(unix)]
tokio::select! {
_ = sigint => (),
() = sigint => (),
_ = sigterm => (),
}
#[cfg(windows)]
Expand Down Expand Up @@ -316,14 +316,14 @@ where
name = "Request failure",
body = %err,
error = true,
)
);
}),
)
.with_state(state);

let expected_auth_header: Option<HeaderValue> =
service_token_secret.and_then(|service_token_secret| {
let expected_bearer = format!("Bearer {}", service_token_secret);
let expected_bearer = format!("Bearer {service_token_secret}");
HeaderValue::from_str(&expected_bearer).ok()
});

Expand Down Expand Up @@ -371,7 +371,7 @@ where
async fn get_metrics<C: Connector>(
State(state): State<ServerState<C>>,
) -> Result<String, (StatusCode, Json<ErrorResponse>)> {
routes::get_metrics::<C>(&state.configuration, &state.state, state.metrics)
routes::get_metrics::<C>(&state.configuration, &state.state, &state.metrics)
}

async fn get_capabilities<C: Connector>() -> JsonResponse<CapabilitiesResponse> {
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
pub fn get_metrics<C: Connector>(
configuration: &C::Configuration,
state: &C::State,
metrics: Registry,
metrics: &Registry,
) -> Result<String, (StatusCode, Json<models::ErrorResponse>)> {
let encoder = TextEncoder::new();

Expand Down
Loading