Skip to content

Commit 89ebff3

Browse files
authored
Enable Rust and Clippy lints (#19)
* Enable lints * Fix URL lint * Fix consistent formatting lint * Fix variables can be used directly lint * Remove unused import
1 parent 7956fc9 commit 89ebff3

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

benches/write_allowed_signers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use chrono::{Local, TimeZone};
2-
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};
2+
use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion};
33
use hanko::{AllowedSigner, AllowedSignersFile};
44

55
pub fn criterion_benchmark(c: &mut Criterion) {

src/allowed_signers.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Types and functions to interact with the OpenSSH `allowed_signers` file.
22
//!
3-
//! # File format
4-
//! https://man.openbsd.org/ssh-keygen.1#ALLOWED_SIGNERS
3+
//! [File Format Documentation](https://man.openbsd.org/ssh-keygen.1#ALLOWED_SIGNERS)
54
use crate::SshPublicKey;
65
use chrono::{DateTime, Local};
76
use std::{
@@ -81,7 +80,7 @@ impl AllowedSignersFile {
8180
pub fn write(&mut self) -> io::Result<()> {
8281
let mut file_buf = io::BufWriter::new(&mut self.file);
8382
for signer in &self.signers {
84-
writeln!(file_buf, "{}", signer)?;
83+
writeln!(file_buf, "{signer}")?;
8584
}
8685
writeln!(file_buf)?;
8786
Ok(())
@@ -158,7 +157,7 @@ mod tests {
158157
let path = tempfile::NamedTempFile::new().unwrap().into_temp_path();
159158
let mut expected_content = String::new();
160159
for signer in &example_signers {
161-
expected_content.push_str(&format!("{}\n", signer));
160+
expected_content.push_str(&format!("{signer}\n"));
162161
}
163162
expected_content.push('\n');
164163

@@ -175,7 +174,7 @@ mod tests {
175174
fn writing_overrides_existing_content(example_signers: Vec<AllowedSigner>) {
176175
let existing_content = "gathered dust";
177176
let mut existing_file = tempfile::NamedTempFile::new().unwrap();
178-
writeln!(existing_file, "{}", existing_content).unwrap();
177+
writeln!(existing_file, "{existing_content}").unwrap();
179178
let path = existing_file.into_temp_path();
180179

181180
{

src/cli/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ fn default_config_path() -> Resettable<OsStr> {
6262
let filename = "config.toml";
6363

6464
if let Ok(xdg_config_home) = env::var("XDG_CONFIG_HOME") {
65-
Resettable::Value(format!("{}/{}/{}", xdg_config_home, dirname, filename).into())
65+
Resettable::Value(format!("{xdg_config_home}/{dirname}/{filename}").into())
6666
} else if let Ok(home) = env::var("HOME") {
67-
Resettable::Value(format!("{}/.config/{}/{}", home, dirname, filename).into())
67+
Resettable::Value(format!("{home}/.config/{dirname}/{filename}").into())
6868
} else {
6969
Resettable::Reset
7070
}
@@ -83,6 +83,6 @@ mod tests {
8383
#[test]
8484
fn verify_cli() {
8585
use clap::CommandFactory;
86-
Cli::command().debug_assert()
86+
Cli::command().debug_assert();
8787
}
8888
}

src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#![warn(clippy::pedantic)]
2+
#![warn(clippy::panic)]
3+
#![forbid(unsafe_code)]
4+
15
pub use allowed_signers::{AllowedSigner, AllowedSignersFile};
26
pub use config::Config;
37
pub use core::*;

src/provider/github.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ impl Github {
1717

1818
/// Get the signing keys of a user by their username.
1919
///
20-
/// # API documentation
21-
/// https://docs.github.com/en/rest/users/ssh-signing-keys?apiVersion=2022-11-28#list-ssh-signing-keys-for-a-user
20+
/// [API documentation](https://docs.github.com/en/rest/users/ssh-signing-keys?apiVersion=2022-11-28#list-ssh-signing-keys-for-a-user)
2221
pub async fn get_keys_by_username(
2322
&self,
2423
username: &str,

src/provider/gitlab.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ impl Gitlab {
1818

1919
/// Get the signing keys of a user by their username.
2020
///
21-
/// # API documentation
22-
/// https://docs.gitlab.com/16.10/ee/api/users.html#list-ssh-keys-for-user
21+
/// [API Documentation](https://docs.gitlab.com/16.10/ee/api/users.html#list-ssh-keys-for-user)
2322
pub async fn get_keys_by_username(
2423
&self,
2524
username: &str,

0 commit comments

Comments
 (0)