Skip to content

lint: enable some lints#164

Draft
KSXGitHub wants to merge 4 commits into
masterfrom
claude/fervent-lamport-Ap8e9
Draft

lint: enable some lints#164
KSXGitHub wants to merge 4 commits into
masterfrom
claude/fervent-lamport-Ap8e9

Conversation

@KSXGitHub
Copy link
Copy Markdown
Owner

@KSXGitHub KSXGitHub commented May 26, 2026

Enable two of perfectionist's own lints against its source and make the crate satisfy them.

unit_test_file_layout

  • Drop the crate's self-opt-out in dylint.toml.
  • Extract the eight over-budget inline #[cfg(test)] mod tests blocks under src/ into nested tests.rs files (pure relocation — no test logic changes).

unicode_ellipsis_in_docs with scan_code_spans = true

  • Turn the knob on in dylint.toml.
  • The ellipsis rules' own rustdoc deliberately names the glyph, so the rule is silenced rather than reworded around: one crate-root #[expect(perfectionist::unicode_ellipsis_in_docs, …)] in src/lib.rs, plus the register_tool boilerplate and the dylint_lib check-cfg — all gated on cfg(dylint_lib = "perfectionist"), per CONTROLLING_RULES.md.
  • The expectation has to live at the crate root: this lint scans comments in check_crate, so every finding resolves to the crate level and a per-site #[expect] is ignored (and reported unfulfilled). Filed as Per-site #[allow]/#[expect] is ignored by comment-walking lints (findings resolve to crate root) #165.
  • Pin the ui/ default-config sweep to an empty dylint.toml so the crate-wide knob doesn't leak into that fixture; the enabled behaviour stays covered under ui-toml/.

The integration-test false-positive fix this depends on already landed on master (#162), now merged in.

just all passes locally: fmt, build, doc, clippy -D warnings, test (--workspace --all-targets), and cargo dylint self-lint.

https://claude.ai/code/session_01SKy8FkjVvug9XkDNzGQL8r

claude added 2 commits May 26, 2026 16:29
…_code_spans

Turn on both rules for the crate's own self-lint and make the source
satisfy them (building on the separate-target fix already on master):

- Drop the crate's `unit_test_file_layout` opt-out and extract the eight
  over-budget inline `#[cfg(test)] mod tests` blocks under `src/` into
  nested `tests.rs` files.
- Set `unicode_ellipsis_in_docs.scan_code_spans = true` and reword the
  rules' own doc comments so no `…` glyph survives inside an inline code
  span; regenerate the rule catalogue.
- Pin the `ui/` default-config sweep to an empty `dylint.toml` so the
  crate-wide `scan_code_spans` override doesn't leak into it (the
  enabled behaviour stays covered under `ui-toml/`).

https://claude.ai/code/session_01SKy8FkjVvug9XkDNzGQL8r
The crate-wide `scan_code_spans` dogfooding stripped the `…` glyph from
the ellipsis rules' own documentation, where naming the character is
the whole point. Restore the glyphs and silence the rule instead of
rewording around it.

`unicode_ellipsis_in_docs` scans comments crate-wide in `check_crate`,
so every finding resolves to the crate root; a per-item `#[expect]` is
out of scope and reported unfulfilled. Place the expectation at the
project-wide site `CONTROLLING_RULES.md` prescribes (`src/lib.rs`), add
the `register_tool` boilerplate so the `perfectionist::` attribute is
accepted, and declare the `dylint_lib` cfg. All three are gated on
`cfg(dylint_lib = "perfectionist")` so a plain `cargo build`, where the
lint never runs, sees neither an unknown tool nor an unfulfilled
expectation.

https://claude.ai/code/session_01SKy8FkjVvug9XkDNzGQL8r
Copy link
Copy Markdown
Owner Author

@KSXGitHub KSXGitHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have posted some questions and some suggestions.

For the questions, answer them. Then take appropriate action if necessary.

For the suggestions, apply them.

text where the ellipsis is meaningful, so they are left alone
unless this is set to `true`. Code *blocks* — fenced
(` ``` ``` `), `~~~`-fenced, four-space indented, and the
(` ``` ... ``` `), `~~~`-fenced, four-space indented, and the
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code,

Is this change intentional?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same change as the src/rules/unicode_ellipsis_in_docs.rs:56 thread — this rules/*.md file is the generated mirror of the source rustdoc (kept in sync, verified by just check-rules-md), so it tracks that edit.

Short version: yes, intentional. Here is a placeholder for a fenced block's contents (a genuine ellipsis → ... per the rule), distinct from the subject-glyph `…` above it, which stays literal and is covered by the crate-root #[expect].


Generated by Claude Code

/// text where the ellipsis is meaningful, so they are left alone
/// unless this is set to `true`. Code *blocks* — fenced
/// (` ``` ``` `), `~~~`-fenced, four-space indented, and the
/// (` ``` ... ``` `), `~~~`-fenced, four-space indented, and the
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude code,

Is this change intentional?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, intentional — and it's the rule-compliant fix rather than drift.

Here the was a placeholder standing in for a fenced code block's contents (``` … ``` → "a fence with some code in it"), i.e. a genuine ellipsis. That's exactly the usage unicode_ellipsis_in_docs asks you to write as ..., so when scan_code_spans = true flagged it, rewording to ... is the correct response.

Contrast the `…` three lines up (the field's first sentence, "flag a character inside an inline code span (`…`)"): there is the subject character the sentence is naming, so it must stay the literal U+2026 glyph. That one — and the other glyph-quoting uses in these rules' rustdoc — is what the crate-root #[expect(perfectionist::unicode_ellipsis_in_docs)] in src/lib.rs exists to silence.

So the split is deliberate: quote-the-glyph uses stay (silenced by the expect); genuine-ellipsis uses become ... (the rule's preferred form). No revert.


Generated by Claude Code

Comment thread src/lib.rs Outdated
Comment on lines +2 to +6
// Register the `perfectionist` tool namespace so this crate can carry
// its own `#[expect(perfectionist::...)]` attributes (see
// `CONTROLLING_RULES.md`). Gated on `cfg(dylint_lib = "perfectionist")`
// so a plain `cargo build` / `cargo check` ignores it and needs no
// nightly `register_tool` feature.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Register the `perfectionist` tool namespace so this crate can carry
// its own `#[expect(perfectionist::...)]` attributes (see
// `CONTROLLING_RULES.md`). Gated on `cfg(dylint_lib = "perfectionist")`
// so a plain `cargo build` / `cargo check` ignores it and needs no
// nightly `register_tool` feature.

Comment thread src/lib.rs Outdated
Comment on lines +9 to +16
// The unicode-ellipsis rules' own rustdoc names the U+2026 glyph they
// govern, which the crate-wide `scan_code_spans` dogfooding would
// otherwise flag. `unicode_ellipsis_in_docs` scans comments crate-wide
// (in `check_crate`), so its findings only ever resolve to the crate
// root — per-item `#[expect]` is out of scope and unfulfilled — so the
// expectation lives here, the project-wide site `CONTROLLING_RULES.md`
// prescribes. Gated on the dylint cfg so a plain `cargo build`, where
// the lint never runs, sees no unfulfilled expectation.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also document that per-site suppression, whilst desirable, is impossible as of now. Also link the relevant issue.

Comment thread dylint.toml Outdated
Comment on lines +6 to +8
# The crate dogfoods `unicode_ellipsis_in_docs` against its own doc
# comments, including the ones inside inline code spans, so the rule's
# own prose may not smuggle a `…` glyph past the code-span exemption.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# The crate dogfoods `unicode_ellipsis_in_docs` against its own doc
# comments, including the ones inside inline code spans, so the rule's
# own prose may not smuggle a `…` glyph past the code-span exemption.

Address PR review feedback:
- Drop the register_tool explanation comment and the dylint.toml
  scan_code_spans note.
- Expand the crate-root expect comment to state that per-site
  #[expect] suppression is desirable but impossible as of now, and
  link the tracking issue (#165).

https://claude.ai/code/session_01SKy8FkjVvug9XkDNzGQL8r

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants