Skip to content

Commit

Permalink
chore: fix clippy warnings (#967)
Browse files Browse the repository at this point in the history
* Automatically fix clippy lints

* Fix remaining clippy warnings

* Enforce on CI

* Remove path limitation, does't play well with concurrency feature

* Update flags
  • Loading branch information
Hofer-Julian authored Jul 11, 2024
1 parent bfaf65d commit 46705c5
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 24 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@ on:
branches: [main]
tags:
- "v*.*.*"
paths:
- "src/**"
- "Cargo.*"
- ".github/workflows/*"
pull_request:
paths:
- "src/**"
- "Cargo.*"
- ".github/workflows/*"

workflow_dispatch:

Expand Down Expand Up @@ -55,6 +47,7 @@ jobs:
with:
reporter: "github-pr-check"
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: "--all-targets"

build:
name: Build ${{ matrix.target }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ repos:
- id: clippy
name: clippy
description: Checks a package to catch common mistakes and improve your Rust code.
entry: cargo clippy --all --color always
entry: cargo clippy --all-targets --color always
language: system
pass_filenames: false
5 changes: 1 addition & 4 deletions src/package_test/content_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,7 @@ mod tests {
NoMatch,
}

fn test_glob_matches(
globs: &Vec<(String, GlobSet)>,
paths: &[String],
) -> Result<(), MatchError> {
fn test_glob_matches(globs: &[(String, GlobSet)], paths: &[String]) -> Result<(), MatchError> {
let mut matches = Vec::new();
for path in paths {
let mut has_match = false;
Expand Down
6 changes: 3 additions & 3 deletions src/recipe/jinja.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,9 @@ mod tests {
fn with_temp_dir(key: &'static str, f: impl Fn(&std::path::Path)) {
let tempdir = tempfile::tempdir().unwrap();
let dir = tempdir.path().join(key);
_ = std::fs::create_dir_all(&dir).unwrap();
std::fs::create_dir_all(&dir).unwrap();
f(&dir);
_ = std::fs::remove_dir_all(dir).unwrap();
std::fs::remove_dir_all(dir).unwrap();
}

// git version is too old in cross container for aarch64
Expand Down Expand Up @@ -774,7 +774,7 @@ mod tests {
assert_eq!(jinja.eval(&format!("git.latest_tag({:?})", path)).expect("test 0").as_str().unwrap(), "v0.1.0");
assert_eq!(jinja.eval(&format!("git.latest_tag_rev({:?})", path)).expect("test 1 left").as_str().unwrap(), jinja.eval(&format!("git.head_rev({:?})", path)).expect("test 1 right").as_str().unwrap());
assert_eq!(
jinja_wo_experimental.eval(&format!("git.latest_tag({:?})", path)).err().expect("test 2").to_string(),
jinja_wo_experimental.eval(&format!("git.latest_tag({:?})", path)).expect_err("test 2").to_string(),
"invalid operation: Experimental feature: provide the `--experimental` flag to enable this feature (in <expression>:1)",
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/recipe/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ mod tests {
let err = recipe.unwrap_err();
let err: ParseErrors = err
.into_iter()
.map(|err| ParsingError::from_partial(&raw_recipe, err))
.map(|err| ParsingError::from_partial(raw_recipe, err))
.collect::<Vec<_>>()
.into();
assert_miette_snapshot!(err);
Expand Down
2 changes: 1 addition & 1 deletion src/recipe/parser/glob_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl GlobVec {
include,
exclude,
include_globset: globset,
exclude_globset: exclude_globset,
exclude_globset,
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/recipe/parser/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ impl TryConvertNode<PackageContentsTest> for RenderedMappingNode {
}

#[cfg(test)]
#[allow(clippy::module_inception)]
mod test {
use std::fs;

Expand Down Expand Up @@ -395,12 +396,12 @@ mod test {

// from yaml
let tests: Vec<TestType> = serde_yaml::from_str(&yaml_serde).unwrap();
let t = tests.get(0);
let t = tests.first();

match t {
Some(TestType::Python { python }) => {
assert_eq!(python.imports, vec!["numpy.testing", "numpy.matrix"]);
assert_eq!(python.pip_check, true);
assert!(python.pip_check);
}
_ => panic!("expected python test"),
}
Expand Down
2 changes: 1 addition & 1 deletion src/render/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ mod test {
let (version, hash) = spec.split_whitespace().collect_tuple().unwrap();
let version: Version = version.parse().unwrap();
let spec = test.pin.apply(&version, hash).unwrap();
println!("{} -> {}", spec.to_string(), test.expected);
println!("{} -> {}", spec, test.expected);
assert_eq!(spec.to_string(), test.expected);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/render/resolved_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,6 @@ mod tests {
upper_bound: Some("x.x".parse().unwrap()),
lower_bound: Some("x.x.x".parse().unwrap()),
exact: true,
..Default::default()
},
}
.into(),
Expand All @@ -988,7 +987,6 @@ mod tests {
upper_bound: Some("x.x".parse().unwrap()),
lower_bound: Some("x.x.x".parse().unwrap()),
exact: true,
..Default::default()
},
}
.into(),
Expand Down
2 changes: 1 addition & 1 deletion src/source/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ mod test {
assert!(term.contents().trim().starts_with(
"Extracting zip [00:00:00] [━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━]"
));
assert!(matches!(res.err(), None));
assert!(res.err().is_none());
assert!(tempdir.path().join("text.txt").exists());
assert!(std::fs::read_to_string(tempdir.path().join("text.txt"))
.unwrap()
Expand Down

0 comments on commit 46705c5

Please sign in to comment.