Skip to content

feat(rules): add Solidity and Vyper review rules - #961

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
chethanuk:wf/solidity-vyper-language-support
Aug 27, 2026
Merged

lizhengfeng101 merged 2 commits into
alibaba:mainfrom
chethanuk:wf/solidity-vyper-language-support

Conversation

@chethanuk

Copy link
Copy Markdown
Contributor

Description

.sol and .vy files were never reviewed. Neither extension is in supported_file_types.json, so IsAllowedExt drops them at the filter gate before any rule can run, which is why a rule doc on its own would never have been reachable.

This adds both extensions and registers two rule docs in path_rule_map: **/*.sol → solidity.md and **/*.vy → vyper.md. Data only, no Go source changes.

Two docs rather than one shared EVM doc. The repo splits rule docs by language syntax, not by domain — c.md and cpp.md stay separate despite covering the same ground, and multi-extension docs like haskell.md cover several file forms of a single language, never two languages. Vyper checks arithmetic by default and has neither inheritance nor inline assembly, so a merged doc would put claims into every Vyper review that are false for Vyper.

The six exclude patterns are scoped by extension (**/test/**/*.sol, not a bare **/test/**). IsExcludedPath applies every pattern to every path with no language dispatch, so an unscoped test/ pattern would drop Julia, Nim and Haskell files as well. **/*.t.sol on its own is not enough either: Foundry test helpers and mock contracts carry no suffix, and test/utils/BaseTest.sol and contracts/test/ERC20TestToken.sol are both real layouts. The directory patterns cover those the way **/test/**/*.jl and **/tests/**/*.nim already do. Both the singular and the plural spelling of the directory is present for each extension.

lib/**/*.sol is root-anchored on purpose. That is where Foundry installs git submodule dependencies, but **/lib/**/*.sol would also match src/lib/Math.sol and contracts/lib/SafeMath.sol, which are a project's own hand-written library code. Three negative rows fail if anyone broadens the pattern later.

Limitation

Vyper's legacy .v.py extension is not covered and cannot be. extFromPath takes the last dot of the basename, so token.v.py resolves to .py and is reviewed as Python. An allowlist entry for .v.py would never be looked up.

.sol and .vy diffs that used to be skipped are now reviewed. Anyone who does not want that opts out with user exclude globs, which are checked before the allowlist.

Type of Change

  • New feature (non-breaking change that adds functionality)

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Rows appended to the existing table tests:

  • TestIsAllowedExt — .sol/.SOL and .vy/.VY.
  • TestIsExcludedPath — the six patterns, the three lib/ negatives above, and script/Deploy.s.sol, which stays reviewable.
  • TestResolve_DefaultRules — source paths for both extensions resolve by heading anchors unique to each doc.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

The rule table in pages/src/content/docs/{en,ja,ru,zh}/review-rules.md lists both new patterns.

Related Issues

Part of #470.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s).

@chethanuk
chethanuk force-pushed the wf/solidity-vyper-language-support branch 2 times, most recently from 57346f4 to 6e34b54 Compare August 17, 2026 07:35
@chethanuk
chethanuk force-pushed the wf/solidity-vyper-language-support branch 2 times, most recently from fa87067 to a2cc110 Compare August 18, 2026 08:53
`.sol` and `.vy` files were rejected by the extension allowlist, so no
review rules could ever run on them. `whyExcluded` checks `IsAllowedExt`
before any rule is resolved, so allowlisting the two extensions is what
makes the new rule docs reachable at all.

Adds `.sol`/`.vy` to supported_file_types.json, routes them to two new
rule docs via path_rule_map, and adds six exclude patterns.

Two rule docs rather than one shared EVM doc: the repo splits rule docs
by language syntax, not by domain (`c.md`/`cpp.md`, `po.md`/`pot.md`).
Vyper checks arithmetic by default and has no inheritance or inline
assembly, so half a shared doc would be wrong on every file it matched.

No `.v.py`: `extFromPath` takes the last dot of the basename, so
`token.v.py` resolves to `.py` and the entry could never be looked up.
Every remaining use of that extension is pre-0.1 viper-era code or a
tool's backward-compat list.

`**/*.t.sol` alone misses the test helpers and mock contracts that carry
no suffix — `test/BaseTest.sol`, `test/foundry/utils/BaseTest.sol` and
`contracts/test/ERC20TestToken.sol` are all real layouts — so
`**/test/**/*.sol` and `**/tests/**/*.sol` cover the directory the way
`**/test/**/*.jl` and `**/tests/**/*.nim` already do for other
languages. `.vy` gets both spellings of the directory for the same
reason.

`lib/**/*.sol` is root-anchored deliberately. `IsExcludedPath` applies
every pattern to every path with no language dispatch, and
`**/lib/**/*.sol` also matches `src/lib/Math.sol` — a project's own
library directory. The test table asserts both directions.

No build-output patterns: `out/`, `artifacts/`, `cache/` and
`typechain-types/` contain no `.sol` or `.vy` files, and are gitignored,
so internal/scan/provider.go's gitignore walk already skips them.

Users can re-admit any of this with `--include`, which `whyExcluded`
checks before `IsExcludedPath`.

The rule table in pages/src/content/docs/{en,ja,ru,zh}/review-rules.md
lists both new patterns.
@chethanuk
chethanuk force-pushed the wf/solidity-vyper-language-support branch from a2cc110 to f0be91f Compare August 21, 2026 06:19
Main's Objective-C/MATLAB `.m` rule lands on the same trailing lines this
branch appends to: the pattern map in system_rules.json, the resolution table
in system_rules_test.go, and the pattern table in all four locales of
review-rules.md. Kept both sides, main's first; in the JSON that also means
giving main's entry the comma it did not need as the last member.

Claude-Session: https://claude.ai/code/session_01FoMHZQ3qqdt98LHTwSJuTG
@chethanuk

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Rebased onto main and conflicts resolved again. Please review this. Thanks :)

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 1cbad6d into alibaba:main Aug 27, 2026
14 checks passed
Githab-capibara added a commit to Githab-capibara/open-code-review that referenced this pull request Sep 17, 2026
`.sol` and `.vy` files were rejected by the extension allowlist, so no
review rules could ever run on them. `whyExcluded` checks `IsAllowedExt`
before any rule is resolved, so allowlisting the two extensions is what
makes the new rule docs reachable at all.

Adds `.sol`/`.vy` to supported_file_types.json, routes them to two new
rule docs via path_rule_map, and adds six exclude patterns.

Two rule docs rather than one shared EVM doc: the repo splits rule docs
by language syntax, not by domain (`c.md`/`cpp.md`, `po.md`/`pot.md`).
Vyper checks arithmetic by default and has no inheritance or inline
assembly, so half a shared doc would be wrong on every file it matched.

No `.v.py`: `extFromPath` takes the last dot of the basename, so
`token.v.py` resolves to `.py` and the entry could never be looked up.
Every remaining use of that extension is pre-0.1 viper-era code or a
tool's backward-compat list.

`**/*.t.sol` alone misses the test helpers and mock contracts that carry
no suffix — `test/BaseTest.sol`, `test/foundry/utils/BaseTest.sol` and
`contracts/test/ERC20TestToken.sol` are all real layouts — so
`**/test/**/*.sol` and `**/tests/**/*.sol` cover the directory the way
`**/test/**/*.jl` and `**/tests/**/*.nim` already do for other
languages. `.vy` gets both spellings of the directory for the same
reason.

`lib/**/*.sol` is root-anchored deliberately. `IsExcludedPath` applies
every pattern to every path with no language dispatch, and
`**/lib/**/*.sol` also matches `src/lib/Math.sol` — a project's own
library directory. The test table asserts both directions.

No build-output patterns: `out/`, `artifacts/`, `cache/` and
`typechain-types/` contain no `.sol` or `.vy` files, and are gitignored,
so internal/scan/provider.go's gitignore walk already skips them.

Users can re-admit any of this with `--include`, which `whyExcluded`
checks before `IsExcludedPath`.

The rule table in pages/src/content/docs/{en,ja,ru,zh}/review-rules.md
lists both new patterns.
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