Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignment_linter() gains operator= argument to allow, e.g. '=' assignments #2711

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

MichaelChirico
Copy link
Collaborator

Supersedes #2698 and #2521. h/t again @J-Moravec for getting the ball rolling here.

Closes #2441.

This also un-couples the linted operator from the allow_trailing behavior; lints generated by the operator used are now independent of lints generated by line-trailing assignment operators:

## current 'main'
lint("a <-
1", assignment_linter(allow_trailing=FALSE))
# <text>:1:3: style: [assignment_linter] Assignment <- should not be trailing at the end of a line.
# a <-
#   ^~
lint("a =
1", assignment_linter(allow_trailing=FALSE))
# <text>:1:3: style: [assignment_linter] Use <-, not =, for assignment.
# a =
#   ^

## current branch (assignment-operator)
lint("a <-
1", assignment_linter(allow_trailing=FALSE))
# <text>:1:3: style: [assignment_linter] Assignment <- should not be trailing at the end of a line.
# a <-
#   ^~
lint("a =
1", assignment_linter(allow_trailing=FALSE))
# <text>:1:3: style: [assignment_linter] Use one of <-, <<- for assignment, not =.
# a =
#   ^
# <text>:1:3: style: [assignment_linter] Assignment = should not be trailing at the end of a line.
# a =
#   ^

Having <<- allowed by default is back-compatible, but does strike me as odd -- should we also plan to remove this from the defaults?

@MichaelChirico MichaelChirico changed the title Assignment operator assignment_linter() gains operator= argument to allow, e.g. '=' assignments Jan 28, 2025
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.

Extend assignment_linter() to enforce '=' by default for assignment
1 participant