Skip to content

Commit

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

[lints.rust]
unreachable_pub = "warn"
unsafe_code = "warn"
# TODO: Enable this lint once the lib target is split out to a shared code crate,
# which will reduce the false positives and make using this lint viable.
# unused_crate_dependencies = "warn"

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

[dependencies]
flate2 = { version = "1", default-features = false, features = ["zlib"] }
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/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::path;

/// Represents buildpack configuration found in a project's `go.mod`.
pub(crate) struct GoModConfig {
pub packages: Option<Vec<String>>,
pub version: Option<Requirement>,
pub(crate) packages: Option<Vec<String>>,
pub(crate) version: Option<Requirement>,
}

#[derive(thiserror::Error, Debug)]
Expand Down
11 changes: 5 additions & 6 deletions src/inv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use serde::{Deserialize, Serialize};
use std::fs;
use toml;

pub const GITHUB_API_URL: &str = "https://api.github.com";
pub const GO_REPO_NAME: &str = "golang/go";
pub const GO_HOST_URL: &str = "https://dl.google.com/go";
pub const GO_MIRROR_URL: &str = "https://heroku-golang-prod.s3.us-east-1.amazonaws.com";
pub const REGION: &str = "us-east-1";
pub const ARCH: &str = "linux-amd64";
const GITHUB_API_URL: &str = "https://api.github.com";
const GO_REPO_NAME: &str = "golang/go";
const GO_HOST_URL: &str = "https://dl.google.com/go";
const GO_MIRROR_URL: &str = "https://heroku-golang-prod.s3.us-east-1.amazonaws.com";
const ARCH: &str = "linux-amd64";

/// Represents a collection of known go release artifacts.
#[derive(Debug, Deserialize, Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/layers/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::Path;

/// A layer for go incremental build cache artifacts
pub(crate) struct BuildLayer {
pub go_version: String,
pub(crate) go_version: String,
}

#[derive(Deserialize, Serialize, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion src/layers/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::Path;

/// A layer that downloads and installs the Go distribution artifacts
pub(crate) struct DistLayer {
pub artifact: Artifact,
pub(crate) artifact: Artifact,
}

#[derive(Deserialize, Serialize, Clone, PartialEq, Eq)]
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::path::Path;

const INVENTORY: &str = include_str!("../inventory.toml");

pub(crate) struct GoBuildpack;
struct GoBuildpack;

impl Buildpack for GoBuildpack {
type Platform = GenericPlatform;
Expand Down Expand Up @@ -168,7 +168,7 @@ impl Buildpack for GoBuildpack {
}

#[derive(thiserror::Error, Debug)]
pub(crate) enum GoBuildpackError {
enum GoBuildpackError {
#[error("{0}")]
BuildLayer(#[from] BuildLayerError),
#[error("Couldn't run `go build`: {0}")]
Expand Down
4 changes: 2 additions & 2 deletions src/tgz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ struct DigestingReader<R: Read, H: sha2::Digest> {
}

impl<R: Read, H: sha2::Digest> DigestingReader<R, H> {
pub fn new(reader: R, hasher: H) -> DigestingReader<R, H> {
pub(crate) fn new(reader: R, hasher: H) -> DigestingReader<R, H> {
DigestingReader {
r: reader,
h: hasher,
}
}
pub fn finalize(self) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize> {
pub(crate) fn finalize(self) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize> {
self.h.finalize()
}
}
Expand Down

0 comments on commit 68be47f

Please sign in to comment.