Extend rules documentation with before/after code blocks and real use cases
#1,498 opened on Aug 29, 2025
Repository metrics
- Stars
- (5,517 stars)
- PR merge metrics
- (PR metrics pending)
Description
Currently, RULES_DESCRIPTIONS.md provides descriptions of rules but lacks practical examples. This makes it harder for developers to quickly understand the impact of enabling a rule.
Proposal
- Add short before/after code blocks to every rule in RULES_DESCRIPTIONS.md. Can be similar to "Before/After" in go-critic.
- Where possible, include real use cases of fixing such rules in well-known Open Source codebases.
- Ensure examples are minimal but illustrative, showing both the violation and the corrected version.
This will make the documentation more practical, reduce ambiguity, and help developers adopt Revive more effectively.
Example
Below is a proposed format for use-any description.
use-any
Description
Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any to follow modern Go conventions introduced with generics.
Configuration
N/A
Examples
Before (violation):
func PrintValue(v interface{}) {
fmt.Println(v)
}
After (fixed):
func PrintValue(v any) {
fmt.Println(v)
}
Real-world use cases