Skip to content

chore(lint): enable clippy::filetype_is_file - #51

Merged
tupe12334 merged 2 commits into
mainfrom
lint/enable-filetype-is-file
Jul 16, 2026
Merged

tupe12334 merged 2 commits into
mainfrom
lint/enable-filetype-is-file

Conversation

@tupe12334

Copy link
Copy Markdown
Member

What

Enable the clippy::filetype_is_file restriction lint (deny, matching the existing strict baseline) and fix the three violations it surfaces.

Why

When iterating directory entries with read_dir, an entry's FileType reflects the entry itself and is not followed through symlinks. A guard like if !entry.file_type().await?.is_file() { continue; } — intended to skip subdirectories — also silently skips a symlink that points at a real .md item file, making that item invisible to list/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 existing is_item_file() name check and frontmatter parse, so non-item entries are still filtered out.

Changes

  • Cargo.toml: add filetype_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.

tupe12334 and others added 2 commits June 20, 2026 07:04
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).
@tupe12334
tupe12334 merged commit b995147 into main Jul 16, 2026
6 checks passed
@tupe12334
tupe12334 deleted the lint/enable-filetype-is-file branch July 16, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable clippy::filetype_is_file lint rule

1 participant