mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-05 04:53:02 +00:00
i dont like commits
This commit is contained in:
@@ -43,6 +43,21 @@ func (d *LargeFileDetector) Detect(ctx context.Context, path string, config *qua
|
||||
for _, file := range files {
|
||||
loc, err := countLines(file)
|
||||
if err != nil {
|
||||
findings = append(findings, quality.Finding{
|
||||
ID: fmt.Sprintf("detector_read_error::large_file::%s", file),
|
||||
Type: "detector_error",
|
||||
Title: "Large file detector could not read file",
|
||||
Description: fmt.Sprintf("Failed to count lines in %s: %v", filepath.Base(file), err),
|
||||
File: file,
|
||||
Line: 1,
|
||||
Severity: quality.SeverityT2,
|
||||
Score: 0,
|
||||
Status: quality.StatusOpen,
|
||||
Metadata: map[string]string{
|
||||
"detector": "large_file",
|
||||
"error": err.Error(),
|
||||
},
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -99,18 +114,21 @@ func (d *GodStructDetector) Detect(ctx context.Context, path string, config *qua
|
||||
|
||||
var findings []quality.Finding
|
||||
for _, file := range files {
|
||||
fileFindings := d.analyzeFile(file)
|
||||
fileFindings, err := d.analyzeFile(file)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("analyze god struct in %q: %w", file, err)
|
||||
}
|
||||
findings = append(findings, fileFindings...)
|
||||
}
|
||||
|
||||
return findings, nil
|
||||
}
|
||||
|
||||
func (d *GodStructDetector) analyzeFile(path string) []quality.Finding {
|
||||
func (d *GodStructDetector) analyzeFile(path string) ([]quality.Finding, error) {
|
||||
fset := token.NewFileSet()
|
||||
node, err := parser.ParseFile(fset, path, nil, 0)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, fmt.Errorf("parse %s: %w", path, err)
|
||||
}
|
||||
|
||||
methodCounts := make(map[string]int)
|
||||
@@ -198,7 +216,7 @@ func (d *GodStructDetector) analyzeFile(path string) []quality.Finding {
|
||||
}
|
||||
}
|
||||
|
||||
return findings
|
||||
return findings, nil
|
||||
}
|
||||
|
||||
type DebugLogDetector struct {
|
||||
@@ -227,22 +245,25 @@ func (d *DebugLogDetector) Detect(ctx context.Context, path string, config *qual
|
||||
|
||||
var findings []quality.Finding
|
||||
for _, file := range files {
|
||||
fileFindings := d.analyzeFile(file)
|
||||
fileFindings, err := d.analyzeFile(file)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("analyze debug logs in %q: %w", file, err)
|
||||
}
|
||||
findings = append(findings, fileFindings...)
|
||||
}
|
||||
|
||||
return findings, nil
|
||||
}
|
||||
|
||||
func (d *DebugLogDetector) analyzeFile(path string) []quality.Finding {
|
||||
func (d *DebugLogDetector) analyzeFile(path string) ([]quality.Finding, error) {
|
||||
fset := token.NewFileSet()
|
||||
node, err := parser.ParseFile(fset, path, nil, 0)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, fmt.Errorf("parse %s: %w", path, err)
|
||||
}
|
||||
normPath := filepath.ToSlash(path)
|
||||
if strings.Contains(normPath, "internal/ui/") || strings.Contains(normPath, "examples/") {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
debugPatterns := []string{
|
||||
@@ -324,7 +345,7 @@ func (d *DebugLogDetector) analyzeFile(path string) []quality.Finding {
|
||||
return true
|
||||
})
|
||||
|
||||
return findings
|
||||
return findings, nil
|
||||
}
|
||||
|
||||
type GodFunctionDetector struct {
|
||||
|
||||
Reference in New Issue
Block a user