From ec9df53d4c8c9187c5df9a3e6aec9786f03c1616 Mon Sep 17 00:00:00 2001 From: Luni-4 Date: Fri, 17 Nov 2023 01:35:38 +0100 Subject: [PATCH] ci/Fix `cargo clippy` action (#942) --- .github/workflows/test.yml | 5 ++++- backend-comparison/benches/custom_gelu.rs | 6 ++---- burn-import/onnx-tests/tests/onnx_tests.rs | 3 +++ burn-tensor/src/tests/ops/slice.rs | 1 + examples/image-classification-web/build.rs | 2 +- xtask/src/runchecks.rs | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fe0d8240..30fc13b97 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,7 +89,10 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} # Run clippy for each workspace, targets, and featrues, considering # warnings as errors - clippy_flags: --workspace --all-targets --all-features -- -D warnings + clippy_flags: --all-targets -- -Dwarnings + # Do not filter results + filter_mode: nofilter + # Report clippy annotations as snippets reporter: github-pr-check - name: Install grcov diff --git a/backend-comparison/benches/custom_gelu.rs b/backend-comparison/benches/custom_gelu.rs index 97aceb490..71db646a9 100644 --- a/backend-comparison/benches/custom_gelu.rs +++ b/backend-comparison/benches/custom_gelu.rs @@ -52,9 +52,7 @@ where Erf: Fn(Tensor) -> Tensor, { let x = x.clone() * (erf(x / SQRT_2) + 1); - let result = x / 2; - - result + x / 2 } fn erf_custom(x: Tensor) -> Tensor { @@ -81,7 +79,7 @@ fn erf_positive(x: Tensor) -> Tensor { let t = x1.recip(); let tmp = (((((t.clone() * a5) + a4) * t.clone()) + a3) * t.clone() + a2) * t.clone() + a1; - return -(tmp * t * (-x.clone() * x).exp()) + 1.0; + -(tmp * t * (-x.clone() * x).exp()) + 1.0 } #[allow(dead_code)] diff --git a/burn-import/onnx-tests/tests/onnx_tests.rs b/burn-import/onnx-tests/tests/onnx_tests.rs index f1e515845..b10c45849 100644 --- a/burn-import/onnx-tests/tests/onnx_tests.rs +++ b/burn-import/onnx-tests/tests/onnx_tests.rs @@ -551,8 +551,11 @@ mod tests { fn linear() { // Initialize the model with weights (loaded from the exported file) let model: linear::Model = linear::Model::default(); + #[allow(clippy::approx_constant)] let input1 = Tensor::::full([4, 3], 3.14); + #[allow(clippy::approx_constant)] let input2 = Tensor::::full([2, 5], 3.14); + #[allow(clippy::approx_constant)] let input3 = Tensor::::full([3, 2, 7], 3.14); let (output1, output2, output3) = model.forward(input1, input2, input3); diff --git a/burn-tensor/src/tests/ops/slice.rs b/burn-tensor/src/tests/ops/slice.rs index d08db11ab..7db32a672 100644 --- a/burn-tensor/src/tests/ops/slice.rs +++ b/burn-tensor/src/tests/ops/slice.rs @@ -131,6 +131,7 @@ mod tests { let data = Data::from([0.0, 1.0, 2.0]); let tensor = Tensor::::from_data(data.clone()); + #[allow(clippy::reversed_empty_ranges)] let data_actual = tensor.slice([2..1]).into_data(); assert_eq!(data, data_actual); diff --git a/examples/image-classification-web/build.rs b/examples/image-classification-web/build.rs index 127a7982c..e9c4ad2fa 100644 --- a/examples/image-classification-web/build.rs +++ b/examples/image-classification-web/build.rs @@ -36,7 +36,7 @@ fn main() { fn generate_labels_from_txt_file() -> std::io::Result<()> { let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join(LABEL_DEST_FILE); - let mut f = File::create(&dest_path)?; + let mut f = File::create(dest_path)?; let file = File::open(LABEL_SOURCE_FILE)?; let reader = BufReader::new(file); diff --git a/xtask/src/runchecks.rs b/xtask/src/runchecks.rs index cf0c3364d..4d790aa3f 100644 --- a/xtask/src/runchecks.rs +++ b/xtask/src/runchecks.rs @@ -120,7 +120,7 @@ fn cargo_clippy() { // Run cargo clippy run_cargo( "clippy", - ["--color=always", "--", "-D", "warnings"].into(), + ["--color=always", "--all-targets", "--", "-D", "warnings"].into(), "Failed to run cargo clippy", ); }