-
Notifications
You must be signed in to change notification settings - Fork 313
Open
2 / 22 of 2 issues completedOpen
2 / 22 of 2 issues completed
Copy link
Labels
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.
Details
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
chavacava