mirror of
https://github.com/securego/gosec.git
synced 2025-01-12 04:45:53 +00:00
Fix error parsing from package
Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
parent
92b3644625
commit
b04c1ce0a7
1 changed files with 4 additions and 2 deletions
|
@ -199,7 +199,7 @@ func (gosec *Analyzer) parseErrors(pkg *packages.Package) error {
|
|||
var err error
|
||||
var line, column int
|
||||
var errorMsg string
|
||||
if len(infoErr) == 3 {
|
||||
if len(infoErr) == 4 {
|
||||
if line, err = strconv.Atoi(infoErr[1]); err != nil {
|
||||
return fmt.Errorf("parsing line: %v", err)
|
||||
}
|
||||
|
@ -207,8 +207,10 @@ func (gosec *Analyzer) parseErrors(pkg *packages.Package) error {
|
|||
return fmt.Errorf("parsing column: %v", err)
|
||||
}
|
||||
errorMsg = strings.TrimSpace(infoErr[3])
|
||||
} else {
|
||||
} else if len(infoErr) > 1 {
|
||||
errorMsg = strings.TrimSpace(infoErr[1])
|
||||
} else {
|
||||
return fmt.Errorf("cannot parse error %q", infoErr)
|
||||
}
|
||||
newErr := NewError(line, column, errorMsg)
|
||||
if errSlice, ok := gosec.errors[filePath]; ok {
|
||||
|
|
Loading…
Reference in a new issue