Skip to content

Commit

Permalink
all, checks.bash: restore unparam check
Browse files Browse the repository at this point in the history
Restore the check for unused parameters and remove unused parameters
found by the check.

Change-Id: I80fe9b1cab507eeae8eb1f27e2395824330868c5
Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/551436
Reviewed-by: Damien Neil <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
tatianab committed Dec 19, 2023
1 parent d361dd1 commit ba00fcf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions checks.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ check_headers() {
# check_unparam runs unparam on source files.
check_unparam() {
ensure_go_binary mvdan.cc/unparam
# Temporarily exclude until updated for Go 1.20.
# runcmd unparam ./...
runcmd unparam ./...
}

# check_vet runs go vet on source files.
Expand Down
5 changes: 2 additions & 3 deletions cmd/cve/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ only update now if this warning is spurious (i.e., the records were deleted on p
return false
}

cveFile := fmt.Sprintf("data/cve/%s.json", goID)
if err := addMissing(yamlReportFile, cveFile, deleted); err != nil {
if err := addMissing(yamlReportFile, deleted); err != nil {
fmt.Println("ERROR: could not add missing refs: ", err)
return false
}
Expand All @@ -412,7 +411,7 @@ only update now if this warning is spurious (i.e., the records were deleted on p
return true
}

func addMissing(yamlFile, cveFile string, missing []string) error {
func addMissing(yamlFile string, missing []string) error {
r, err := report.Read(yamlFile)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/forks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Score struct {
Score int // 0 - 10
}

func run(ctx context.Context) error {
func run(_ context.Context) error {
if flag.NArg() == 0 {
flag.Usage()
return nil
Expand Down
4 changes: 2 additions & 2 deletions internal/report/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func (s *Summary) lint(l *linter, r *Report) {
// If there are no such paths listed in the report at all,
// another lint will complain, so reduce noise by not erroring here.
if paths := r.nonStdPaths(); len(paths) > 0 {
if ok := containsPath(l, summary, paths); !ok {
if ok := containsPath(summary, paths); !ok {
l.Errorf("must contain an affected module or package path (e.g. %q)", paths[0])
}
}
Expand All @@ -324,7 +324,7 @@ func (s *Summary) lint(l *linter, r *Report) {
// and is a prefix of a path, the function returns true. This gives us a
// workaround for reports that affect a lot of modules and/or have very long
// module paths.
func containsPath(l *linter, summary string, paths []string) bool {
func containsPath(summary string, paths []string) bool {
if len(paths) == 0 {
return false
}
Expand Down
6 changes: 3 additions & 3 deletions internal/symbols/vuln_entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func vulnEntries(pkgs []*packages.Package, m *report.Module) ([]*ssa.Function, e

// Identify vulnerable functions/methods in the call graph and
// compute the backwards reachable entries.
entryNodes := vulnReachingEntries(cg, vulnFuncs(cg, m), entries)
entryNodes := vulnReachingEntries(vulnFuncs(cg, m), entries)
var vres []*ssa.Function
for _, n := range entryNodes {
vres = append(vres, n.Func)
Expand Down Expand Up @@ -80,9 +80,9 @@ func vulnFuncs(cg *callgraph.Graph, m *report.Module) []*callgraph.Node {
return vfs
}

// vulnReachingEntries returns call graph nodes of cg corresponding to allEntries
// vulnReachingEntries returns call graph nodes corresponding to allEntries
// that are backwards reachable from sinks.
func vulnReachingEntries(cg *callgraph.Graph, sinks []*callgraph.Node, allEntries []*ssa.Function) []*callgraph.Node {
func vulnReachingEntries(sinks []*callgraph.Node, allEntries []*ssa.Function) []*callgraph.Node {
allEs := make(map[*ssa.Function]bool)
for _, e := range allEntries {
allEs[e] = true
Expand Down

0 comments on commit ba00fcf

Please sign in to comment.