Fix lint and fail on error in the ci build

This commit is contained in:
Matthieu MOREL
2021-05-31 10:44:12 +02:00
committed by GitHub
parent dbb9811e62
commit 1256f16f33
51 changed files with 218 additions and 203 deletions

View File

@@ -120,7 +120,7 @@ var (
// stdout the results as well as write it in the output file
flagStdOut = flag.Bool("stdout", false, "Stdout the results as well as write it in the output file")
//print the text report with color, this is enabled by default
// print the text report with color, this is enabled by default
flagColor = flag.Bool("color", true, "Prints the text format report with colorization when it goes in the stdout")
// overrides the output format when stdout the results while saving them in the output file
@@ -209,7 +209,7 @@ func getRootPaths(paths []string) []string {
}
func getPrintedFormat(format string, verbose string) string {
var fileFormat = format
fileFormat := format
if format != "" && verbose != "" {
fileFormat = verbose
}
@@ -217,7 +217,6 @@ func getPrintedFormat(format string, verbose string) string {
}
func printReport(format string, color bool, rootPaths []string, reportInfo *gosec.ReportInfo) error {
err := report.CreateReport(os.Stdout, format, color, rootPaths, reportInfo)
if err != nil {
return err
@@ -226,7 +225,6 @@ func printReport(format string, color bool, rootPaths []string, reportInfo *gose
}
func saveReport(filename, format string, rootPaths []string, reportInfo *gosec.ReportInfo) error {
outfile, err := os.Create(filename)
if err != nil {
return err
@@ -386,7 +384,7 @@ func main() {
reportInfo := gosec.NewReportInfo(issues, metrics, errors).WithVersion(Version)
if *flagOutput == "" || *flagStdOut {
var fileFormat = getPrintedFormat(*flagOutput, *flagVerbose)
fileFormat := getPrintedFormat(*flagOutput, *flagVerbose)
if err := printReport(fileFormat, *flagColor, rootPaths, reportInfo); err != nil {
logger.Fatal((err))
}

View File

@@ -12,7 +12,6 @@ import (
func extractLineNumber(s string) int {
lineNumber, _ := strconv.Atoi(strings.Split(s, "-")[0])
return lineNumber
}
type sortBySeverity []*gosec.Issue

View File

@@ -26,11 +26,13 @@ import (
"strings"
)
type command func(args ...string)
type utilities struct {
commands map[string]command
call []string
}
type (
command func(args ...string)
utilities struct {
commands map[string]command
call []string
}
)
// Custom commands / utilities to run instead of default analyzer
func newUtils() *utilities {
@@ -58,7 +60,6 @@ func (u *utilities) String() string {
func (u *utilities) Set(opt string) error {
if _, ok := u.commands[opt]; !ok {
return fmt.Errorf("valid tools are: %s", u.String())
}
u.call = append(u.call, opt)
return nil
@@ -171,7 +172,6 @@ func checkContext(ctx *context, file string) bool {
}
func dumpCallObj(files ...string) {
for _, file := range files {
if shouldSkip(file) {
continue
@@ -184,9 +184,9 @@ func dumpCallObj(files ...string) {
var obj types.Object
switch node := n.(type) {
case *ast.Ident:
obj = context.info.ObjectOf(node) //context.info.Uses[node]
obj = context.info.ObjectOf(node) // context.info.Uses[node]
case *ast.SelectorExpr:
obj = context.info.ObjectOf(node.Sel) //context.info.Uses[node.Sel]
obj = context.info.ObjectOf(node.Sel) // context.info.Uses[node.Sel]
default:
obj = nil
}