diff --git a/.justfile b/.justfile index 47378129..5ca80c0b 100644 --- a/.justfile +++ b/.justfile @@ -2,7 +2,7 @@ install: cargo install --path ./crates/moon --debug --offline --root ~/.moon --force --locked clippy: - cargo clippy --all-targets --all-features -- -D warnings + cargo clippy --all-targets --all-features --locked -- -D warnings add-header: hawkeye format diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 00000000..71a4829a --- /dev/null +++ b/clippy.toml @@ -0,0 +1,21 @@ +# moon: The build system and package manager for MoonBit. +# Copyright (C) 2024 International Digital Economy Academy +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# For inquiries, you can contact us via e-mail at jichuruanjian@idea.edu.cn. + +disallowed-methods = [ + { path = "std::path::Path::canonicalize", reason = "Please use dunce::canonicalize" }, +] diff --git a/crates/moon/tests/test_cases/mod.rs b/crates/moon/tests/test_cases/mod.rs index 323b40ee..e47c66be 100644 --- a/crates/moon/tests/test_cases/mod.rs +++ b/crates/moon/tests/test_cases/mod.rs @@ -2391,7 +2391,7 @@ fn test_mbti() { #[test] fn test_dummy_core() { let test_dir = TestDir::new("dummy-core.in"); - let dir = test_dir.as_ref().canonicalize().unwrap(); + let dir = dunce::canonicalize(test_dir.as_ref()).unwrap(); snapbox::cmd::Command::new(moon_bin()) .current_dir(&dir) diff --git a/crates/moonbuild/src/expect.rs b/crates/moonbuild/src/expect.rs index 0e7a6271..7e1276d8 100644 --- a/crates/moonbuild/src/expect.rs +++ b/crates/moonbuild/src/expect.rs @@ -94,8 +94,7 @@ pub struct ExpectFailedRaw { pub fn expect_failed_to_snapshot_result(efr: ExpectFailedRaw) -> SnapshotResult { let filename = parse_filename(&efr.loc).unwrap(); - let expect_file = PathBuf::from(&filename) - .canonicalize() + let expect_file = dunce::canonicalize(PathBuf::from(&filename)) .unwrap() .parent() .unwrap() @@ -589,8 +588,7 @@ pub fn apply_snapshot(messages: &[String]) -> anyhow::Result<()> { let filename = parse_filename(&snapshot.loc)?; let actual = snapshot.actual.clone(); let expect_file = &snapshot.expect_file; - let expect_file = PathBuf::from(&filename) - .canonicalize() + let expect_file = dunce::canonicalize(PathBuf::from(&filename)) .unwrap() .parent() .unwrap() @@ -698,8 +696,7 @@ pub fn render_snapshot_fail(msg: &str) -> anyhow::Result<(bool, String, String)> let loc = parse_loc(&snapshot.loc)?; let actual = snapshot.actual.clone(); let expect_file = &snapshot.expect_file; - let expect_file = PathBuf::from(&filename) - .canonicalize() + let expect_file = dunce::canonicalize(PathBuf::from(&filename)) .unwrap() .parent() .unwrap()