Skip to content

Commit

Permalink
Enable additional rustc and Clippy lints (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
edmorley authored Nov 20, 2023
1 parent 686f56a commit ad951d8
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ rust-version = "1.74"
autotests = false

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

[lints.clippy]
panic_in_result_fn = "warn"
pedantic = "warn"
unwrap_used = "warn"
# Prevent warnings caused by the large size of `ureq::Error` in error enums,
# where it is not worth boxing since the enum size doesn't affect performance.
large_enum_variant = "allow"
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
4 changes: 2 additions & 2 deletions src/layers/pip_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use std::path::Path;
/// Layer containing Pip's cache of HTTP requests/downloads and built package wheels.
pub(crate) struct PipCacheLayer<'a> {
/// The Python version used for this build.
pub python_version: &'a PythonVersion,
pub(crate) python_version: &'a PythonVersion,
/// The pip, setuptools and wheel versions used for this build.
pub packaging_tool_versions: &'a PackagingToolVersions,
pub(crate) packaging_tool_versions: &'a PackagingToolVersions,
}

impl Layer for PipCacheLayer<'_> {
Expand Down
4 changes: 2 additions & 2 deletions src/layers/pip_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use std::{fs, io};
/// Layer containing the application's Python dependencies, installed using Pip.
pub(crate) struct PipDependenciesLayer<'a> {
/// Environment variables inherited from earlier buildpack steps.
pub command_env: &'a Env,
pub(crate) command_env: &'a Env,
/// The path to the Pip cache directory, which is stored in another layer since it isn't needed at runtime.
pub pip_cache_dir: PathBuf,
pub(crate) pip_cache_dir: PathBuf,
}

impl Layer for PipDependenciesLayer<'_> {
Expand Down
6 changes: 3 additions & 3 deletions src/layers/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ use std::{fs, io};
/// - It matches what both local and official Docker image environments do.
pub(crate) struct PythonLayer<'a> {
/// Environment variables inherited from earlier buildpack steps.
pub command_env: &'a Env,
pub(crate) command_env: &'a Env,
/// The Python version that this layer should install.
pub python_version: &'a PythonVersion,
pub(crate) python_version: &'a PythonVersion,
/// The pip, setuptools and wheel versions that this layer should install.
pub packaging_tool_versions: &'a PackagingToolVersions,
pub(crate) packaging_tool_versions: &'a PackagingToolVersions,
}

impl Layer for PythonLayer<'_> {
Expand Down
6 changes: 3 additions & 3 deletions src/packaging_tool_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const WHEEL_REQUIREMENT: &str = include_str!("../requirements/wheel.txt");
/// semver, and we never introspect the version parts anyway.
#[derive(Clone, Deserialize, PartialEq, Serialize)]
pub(crate) struct PackagingToolVersions {
pub pip_version: String,
pub setuptools_version: String,
pub wheel_version: String,
pub(crate) pip_version: String,
pub(crate) setuptools_version: String,
pub(crate) wheel_version: String,
}

impl Default for PackagingToolVersions {
Expand Down
10 changes: 5 additions & 5 deletions src/python_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ pub(crate) const DEFAULT_PYTHON_VERSION: PythonVersion = PythonVersion {
/// Representation of a specific Python `X.Y.Z` version.
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct PythonVersion {
pub major: u16,
pub minor: u16,
pub patch: u16,
pub(crate) major: u16,
pub(crate) minor: u16,
pub(crate) patch: u16,
}

impl PythonVersion {
pub fn new(major: u16, minor: u16, patch: u16) -> Self {
pub(crate) fn new(major: u16, minor: u16, patch: u16) -> Self {
Self {
major,
minor,
patch,
}
}

pub fn url(&self, stack_id: &StackId) -> String {
pub(crate) fn url(&self, stack_id: &StackId) -> String {
// TODO: (W-11474658) Switch to tracking versions/URLs via a manifest file.
format!(
"https://heroku-buildpack-python.s3.us-east-1.amazonaws.com/{}/runtimes/python-{}.{}.{}.tar.gz",
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_txt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(crate) enum RuntimeTxtError {
/// Errors that can occur when parsing the contents of a `runtime.txt` file.
#[derive(Debug, PartialEq)]
pub(crate) struct ParseRuntimeTxtError {
pub cleaned_contents: String,
pub(crate) cleaned_contents: String,
}

#[cfg(test)]
Expand Down

0 comments on commit ad951d8

Please sign in to comment.