Skip to content

add function_argument_linter() - #1420

Merged
IndrajeetPatil merged 12 commits into
mainfrom
feature/450-function-argument-linter
Jul 27, 2022
Merged

IndrajeetPatil merged 12 commits into
mainfrom
feature/450-function-argument-linter

Conversation

@AshesITR

Copy link
Copy Markdown
Collaborator

Fixes #450.

Name chosen so that we can extend this linter to perform other checks on function argument lists in the future.
e.g. tidyverse usually has defaults for arguments that appear after ...

@AshesITR
AshesITR force-pushed the feature/450-function-argument-linter branch from ee82388 to 6316738 Compare June 19, 2022 17:05
Comment thread NEWS.md Resolved
Comment thread R/function_argument_linter.R Resolved
Comment thread R/function_argument_linter.R Resolved

@MichaelChirico MichaelChirico left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would you mind running this on all (a bunch of?) the tidyverse/r-lib packages? I have a feeling we may be missing some common case, or that it's violated a lot in practice. Any special care needed for S3 methods?

@AshesITR
AshesITR requested a review from MichaelChirico July 11, 2022 12:59
@AshesITR

Copy link
Copy Markdown
Collaborator Author

I'll try to do a run similar to indentation linter and report my findings some time later.
So far I incorporated your feedback and added some more tests.

Comment thread R/function_argument_linter.R Outdated
following-sibling::SYMBOL_FORMALS[not(following-sibling::*[1][self::EQ_FORMALS])]"
xpath <- paste(glue::glue(
"//{c('FUNCTION', 'OP-LAMBDA')}/following-sibling::EQ_FORMALS[1]/
following-sibling::SYMBOL_FORMALS[not(following-sibling::*[not(self::COMMENT)][1][self::EQ_FORMALS])]"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: feels like a lot of whitespace here, no?

MichaelChirico
MichaelChirico previously approved these changes Jul 13, 2022
@MichaelChirico MichaelChirico added this to the 3.0.1 milestone Jul 25, 2022
@IndrajeetPatil
IndrajeetPatil merged commit 2bdf248 into main Jul 27, 2022
@IndrajeetPatil
IndrajeetPatil deleted the feature/450-function-argument-linter branch July 27, 2022 08:06
@MichaelChirico MichaelChirico modified the milestones: 3.0.3, 3.1.0 Mar 20, 2023
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.

Add a linter to check that arguments after an argument with default value have a default value as well

3 participants