-
Notifications
You must be signed in to change notification settings - Fork 445
feat(gnovm): add extensible linting framework with AVL001 and GLOBAL001 rules #5068
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
base: master
Are you sure you want to change the base?
feat(gnovm): add extensible linting framework with AVL001 and GLOBAL001 rules #5068
Conversation
🛠 PR Checks Summary🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
fix #4421 & fix #1042
Summary
This PR adds an extensible linting framework to
gno lint. You can now write pluggable rules, choose differentoutput formats, and suppress warnings with
//nolintcomments.What's New
New Lint Package (
gnovm/pkg/lint/)Core stuff:
Issue- represents a single lint finding (severity, location, message)Severity- three levels: info, warning, errorRuleinterface - implement this to create your own lint rulesRuleContext- gives rules access to the file, source code, and parent nodesRegistry- handles rule registration (rules self-register viainit())Config- controls mode and which rules to disableNolintParser- reads//nolintcomments to suppress specific issuesReporters (how output gets formatted):
TextReporter- human-friendly output, sorted by file/line, with a summary at the endJSONReporter- machine-readable JSON array for tooling integrationDirectReporter- prints issues immediately as they're found (used bygno test)Built-in rules:
AVL001- warns when you iterate an entire AVL tree without bounds (tree.Iterate("", "", ...))GLOBAL001- warns about exported package-level variables (likevar Counter int)CLI Changes (
gnovm/cmd/gno/lint.go)New flags:
--mode- choose betweendefault,strict, orwarn-only--format- output astextorjson--list-rules- shows all available rules and exits--disable-rules- skip specific rules (e.g.,--disable-rules=AVL001,GLOBAL001)Output format changed:
Before
After
Docs
docs/resources/gno-lint.mdwith usage examples, rule descriptions, and a guide for writing new rulesTests
gnovm/pkg/lint/Breaking Changes
Output format - The lint output now includes severity and uses a different format (see above)
Exit codes - Now depend on the mode:
defaultstrictwarn-only