Skip to content

Commit

Permalink
Enable additional rustc and Clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
edmorley committed Nov 20, 2023
1 parent 1c5e136 commit c36b597
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ edition = "2021"
rust-version = "1.74"

[lints.rust]
unreachable_pub = "warn"
unsafe_code = "warn"
unused_crate_dependencies = "warn"

[lints.clippy]
panic_in_result_fn = "warn"
pedantic = "warn"
unwrap_used = "warn"

[dependencies]
indoc = "2"
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allow-unwrap-in-tests = true
10 changes: 2 additions & 8 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ use indoc::formatdoc;
use libherokubuildpack::log::log_error;

#[derive(Debug)]
// This allow can be removed once the visibility of this enum is fixed,
// since the lint only applies to public APIs.
#[allow(clippy::module_name_repetitions)]
pub enum ProcfileBuildpackError {
pub(crate) enum ProcfileBuildpackError {
CannotReadProcfileContents(std::io::Error),
ProcfileParsingError(ProcfileParsingError),
ProcfileConversionError(ProcfileConversionError),
}

// This allow can be removed once the visibility of this enum is fixed,
// since the lint only applies to public APIs.
#[allow(clippy::module_name_repetitions)]
pub fn error_handler(buildpack_error: ProcfileBuildpackError) {
pub(crate) fn error_handler(buildpack_error: ProcfileBuildpackError) {
match buildpack_error {
ProcfileBuildpackError::CannotReadProcfileContents(io_error) => {
log_error(
Expand Down
2 changes: 1 addition & 1 deletion src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl TryFrom<Procfile> for Launch {
}

#[derive(Debug)]
pub enum ProcfileConversionError {
pub(crate) enum ProcfileConversionError {
InvalidProcessType(libcnb::data::launch::ProcessTypeError),
}

Expand Down
16 changes: 7 additions & 9 deletions src/procfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ use regex::Regex;
use std::str::FromStr;

#[derive(Debug, Eq, PartialEq)]
pub struct Procfile {
pub processes: LinkedHashMap<String, String>,
pub(crate) struct Procfile {
pub(crate) processes: LinkedHashMap<String, String>,
}

impl Procfile {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
Procfile {
processes: LinkedHashMap::new(),
}
}

pub fn is_empty(&self) -> bool {
pub(crate) fn is_empty(&self) -> bool {
self.processes.is_empty()
}

pub fn insert(&mut self, k: impl Into<String>, v: impl Into<String>) {
#[cfg(test)]
pub(crate) fn insert(&mut self, k: impl Into<String>, v: impl Into<String>) {
self.processes.insert(k.into(), v.into());
}
}
Expand Down Expand Up @@ -64,10 +65,7 @@ impl FromStr for Procfile {
// There are currently no ways in which parsing can fail, however we will add some in the future:
// https://github.com/heroku/procfile-cnb/issues/73
#[derive(Debug, Eq, PartialEq)]
// This allow can be removed once the visibility of this enum is fixed,
// since the lint only applies to public APIs.
#[allow(clippy::module_name_repetitions)]
pub enum ProcfileParsingError {}
pub(crate) enum ProcfileParsingError {}

#[cfg(test)]
mod tests {
Expand Down

0 comments on commit c36b597

Please sign in to comment.