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

Feature: forge query - AST based code search #2408

Open
sambacha opened this issue Jul 20, 2022 · 4 comments
Open

Feature: forge query - AST based code search #2408

sambacha opened this issue Jul 20, 2022 · 4 comments
Labels
C-forge Command: forge P-low Priority: low T-feature Type: feature

Comments

@sambacha
Copy link
Contributor

Component

Forge

Describe the feature you would like

Forge Query

Provide an AST pattern, and see details about when that pattern was introduced.

This enables a much easier way to understand how or why a pattern was introduced. For instance, you can answer questions such as:

  • Which devs are using solmate, and which are using open-zeppelin?
  • Chronologically, when has each package been used? Do we see a shift over time?

To query the codebase to search for such a pattern, we can specify an AST selector as it would be accepted by Forge Lint.

AST selector is supported on AST Explorer for solidity.

For instance, to search for console.log() calls in javascript, the ESLint selector would be

"CallExpression[callee.object.name=console][callee.property.name=log]"

Other use cases

This could be used to help automate refactoring, finding regressions, etc

Additional context

No response

@sambacha sambacha added the T-feature Type: feature label Jul 20, 2022
@gakonst gakonst added this to Foundry Jul 20, 2022
@gakonst gakonst moved this to Todo in Foundry Jul 20, 2022
@onbjerg
Copy link
Collaborator

onbjerg commented Jul 21, 2022

Not entirely sure how this feature would answer those questions without some sort of time scale/log, can you expand on that?

@onbjerg onbjerg added C-forge Command: forge P-low Priority: low labels Jul 21, 2022
@sambacha
Copy link
Contributor Author

Not entirely sure how this feature would answer those questions without some sort of time scale/log, can you expand on that?

It would resolve to the git commit, can do a PoC tomorrow or Saturday possibly

@sambacha
Copy link
Contributor Author

sambacha commented Aug 6, 2022

Not entirely sure how this feature would answer those questions without some sort of time scale/log, can you expand on that?

It would resolve to the git commit, can do a PoC tomorrow or Saturday possibly

Waiting for this to land: gakonst/ethers-rs#1567

@DaniPopes
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge P-low Priority: low T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

4 participants