Skip to content

Commit

Permalink
Enable nursery lints
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Oct 16, 2024
1 parent 1bbd899 commit c20d0eb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct PortAllocator {
impl PortAllocator {
// Create a new port allocator that allocates from the provided available ports
pub fn new(available_ports: impl Iterator<Item = u16>) -> Self {
PortAllocator {
Self {
available_ports: available_ports.collect(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/caddy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub fn reload(
deps.exec(
std::process::Command::new("caddy")
.args(["reload", "--adapter", "caddyfile", "--config"])
.arg(caddyfile_path.clone()),
.arg(caddyfile_path),
)
.map_err(CaddyError::Exec)?;

Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Config {

// Return a new configuration from a TOML string
fn from_toml(toml_str: &str) -> anyhow::Result<Self> {
let config: Config = toml::from_str(toml_str)?;
let config: Self = toml::from_str(toml_str)?;

if config.ranges.is_empty() {
bail!("Validation error: port ranges must not be empty\n")
Expand Down
18 changes: 10 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![warn(clippy::pedantic)]
#![warn(clippy::pedantic, clippy::nursery)]
#![allow(clippy::module_name_repetitions)]

mod allocator;
Expand Down Expand Up @@ -205,13 +205,15 @@ fn run(
extended,
} => {
let registry = load_registry(deps)?;
let (name, project) = match project_name {
Some(ref name) => registry
.get(name)
.map(|project| (name, project))
.ok_or_else(|| ApplicationError::NonExistentProject(name.clone())),
None => get_active_project(deps, &registry),
}?;
let (name, project) = project_name.as_ref().map_or_else(
|| get_active_project(deps, &registry),
|name| {
registry
.get(name)
.map(|project| (name, project))
.ok_or_else(|| ApplicationError::NonExistentProject(name.clone()))
},
)?;
if extended {
let directory = project
.directory
Expand Down
5 changes: 2 additions & 3 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::collections::{BTreeMap, HashSet};
use std::path::PathBuf;

#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[cfg_attr(test, derive(Debug, Eq, PartialEq))]
pub struct Project {
pub port: u16,
pub directory: Option<PathBuf>,
Expand Down Expand Up @@ -339,8 +339,7 @@ impl Registry {
result.push(char.to_ascii_lowercase());
}
result
})
.to_string();
});
normalized.truncate(63);
if normalized.ends_with('-') {
normalized.pop();
Expand Down

0 comments on commit c20d0eb

Please sign in to comment.