feat(code-action): add quickfix to remove extra rec keyword#785
Closed
takeokunn wants to merge 1 commit into
Closed
feat(code-action): add quickfix to remove extra rec keyword#785takeokunn wants to merge 1 commit into
takeokunn wants to merge 1 commit into
Conversation
- Recognize DK_ExtraRecursive diagnostics as preferred quickfixes - Add tests for removing extra rec in basic, empty, and multiline attrsets - Ensure no code action is offered when rec is required for references
3 tasks
inclyc
reviewed
Feb 14, 2026
| bool IsPreferred = false; | ||
| switch (D.kind()) { | ||
| case nixf::Diagnostic::DK_UnusedDefLet: | ||
| case nixf::Diagnostic::DK_ExtraRecursive: |
Member
Collaborator
Author
There was a problem hiding this comment.
Sorry, You're right — these PRs all add the same pattern and they conflict with #778.
#778 introduces Fix::prefer() so each fix declares itself as preferred at creation time, which removes this switch statement.
I'll close #785–#788, get #778 merged first, then open a single follow-up PR that adds .prefer() to the remaining diagnostic fixes (extra-rec, extra-with, empty-inherit, redundant-paren) together with their tests.
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.
Summary
Add a code action that removes unnecessary
reckeywords from attribute sets, marked as a preferred quickfix.Example Transformation:
rec { x = 1; }{ x = 1; }Changes
nixd/lib/Controller/CodeAction.cppDK_ExtraRecursiveas isPreferredBehavior
Action offered when:
reckeyword where no binding references another binding in the same attrsetAction NOT offered when:
rec { x = 1; y = x; })Test Plan
basic.md: Single-linerec { x = 1; }removalmultiline.md: Multiline attrset with independent bindingsneeded-rec.md: Negative test — action not offered whenrecis neededRelated