Repository navigation
chore(lint): enable clippy::filetype_is_file - #51
Merged
Merged
Conversation
Add `filetype_is_file = "deny"` to the strict Clippy baseline. When walking type directories with `read_dir`, an entry's `FileType` is not followed for symlinks, so `!is_file()` silently skips a symlink pointing at a real `.md` item file. Switch the three directory-scan guards (`list`, `get_next_display_number`, `reconcile_display_numbers`) to `is_dir()` so only true subdirectories are skipped and symlinked item files stay visible. Closes #50 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolve Cargo.toml conflict: main independently added verbose_file_reads in the same area since this branch was created. Keep both new lint entries (verbose_file_reads from main, filetype_is_file from this PR).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Enable the
clippy::filetype_is_filerestriction lint (deny, matching the existing strict baseline) and fix the three violations it surfaces.Why
When iterating directory entries with
read_dir, an entry'sFileTypereflects the entry itself and is not followed through symlinks. A guard likeif !entry.file_type().await?.is_file() { continue; }— intended to skip subdirectories — also silently skips a symlink that points at a real.mditem file, making that item invisible tolist/reconcile. That is a latent correctness bug for any store laid out with symlinks.Testing the directory case directly with
is_dir()expresses the real intent ("skip subdirectories") and keeps symlinked item files visible. They stay gated by the existingis_item_file()name check and frontmatter parse, so non-item entries are still filtered out.Changes
Cargo.toml: addfiletype_is_file = "deny"to[lints.clippy]with a rationale comment.src/storage.rs(list),src/reconcile.rs(get_next_display_number,reconcile_display_numbers):!entry.file_type().await?.is_file()→entry.file_type().await?.is_dir().CHANGELOG.md: note under Unreleased.Verification
cargo clippy --all-targets— clean (exit 0).cargo test— 113 passed, 0 failed.Closes #50
This pull request was opened by the "Add lint rule → issue + PR (owned repos + my orgs) → Slack" routine of moadim, on behalf of @tupe12334.