Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/dylint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- uses: actions/checkout@v6

- name: Cache
id: cache
uses: actions/cache@v5
timeout-minutes: 2
continue-on-error: true
Expand All @@ -39,6 +40,20 @@ jobs:
shell: bash
run: cargo install --locked cargo-dylint dylint-link

# When the primary cache key did not match exactly, the cache was either
# missed entirely or restored from one of the looser `restore-keys`
# entries. The third entry ignores `dylint.toml`, so the restored
# `target/dylint/libraries/libperfectionist.so` may have been built from
# a different `dylint.toml`. `cargo dylint` does not always detect a
# changed `git` `rev`/`tag` and reuses the cached `.so` as-is. Remove
# the dylint build directory in this case so the library rebuilds from
# the in-tree `dylint.toml`. On an exact cache hit the `.so` matches
# the current `dylint.toml` and the rebuild is skipped.
- name: Invalidate stale dylint build artifacts
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: rm -rf target/dylint

- name: Run dylint
shell: bash
env:
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Write documentation, comments, and other prose for ease of understanding first.

## Code Style

Automated tools enforce formatting (`cargo fmt`) and linting (`cargo clippy`). The following conventions are **not** enforced by those tools and must be followed manually.
Automated tools enforce formatting (`cargo fmt`), linting (`cargo clippy`), and a curated set of project-specific rules via dylint (`cargo dylint --all`, run with `DYLINT=true ./test.sh`). The following conventions must be followed manually unless a subsection notes that a specific dylint rule enforces them.

### Import Organization

Expand All @@ -54,7 +54,8 @@ use crate::get_size::{GetBlockCount, GetBlockSize};

### Module Organization

- Use the flat file pattern (`module.rs`) rather than `module/mod.rs` for submodules.
The flat file pattern (`module.rs` rather than `module/mod.rs`) is enforced by the `perfectionist::flat_module_pattern` dylint check. In addition to that requirement, follow these conventions:

- List `pub mod` declarations first, then `pub use` re-exports, then private imports and items.
- Use `pub use` to re-export key types at the module level for convenience.
Comment thread
KSXGitHub marked this conversation as resolved.

Expand Down
2 changes: 1 addition & 1 deletion dylint.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace.metadata.dylint]
libraries = [
{ git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.0" },
{ git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.7" },
]
4 changes: 2 additions & 2 deletions src/app/hdd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ fn is_virtual_block_device<Fs: FsApi>(block_dev: &str) -> bool {
| "xen-blkfront"
| "vbd"
| "vmw_pvscsi"
| "hv_storvsc"
)
| "hv_storvsc",
),
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/hdd/test_linux_smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn real_sysfs_vda_does_not_panic() {
fn nonexistent_device_is_not_virtual() {
assert!(
!is_virtual_block_device::<RealFs>("nonexistent_device_xyz"),
"non-existent device should not be detected as virtual"
"non-existent device should not be detected as virtual",
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/hardlink/hardlink_list/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ where
}
Ordering::Less => {
panic!(
"Impossible! Total of nlink ({links}) is less than detected paths ({paths}). Something must have gone wrong!"
"Impossible! Total of nlink ({links}) is less than detected paths ({paths}). Something must have gone wrong!",
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/man_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn render_possible_values(out: &mut String, arg: &Arg) {
}
if matches!(
arg.get_action(),
ArgAction::SetTrue | ArgAction::SetFalse | ArgAction::Count
ArgAction::SetTrue | ArgAction::SetFalse | ArgAction::Count,
) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ unit() (
run_if "${FMT:-true}" cargo fmt -- --check
# Dylint inspects the source under all feature gates in a single pass, so it is
# run once with `--all-features` rather than across every feature combination.
run_if "${DYLINT:-false}" cargo dylint --all -- --all-features --all-targets
run_if "${DYLINT:-false}" env RUSTFLAGS="-D warnings ${RUSTFLAGS:-}" \
cargo dylint --all -- --all-features --all-targets
Comment thread
KSXGitHub marked this conversation as resolved.
unit "$@"
unit --no-default-features "$@"
unit --all-features "$@"
Expand Down
4 changes: 2 additions & 2 deletions tests/cli_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn min_ratio_1() {
"error: invalid value '1' for '--min-ratio <MIN_RATIO>': greater than or equal to 1"
""
"For more information, try '--help'."
}
},
);
assert_eq!(&stdout, &[] as &[u8]);
}
Expand Down Expand Up @@ -101,7 +101,7 @@ fn max_depth_0() {
r#"error: invalid value '0' for '--max-depth <MAX_DEPTH>': Value is neither "inf" nor a positive integer: number would be zero for non-zero type"#
""
"For more information, try '--help'."
}
},
);
assert_eq!(&stdout, &[] as &[u8]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/one_file_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ fn cross_device_excludes_mount() {
.find_map(|mut entry| entry.next()?.ok());
assert!(
poll_result.is_some(),
"FUSE mount at {mount_point:?} not ready after {retries} retries"
"FUSE mount at {mount_point:?} not ready after {retries} retries",
);

let build_expected_tree = |device_boundary: DeviceBoundary| -> String {
Expand Down
Loading