Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .claude/commands/sniff-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Review code for quality issues, bad patterns, and code smells.

This command accepts a file path or commit hash as an argument to analyze for code quality issues.
Usage: `/sniff-test path/to/file.go` or `/sniff-test commit-hash`

The command will analyze the code for:
- Bad patterns or anti-patterns
- Unnecessary or dead code
- Unreferenced functions or variables
- Code duplication
- Functions that should be simplified or refactored
- API fields missing documentation
- Hardcoded values that should be constants
- Unhelpful or misleading comments
- Missing error handling
- Performance issues
- Security vulnerabilities
- Inconsistent naming conventions
- Missing unit tests for public functions

Steps:
1. Determine if the argument is a file path or commit hash
2. If it's a commit hash, get the list of changed files in that commit
3. For each file to analyze:
- Read the file content
- Perform static analysis looking for code smells
- Check for Go-specific issues like inefficient patterns
- Look for missing documentation on exported types/functions
- Identify hardcoded values that could be constants
- Check for unused imports, variables, or functions
- Look for duplicated code blocks
- Analyze function complexity and suggest simplifications
4. Generate a comprehensive report with:
- Summary of issues found
- Specific line numbers and explanations
- Suggested improvements
- Severity levels (critical, major, minor)
- Best practice recommendations

For Go files, pay special attention to:
- Proper error handling patterns
- Efficient slice/map operations
- Context usage in functions
- Interface design
- Goroutine and channel usage
- Memory allocation patterns
- API design and documentation

The analysis should be constructive and educational, explaining why certain patterns are problematic and how to improve them.
4 changes: 2 additions & 2 deletions pkg/generator/asset_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (gen *AssetGenerator) generateDriverMetricsService(serviceYAML, serviceMoni
return nil
}

func (gen *AssetGenerator) generateSidecarMetricsServices(serviceYAML, serviceMonitorYAML *YAMLWithHistory, localPortStart, exposedPortStart int, sidecars []SidecarConfig, servicePerfix string) error {
func (gen *AssetGenerator) generateSidecarMetricsServices(serviceYAML, serviceMonitorYAML *YAMLWithHistory, localPortStart, exposedPortStart int, sidecars []SidecarConfig, servicePrefix string) error {
localPortIndex := localPortStart
exposedPortIndex := exposedPortStart

Expand All @@ -207,7 +207,7 @@ func (gen *AssetGenerator) generateSidecarMetricsServices(serviceYAML, serviceMo
"${LOCAL_METRICS_PORT}", strconv.Itoa(localPortIndex),
"${EXPOSED_METRICS_PORT}", strconv.Itoa(exposedPortIndex),
"${PORT_NAME}", sidecar.MetricPortName,
"${SERVICE_PREFIX}", servicePerfix,
"${SERVICE_PREFIX}", servicePrefix,
}
localPortIndex++
exposedPortIndex++
Expand Down