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

Add ignore directives for formatter and linter for auto-generated .R files in httptest2::with_mock_dir() #43

Open
IndrajeetPatil opened this issue Jun 9, 2024 · 2 comments

Comments

@IndrajeetPatil
Copy link

IndrajeetPatil commented Jun 9, 2024

Preamble

Is it possible to add directives to turn off formatter and linter for auto-generated .R files by httptest2::with_mock_dir()?

I work with CI systems that mark builds as failed if any lints or formatting issues are found. This is indeed going to be the case for these auto-generated files. But the code in these files need not follow a style guide or linter recommendations. Additionally, it's not even in the control of the user how this output is generated. Therefore, it would be nice if {httptest2} itself generated these files with ignore directives.

Solution

Tidyverse style guide formatter and linter can be turned off like so:

# nolint start
# styler: off

# add code for <httr2_response> class here
... 

# styler: on
# nolint end
@nealrichardson
Copy link
Owner

nealrichardson commented Jun 17, 2024

We could do that. If so, we'd need to put the change here: https://github.com/nealrichardson/httptest2/blob/main/R/capture-requests.R#L177 I would guess that would involve using deparse() instead of dput() to keep the result in a character vector, add the linter/styler comments to that, and then cat() to the file.

Alternatively, we could do something like this after L177:

if (requireNamespace("styler", quietly = TRUE)) {
  styler::style_file(f)
}

@IndrajeetPatil would you be interested in submitting a PR?

@IndrajeetPatil
Copy link
Author

@nealrichardson Sure, I can take a stab at this next week :)

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

No branches or pull requests

2 participants