From 9016ec0aa5d055f5c83446b9bd8725db80dc3bd3 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:45:12 +0000 Subject: [PATCH] fix lints --- src/nixpacks/environment.rs | 6 ++---- src/providers/clojure.rs | 2 +- src/providers/cobol.rs | 2 +- src/providers/crystal.rs | 2 +- src/providers/csharp.rs | 2 +- src/providers/dart.rs | 2 +- src/providers/deno.rs | 2 +- src/providers/elixir.rs | 2 +- src/providers/fsharp.rs | 2 +- src/providers/gleam/mod.rs | 2 +- src/providers/go.rs | 2 +- src/providers/haskell.rs | 2 +- src/providers/java.rs | 2 +- src/providers/lunatic.rs | 2 +- src/providers/node/mod.rs | 2 +- src/providers/node/spa/vite.rs | 5 +---- src/providers/php/mod.rs | 2 +- src/providers/procfile.rs | 2 +- src/providers/python.rs | 2 +- src/providers/ruby.rs | 2 +- src/providers/rust.rs | 2 +- src/providers/scala.rs | 2 +- src/providers/scheme.rs | 2 +- src/providers/staticfile.rs | 2 +- src/providers/swift.rs | 2 +- src/providers/zig.rs | 2 +- 26 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/nixpacks/environment.rs b/src/nixpacks/environment.rs index afd71c2bb..ee2b7f2a3 100644 --- a/src/nixpacks/environment.rs +++ b/src/nixpacks/environment.rs @@ -18,11 +18,9 @@ impl Environment { /// Collects all variables from the calling environment. pub fn from_envs(envs: Vec<&str>) -> Result { let mut environment = Environment::default(); + let r = Regex::new(r"([A-Za-z0-9_-]*)(?:=?)([\s\S]*)").unwrap(); for env in envs { - let matches = Regex::new(r"([A-Za-z0-9_-]*)(?:=?)([\s\S]*)") - .unwrap() - .captures(env) - .unwrap(); + let matches = r.captures(env).unwrap(); if matches.get(2).unwrap().as_str() == "" { // No value, pull from the current environment let name = matches.get(1).unwrap().as_str(); diff --git a/src/providers/clojure.rs b/src/providers/clojure.rs index 9e4283163..a0e78b579 100644 --- a/src/providers/clojure.rs +++ b/src/providers/clojure.rs @@ -16,7 +16,7 @@ const DEFAULT_JDK_PKG_NAME: &str = "jdk8"; pub struct ClojureProvider {} impl Provider for ClojureProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "clojure" } diff --git a/src/providers/cobol.rs b/src/providers/cobol.rs index ce78ff3c4..143905a9c 100644 --- a/src/providers/cobol.rs +++ b/src/providers/cobol.rs @@ -20,7 +20,7 @@ const DEFAULT_COBOL_COMPILE_ARGS: &str = "-x -o"; pub struct CobolProvider {} impl Provider for CobolProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "cobol" } diff --git a/src/providers/crystal.rs b/src/providers/crystal.rs index a2591f0c2..4c44d42a6 100644 --- a/src/providers/crystal.rs +++ b/src/providers/crystal.rs @@ -23,7 +23,7 @@ pub struct ShardYaml { pub struct CrystalProvider {} impl Provider for CrystalProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "crystal" } diff --git a/src/providers/csharp.rs b/src/providers/csharp.rs index 505f6cb45..1c972a96d 100644 --- a/src/providers/csharp.rs +++ b/src/providers/csharp.rs @@ -26,7 +26,7 @@ pub struct CSharpProvider {} pub const ARTIFACT_DIR: &str = "out"; impl Provider for CSharpProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "c#" } diff --git a/src/providers/dart.rs b/src/providers/dart.rs index 535a83c75..cfa38c4cb 100644 --- a/src/providers/dart.rs +++ b/src/providers/dart.rs @@ -22,7 +22,7 @@ pub struct DartPubspec { pub struct DartProvider {} impl Provider for DartProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "dart" } diff --git a/src/providers/deno.rs b/src/providers/deno.rs index 3deef7bee..cc6659c43 100644 --- a/src/providers/deno.rs +++ b/src/providers/deno.rs @@ -28,7 +28,7 @@ pub struct DenoJson { pub struct DenoProvider {} impl Provider for DenoProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "deno" } diff --git a/src/providers/elixir.rs b/src/providers/elixir.rs index ab6a0fa94..d5d863465 100644 --- a/src/providers/elixir.rs +++ b/src/providers/elixir.rs @@ -16,7 +16,7 @@ const ELIXIR_NIXPKGS_ARCHIVE: &str = "c5702bd28cbde41a191a9c2a00501f18941efbd0"; pub struct ElixirProvider {} impl Provider for ElixirProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "elixir" } diff --git a/src/providers/fsharp.rs b/src/providers/fsharp.rs index 0f050c7a4..232a2b52e 100644 --- a/src/providers/fsharp.rs +++ b/src/providers/fsharp.rs @@ -15,7 +15,7 @@ pub struct FSharpProvider {} pub const ARTIFACT_DIR: &str = "out"; impl Provider for FSharpProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "f#" } diff --git a/src/providers/gleam/mod.rs b/src/providers/gleam/mod.rs index d0b38089c..99fd26af3 100644 --- a/src/providers/gleam/mod.rs +++ b/src/providers/gleam/mod.rs @@ -38,7 +38,7 @@ impl GleamManifest { pub struct GleamProvider; impl Provider for GleamProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "gleam" } diff --git a/src/providers/go.rs b/src/providers/go.rs index cb0a27cd3..c6d671529 100644 --- a/src/providers/go.rs +++ b/src/providers/go.rs @@ -47,7 +47,7 @@ const DEFAULT_ARCHIVE: &str = "e89cf1c932006531f454de7d652163a9a5c86668"; const GO_BUILD_CACHE_DIR: &str = "/root/.cache/go-build"; impl Provider for GolangProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "go" } diff --git a/src/providers/haskell.rs b/src/providers/haskell.rs index 1e506f285..0b2752b84 100644 --- a/src/providers/haskell.rs +++ b/src/providers/haskell.rs @@ -19,7 +19,7 @@ const STACK_WORK_CACHE_DIR: &str = ".stack-work"; pub struct HaskellStackProvider {} impl Provider for HaskellStackProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "haskell" } diff --git a/src/providers/java.rs b/src/providers/java.rs index 6f095963d..119578151 100644 --- a/src/providers/java.rs +++ b/src/providers/java.rs @@ -18,7 +18,7 @@ const DEFAULT_GRADLE_VERSION: u32 = 8; const JAVA_NIXPKGS_ARCHIVE: &str = "59dc10b5a6f2a592af36375c68fda41246794b86"; impl Provider for JavaProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "java" } diff --git a/src/providers/lunatic.rs b/src/providers/lunatic.rs index 7c64148bb..0e6013dbe 100644 --- a/src/providers/lunatic.rs +++ b/src/providers/lunatic.rs @@ -14,7 +14,7 @@ use regex::Regex; pub struct LunaticProvider {} impl Provider for LunaticProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "lunatic" } diff --git a/src/providers/node/mod.rs b/src/providers/node/mod.rs index 6e6e09a0b..b3dc4704f 100644 --- a/src/providers/node/mod.rs +++ b/src/providers/node/mod.rs @@ -121,7 +121,7 @@ impl PackageJson { pub struct NodeProvider {} impl Provider for NodeProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "node" } diff --git a/src/providers/node/spa/vite.rs b/src/providers/node/spa/vite.rs index 68d5f5a06..ace8f3239 100644 --- a/src/providers/node/spa/vite.rs +++ b/src/providers/node/spa/vite.rs @@ -1,9 +1,6 @@ use regex::Regex; -use crate::{ - nixpacks::{app::App, environment::Environment}, - providers::node::PackageJson, -}; +use crate::{nixpacks::app::App, providers::node::PackageJson}; pub struct ViteSpaProvider {} diff --git a/src/providers/php/mod.rs b/src/providers/php/mod.rs index 80a1ea90d..3737e1124 100644 --- a/src/providers/php/mod.rs +++ b/src/providers/php/mod.rs @@ -34,7 +34,7 @@ const PHP_ARCHIVE_VERSIONS: &[(&str, (&str, &str))] = &[ pub struct PhpProvider; impl Provider for PhpProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "php" } diff --git a/src/providers/procfile.rs b/src/providers/procfile.rs index 1d22a5463..a78334b6d 100644 --- a/src/providers/procfile.rs +++ b/src/providers/procfile.rs @@ -14,7 +14,7 @@ use anyhow::{Context, Ok, Result}; pub struct ProcfileProvider {} impl Provider for ProcfileProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "procfile" } diff --git a/src/providers/python.rs b/src/providers/python.rs index 6b3f88dbf..db7e4bfe6 100644 --- a/src/providers/python.rs +++ b/src/providers/python.rs @@ -36,7 +36,7 @@ const LEGACY_PYTHON_NIXPKGS_ARCHIVE: &str = "5148520bfab61f99fd25fb9ff7bfbb50dad pub struct PythonProvider {} impl Provider for PythonProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "python" } diff --git a/src/providers/ruby.rs b/src/providers/ruby.rs index 78053ca7b..faeb105d6 100644 --- a/src/providers/ruby.rs +++ b/src/providers/ruby.rs @@ -30,7 +30,7 @@ pub struct RubyProvider {} const BUNDLE_CACHE_DIR: &str = "/root/.bundle/cache"; impl Provider for RubyProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "ruby" } diff --git a/src/providers/rust.rs b/src/providers/rust.rs index f5a07c245..68c6b744c 100644 --- a/src/providers/rust.rs +++ b/src/providers/rust.rs @@ -25,7 +25,7 @@ const CARGO_TARGET_CACHE_DIR: &str = "target"; pub struct RustProvider {} impl Provider for RustProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "rust" } diff --git a/src/providers/scala.rs b/src/providers/scala.rs index 489dbb98c..de0e459a8 100644 --- a/src/providers/scala.rs +++ b/src/providers/scala.rs @@ -24,7 +24,7 @@ const DEFAULT_JDK_VERSION: u32 = 17; * TODO: Add support for scala-cli and mill */ impl Provider for ScalaProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "scala" } diff --git a/src/providers/scheme.rs b/src/providers/scheme.rs index 467c675d4..7c9f19921 100644 --- a/src/providers/scheme.rs +++ b/src/providers/scheme.rs @@ -13,7 +13,7 @@ use anyhow::Result; pub struct HauntProvider {} impl Provider for HauntProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "scheme" } diff --git a/src/providers/staticfile.rs b/src/providers/staticfile.rs index f4064ce6b..db17299c6 100644 --- a/src/providers/staticfile.rs +++ b/src/providers/staticfile.rs @@ -25,7 +25,7 @@ pub struct Staticfile { pub struct StaticfileProvider {} impl Provider for StaticfileProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "staticfile" } diff --git a/src/providers/swift.rs b/src/providers/swift.rs index 905b75478..fc68886b3 100644 --- a/src/providers/swift.rs +++ b/src/providers/swift.rs @@ -37,7 +37,7 @@ const AVAILABLE_SWIFT_VERSIONS: &[(&str, &str)] = &[ pub struct SwiftProvider {} impl Provider for SwiftProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "swift" } diff --git a/src/providers/zig.rs b/src/providers/zig.rs index 8a46e00b2..5e4d284cc 100644 --- a/src/providers/zig.rs +++ b/src/providers/zig.rs @@ -14,7 +14,7 @@ use std::ffi::OsStr; pub struct ZigProvider; impl Provider for ZigProvider { - fn name(&self) -> &str { + fn name(&self) -> &'static str { "zig" }