Skip to content

Conversation

@MikaelVallenet
Copy link
Member

@MikaelVallenet MikaelVallenet commented Jan 17, 2026

fix #4421 & fix #1042

Summary

This PR adds an extensible linting framework to gno lint. You can now write pluggable rules, choose different
output formats, and suppress warnings with //nolint comments.

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, error
  • Rule interface - implement this to create your own lint rules
  • RuleContext - gives rules access to the file, source code, and parent nodes
  • Registry - handles rule registration (rules self-register via init())
  • Config - controls mode and which rules to disable
  • NolintParser - reads //nolint comments to suppress specific issues

Reporters (how output gets formatted):

  • TextReporter - human-friendly output, sorted by file/line, with a summary at the end
  • JSONReporter - machine-readable JSON array for tooling integration
  • DirectReporter - prints issues immediately as they're found (used by gno test)

Built-in rules:

  • AVL001 - warns when you iterate an entire AVL tree without bounds (tree.Iterate("", "", ...))
  • GLOBAL001 - warns about exported package-level variables (like var Counter int)

CLI Changes (gnovm/cmd/gno/lint.go)

New flags:

  • --mode - choose between default, strict, or warn-only
  • --format - output as text or json
  • --list-rules - shows all available rules and exits
  • --disable-rules - skip specific rules (e.g., --disable-rules=AVL001,GLOBAL001)

Output format changed:
Before

  file.gno:10:5: some message (code=someCode)

After

  file.gno:10:5: warning: some message (AVL001)

Docs

  • Added docs/resources/gno-lint.md with usage examples, rule descriptions, and a guide for writing new rules

Tests

  • Unit tests for everything in gnovm/pkg/lint/
  • Integration tests (txtar format) covering AVL001, GLOBAL001, nolint directives, and mode flags

Breaking Changes

Output format - The lint output now includes severity and uses a different format (see above)

Exit codes - Now depend on the mode:

Mode Exits with 1 when...
default there are errors
strict there are any issues (warnings become errors)
warn-only never (errors become warnings)

@github-actions github-actions bot added 📖 documentation Improvements or additions to documentation 📦 🤖 gnovm Issues or PRs gnovm related labels Jan 17, 2026
@Gno2D2 Gno2D2 requested a review from a team January 17, 2026 16:19
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 17, 2026

🛠 PR Checks Summary

🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff
🔴 Pending initial approval by a review team member, or review from tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
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)
🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff
🔴 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: MikaelVallenet/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 A changed file matches this pattern: ^docs/ (filename: docs/resources/gno-lint.md)

Then

🔴 Requirement not satisfied
└── 🔴 And
    ├── 🔴 Or
    │   ├── 🔴 Pull request author is a member of the team: tech-staff
    │   └── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request(with state "APPROVED")
    └── 🔴 Or
        ├── 🔴 Pull request author is a member of the team: devrels
        └── 🔴 At least 1 user(s) of the team devrels reviewed pull request(with state "APPROVED")

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🔴 Requirement not satisfied
└── 🔴 If
    ├── 🔴 Condition
    │   └── 🔴 Or
    │       ├── 🔴 At least one of these user(s) reviewed the pull request: [jefft0 notJoon omarsy MikaelVallenet] (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🔴 Else
        └── 🔴 And
            ├── 🟢 This label is applied to pull request: review/triage-pending
            └── 🔴 On no pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@codecov
Copy link

codecov bot commented Jan 17, 2026

@MikaelVallenet MikaelVallenet marked this pull request as ready for review January 20, 2026 13:10
@MikaelVallenet MikaelVallenet requested a review from moonia January 20, 2026 13:10
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📖 documentation Improvements or additions to documentation 📦 🤖 gnovm Issues or PRs gnovm related review/triage-pending PRs opened by external contributors that are waiting for the 1st review

Projects

Status: No status

2 participants