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 Rust and Clippy lints #19

Merged
merged 5 commits into from
Apr 29, 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
2 changes: 1 addition & 1 deletion benches/write_allowed_signers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chrono::{Local, TimeZone};
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};
use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion};
use hanko::{AllowedSigner, AllowedSignersFile};

pub fn criterion_benchmark(c: &mut Criterion) {
Expand Down
9 changes: 4 additions & 5 deletions src/allowed_signers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Types and functions to interact with the OpenSSH `allowed_signers` file.
//!
//! # File format
//! https://man.openbsd.org/ssh-keygen.1#ALLOWED_SIGNERS
//! [File Format Documentation](https://man.openbsd.org/ssh-keygen.1#ALLOWED_SIGNERS)
use crate::SshPublicKey;
use chrono::{DateTime, Local};
use std::{
Expand Down Expand Up @@ -81,7 +80,7 @@ impl AllowedSignersFile {
pub fn write(&mut self) -> io::Result<()> {
let mut file_buf = io::BufWriter::new(&mut self.file);
for signer in &self.signers {
writeln!(file_buf, "{}", signer)?;
writeln!(file_buf, "{signer}")?;
}
writeln!(file_buf)?;
Ok(())
Expand Down Expand Up @@ -158,7 +157,7 @@ mod tests {
let path = tempfile::NamedTempFile::new().unwrap().into_temp_path();
let mut expected_content = String::new();
for signer in &example_signers {
expected_content.push_str(&format!("{}\n", signer));
expected_content.push_str(&format!("{signer}\n"));
}
expected_content.push('\n');

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

{
Expand Down
6 changes: 3 additions & 3 deletions src/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ fn default_config_path() -> Resettable<OsStr> {
let filename = "config.toml";

if let Ok(xdg_config_home) = env::var("XDG_CONFIG_HOME") {
Resettable::Value(format!("{}/{}/{}", xdg_config_home, dirname, filename).into())
Resettable::Value(format!("{xdg_config_home}/{dirname}/{filename}").into())
} else if let Ok(home) = env::var("HOME") {
Resettable::Value(format!("{}/.config/{}/{}", home, dirname, filename).into())
Resettable::Value(format!("{home}/.config/{dirname}/{filename}").into())
} else {
Resettable::Reset
}
Expand All @@ -83,6 +83,6 @@ mod tests {
#[test]
fn verify_cli() {
use clap::CommandFactory;
Cli::command().debug_assert()
Cli::command().debug_assert();
}
}
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#![warn(clippy::pedantic)]
#![warn(clippy::panic)]
#![forbid(unsafe_code)]

pub use allowed_signers::{AllowedSigner, AllowedSignersFile};
pub use config::Config;
pub use core::*;
Expand Down
3 changes: 1 addition & 2 deletions src/provider/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ impl Github {

/// Get the signing keys of a user by their username.
///
/// # API documentation
/// https://docs.github.com/en/rest/users/ssh-signing-keys?apiVersion=2022-11-28#list-ssh-signing-keys-for-a-user
/// [API documentation](https://docs.github.com/en/rest/users/ssh-signing-keys?apiVersion=2022-11-28#list-ssh-signing-keys-for-a-user)
pub async fn get_keys_by_username(
&self,
username: &str,
Expand Down
3 changes: 1 addition & 2 deletions src/provider/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ impl Gitlab {

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