-
Notifications
You must be signed in to change notification settings - Fork 28
Add automated error message quality linter #4078
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
Conversation
- Create scripts/lint_error_messages.go with AST-based error detection - Add comprehensive tests in scripts/lint_error_messages_test.go - Add lint-errors target to Makefile - Integrate linter into CI workflow (.github/workflows/ci.yml) - Baseline compliance: 89% (705/786 error messages compliant) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Document error message template and guidelines - Reference error message style guide - Include examples of good and bad error messages - Mention lint-errors command Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot lint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements an automated error message quality linter to enforce the error message style guide template: [what's wrong]. [what's expected]. [example]. The linter uses AST-based parsing to extract error messages from Go code, validates them against quality criteria, and reports compliance metrics. Currently, 89% (705/786) of error messages comply with the standard.
Key Changes
- AST-based linter with configurable compliance threshold (default 80%)
- CI integration to prevent non-compliant error messages from being merged
- Comprehensive documentation in CONTRIBUTING.md with error message guidelines and examples
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/lint_error_messages.go | New linter implementation with AST parsing, regex-based validation, and suggestion generation |
| scripts/lint_error_messages_test.go | Comprehensive test suite covering error quality detection, skip logic, suggestions, and pattern matching |
| Makefile | Added lint-errors target for running the linter |
| .github/workflows/ci.yml | Integrated linter into CI lint job |
| CONTRIBUTING.md | Added error message style guide section with examples and best practices |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
scripts/lint_error_messages.go
Outdated
| // Patterns to detect good error messages | ||
| hasExample = regexp.MustCompile(`(?i)\bexample:\s`) | ||
| hasExpected = regexp.MustCompile(`(?i)\b(expected|valid|must be|should be)\b`) | ||
| hasTypeInfo = regexp.MustCompile(`%[TvdsFfgGeExXbcqpoUq]`) |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hasTypeInfo regex pattern is defined but never used in the code. Consider removing this unused variable or documenting its intended future use.
| hasTypeInfo = regexp.MustCompile(`%[TvdsFfgGeExXbcqpoUq]`) |
- Remove unused hasTypeInfo variable - Check fmt.Sscanf error return with proper handling - Add warning message for invalid threshold values Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Task: Create Automated Error Message Quality Linter ✅
Successfully created an automated linter to check error messages for compliance with the error message style guide.
✅ All Acceptance Criteria Met
make lint-errorsmake lint-errorssuccessfully with baseline threshold set appropriately📊 Baseline Statistics
🔧 Implementation
Files Created:
scripts/lint_error_messages.go- Main linter implementationscripts/lint_error_messages_test.go- Comprehensive test suiteFiles Modified:
Makefile- Addedlint-errorstarget and help text.github/workflows/ci.yml- Added linter step to CI pipelineCONTRIBUTING.md- Documented error message standardsRecent Fixes
Commit: Fix linter issues
hasTypeInfovariablefmt.Sscanfreturn value🚀 Usage
🧪 Testing
All tests passing:
make test-unit✅go test scripts/lint_error_messages_test.go✅make lint✅Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.