diff --git a/.claude/commands/sniff-test.md b/.claude/commands/sniff-test.md new file mode 100644 index 000000000..4eb5f2f73 --- /dev/null +++ b/.claude/commands/sniff-test.md @@ -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. diff --git a/pkg/generator/asset_generator.go b/pkg/generator/asset_generator.go index 1f6eb4b1d..a295e5ec1 100644 --- a/pkg/generator/asset_generator.go +++ b/pkg/generator/asset_generator.go @@ -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 @@ -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++