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

Start a fuzzing suite to test for consistency of lints #2818

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

Conversation

MichaelChirico
Copy link
Collaborator

@MichaelChirico MichaelChirico commented Mar 6, 2025

Part of #2191. Progress on #2737. Continuation of #2190.

For this initial PR, I've only added a rule about FUNCTION (function(...) { ... }) and OP-LAMBDA (\(...) { ... }) equivalency.

Hopefully my approach here is extensible for other rules (I tried for that). My plan is for this to only run on main, though it's certainly fast enough to run on every PR.

The upshot is, it smoked out three linters with inconsistencies already!

@MichaelChirico MichaelChirico marked this pull request as ready for review March 6, 2025 22:26
@MichaelChirico
Copy link
Collaborator Author

@DavisVaughan / @lionel-, I'm curious if any of your recent work on {air}/{treesitter.r} & friends could be re-used here.

The idea is we want to make random injections/edits to the R AST (and then do stuff), my approach here felt quite manual/labor-intensive.

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.64%. Comparing base (c315baf) to head (523c218).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2818   +/-   ##
=======================================
  Coverage   99.64%   99.64%           
=======================================
  Files         126      126           
  Lines        6960     6961    +1     
=======================================
+ Hits         6935     6936    +1     
  Misses         25       25           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DavisVaughan
Copy link
Member

DavisVaughan commented Mar 7, 2025

The closest thing I can think of is parser_reparse() in {treesitter}
https://davisvaughan.github.io/r-tree-sitter/reference/parser-parse.html

It performs an incremental reparse and hands you back a new tree with the edit you made. It's quite verbose in terms of what you have to provide (bytes and points) but this is a tree-sitter limitation (and I'm sure they had some reason for it).

Note that text here in parser_reparse() is the entire original source document with a single contiguous edit already applied to it (it's not the incremental bit of text)

For Air, I don't think Rowan trees are really intended to be edited. At least, there doesn't seem to be any easy to use API for that (and plus Rowan isn't exposed in any R package right now anyways)

@MichaelChirico
Copy link
Collaborator Author

Interesting, yea the incremental re-parse is very neat, but more useful in an IDE setting. Here the latency of re-parse is not much concern as the edits are only a tiny fraction of the action run time.

For Air, I don't think Rowan trees are really intended to be edited. At least, there doesn't seem to be any easy to use API for that (and plus Rowan isn't exposed in any R package right now anyways)

Hmm, I guess in my mind something like {styler} / {air} is well-suited here if it exposes a friendly API for transformers, i.e. instead of the usual helpful rule like 'make this line <80 characters', we have a more adversarial rule like "add comments in random but syntactically valid places". I not be understanding where in the stack behind the format-on-save tool such an analog would sit.

@lionel-
Copy link
Member

lionel- commented Mar 10, 2025

For Air, I don't think Rowan trees are really intended to be edited. At least, there doesn't seem to be any easy to use API for that (and plus Rowan isn't exposed in any R package right now anyways)

I may be misunderstanding what you mean but AFAIK the red trees in Rowan are modifiable. I believe this is used for refactorings in rust-analyzer.

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.

3 participants