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

Fix some lints in the R folder #6050

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

etiennebacher
Copy link
Contributor

Hello, I'm building a new package to find and automatically fix lints in R code: flint.

I'm using real-life, large packages to check its performance and ggplot2 is one of them. Since I already test on this, there's no additional cost for me in proposing those changes.

FYI, those changes were all generated by flint::fix_dir("R").

There are many changes but most of them are trivial:

  • replace any(is.na()) by anyNA()
  • replace the = assignment by <- (since both are used across the codebase, I guess <- should be the default)
  • add a leading 0 to decimal (e.g .1 -> 0.1)

and a few other things.

flint is quite new and linter rules are necessarily a bit opinionated, so some of those changes might not be to your taste, but I'd be happy to have some feedback on this.

Copy link
Collaborator

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

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

Thanks Etienne, these look all great to me.
I was in the progress of preparing a big linting PR as well so this is great to see.

An additional thing ggplot2 might still want to replace is seq_len(nrow(x)) with vctrs::vec_seq_along(x), but that perhaps not for this PR.

@etiennebacher
Copy link
Contributor Author

etiennebacher commented Aug 20, 2024

An additional thing ggplot2 might still want to replace is seq_len(nrow(x)) with vctrs::vec_seq_along(x), but that perhaps not for this PR.

I think this would be a perfect case study for setup_flint(), which creates a flint folder where you can add custom rules used by flint or deactivate parts of the built-in rules. Would you be open to a PR with this? Not everything is fleshed out on how a flint update would affect the flint folder, so you might want to wait for a more stable version of flint.

@teunbrand
Copy link
Collaborator

Would you be open to a PR with this?

ggplot2 doesn't do any automatic linting and I don't think we're likely to change that, so we'll gladly accept the improvements presented in this PR but are hesitant towards any deeper integration at this point.

@etiennebacher etiennebacher changed the title Fix some lints Fix some lints in the R folder Aug 20, 2024
@teunbrand
Copy link
Collaborator

I'm going to merge this quickly before I bestow any merge conflicts on this PR, thanks for this!

@teunbrand teunbrand merged commit d8eb945 into tidyverse:main Aug 20, 2024
11 checks passed
@etiennebacher etiennebacher deleted the fix-some-lints branch August 20, 2024 12:19
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