Skip to content

Commit 1f54bba

Browse files
committed
Fix majority of oustanding linting issues after v2 migration
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent b893262 commit 1f54bba

12 files changed

Lines changed: 37 additions & 39 deletions

File tree

.golangci.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ linters:
1717
errcheck:
1818
exclude-functions:
1919
- io.Close
20-
- github.com/spf13/pflag.MarkHidden
20+
- (*github.com/spf13/pflag.FlagSet).MarkHidden
2121
- github.com/spf13/viper.BindEnv
2222
- github.com/spf13/viper.BindPFlag
23-
- github.com/spf13/cobra.Help
24-
- github.com/spf13/cobra.MarkFlagRequired
25-
- github.com/spf13/cobra.Usage
23+
- github.com/spf13/viper.BindPFlags
24+
- (*github.com/spf13/cobra.Command).Help
25+
- (*github.com/spf13/cobra.Command).MarkFlagRequired
26+
- (*github.com/spf13/cobra.Command).Usage
2627
- (github.com/segmentio/analytics-go/v3.Client).Enqueue
27-
- database/sql.Rollback
28-
- github.com/nats-io/nats.go.Unsubscribe
28+
- (*database/sql.Tx).Rollback
29+
- (*github.com/nats-io/nats.go.Subscription).Unsubscribe
30+
revive:
31+
rules:
32+
- name: unused-parameter
33+
disabled: true
2934
staticcheck:
3035
checks:
3136
- all
3237
- "-ST1005" # ignore the "ST1005: error strings should not be capitalized" check
38+
- "-QF1008" # ignore omit embedded fields from selector expression
3339
exclusions:
3440
generated: lax
3541
presets:

src/cloud/auth/controllers/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func (s *Server) Signup(ctx context.Context, in *authpb.SignupRequest) (*authpb.
385385
if !utils.IsNilUUIDProto(inviteOrgID) {
386386
orgInfoPb, err := s.env.OrgClient().GetOrg(ctx, inviteOrgID)
387387
if err != nil {
388-
return nil, status.Errorf(codes.Internal, err.Error())
388+
return nil, status.Error(codes.Internal, err.Error())
389389
}
390390
if orgInfoPb == nil {
391391
return nil, status.Errorf(codes.InvalidArgument, "misformatted invite link")

src/cloud/shared/vzshard/vzshard.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ func ShardMax() string {
5757

5858
// GenerateShardRange shard range produces the hex values 00-ff for the shards as configured.
5959
func GenerateShardRange() []string {
60-
min := minShard()
61-
max := maxShard()
62-
r := make([]string, max-min+1)
63-
for i := min; i <= max; i++ {
64-
r[i-min] = shardIntToHex(i)
60+
minS := minShard()
61+
maxS := maxShard()
62+
r := make([]string, maxS-minS+1)
63+
for i := minS; i <= maxS; i++ {
64+
r[i-minS] = shardIntToHex(i)
6565
}
6666
return r
6767
}

src/pixie_cli/pkg/utils/cli_out.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (c *CLIOutputEntry) Infof(format string, args ...interface{}) {
121121

122122
// Info prints the input string to stdout.
123123
func (c *CLIOutputEntry) Info(str string) {
124-
c.Infof(str)
124+
c.Infof("%s", str)
125125
}
126126

127127
// Errorf prints the input string to stderr formatted with the input args.
@@ -131,7 +131,7 @@ func (c *CLIOutputEntry) Errorf(format string, args ...interface{}) {
131131

132132
// Error prints the input string to stderr.
133133
func (c *CLIOutputEntry) Error(str string) {
134-
c.write(os.Stderr, str)
134+
c.write(os.Stderr, "%s", str)
135135
}
136136

137137
// Fatalf prints the input string to stderr formatted with the input args.
@@ -142,6 +142,6 @@ func (c *CLIOutputEntry) Fatalf(format string, args ...interface{}) {
142142

143143
// Fatal prints the input string to stderr.
144144
func (c *CLIOutputEntry) Fatal(str string) {
145-
c.write(os.Stderr, str)
145+
c.write(os.Stderr, "%s", str)
146146
os.Exit(1)
147147
}

src/pixie_cli/pkg/vizier/stream_adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func (v *StreamOutputAdapter) handleStream(ctx context.Context, stream chan *Exe
254254
case *vizierpb.ExecuteScriptResponse_Data:
255255
err = v.handleData(ctx, res)
256256
default:
257-
err = fmt.Errorf("unhandled response type" + reflect.TypeOf(msg.Resp.Result).String())
257+
err = fmt.Errorf("unhandled response type %s", reflect.TypeOf(msg.Resp.Result).String())
258258
}
259259
if err != nil {
260260
v.err = newScriptExecutionError(CodeBadData, "failed to handle data from Vizier: "+err.Error())

src/stirling/demo_apps/go_http/server/simple_http_server.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ func randStringRunes(n int) string {
6868
return string(b)
6969
}
7070

71-
func min(x, y int64) int64 {
72-
if x < y {
73-
return x
74-
}
75-
return y
76-
}
77-
7871
func fakeLoad(w *http.ResponseWriter, latency float64, mIters, respSize int64) float64 {
7972
// add some jitters
8073
// latency = rand.NormFloat64()*latency/10 + latency

src/stirling/demo_apps/wrk_sweeper/wrk_sweeper.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,24 @@ func parseSpec(spec string) SequenceGenerator {
117117
linRegex := regexp.MustCompile(`lin\((\d+), \s*(\d+),\s*(\d+)\)`)
118118
expMatches := expRegex.FindStringSubmatch(spec)
119119
if len(expMatches) == 4 {
120-
min := parseOrDie(expMatches[1])
121-
max := parseOrDie(expMatches[2])
120+
minSeq := parseOrDie(expMatches[1])
121+
maxSeq := parseOrDie(expMatches[2])
122122
base := parseOrDie(expMatches[3])
123123
return &expSequenceGenerator{
124-
Min: min,
125-
Max: max,
124+
Min: minSeq,
125+
Max: maxSeq,
126126
Base: base,
127127
}
128128
}
129129

130130
linMatches := linRegex.FindStringSubmatch(spec)
131131
if len(linMatches) == 4 {
132-
min := parseOrDie(linMatches[1])
133-
max := parseOrDie(linMatches[2])
132+
minSeq := parseOrDie(linMatches[1])
133+
maxSeq := parseOrDie(linMatches[2])
134134
step := parseOrDie(linMatches[3])
135135
return &linSequenceGenerator{
136-
Min: min,
137-
Max: max,
136+
Min: minSeq,
137+
Max: maxSeq,
138138
Step: step,
139139
}
140140
}

src/utils/erroraccumulator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (ea *ErrorAccumulator) Merge() error {
4545
if len(ea.errorStrs) == 0 {
4646
return nil
4747
}
48-
return fmt.Errorf(indent(strings.Join(ea.errorStrs, "\n")))
48+
return fmt.Errorf("%s", indent(strings.Join(ea.errorStrs, "\n")))
4949
}
5050

5151
// MakeErrorAccumulator constructs the ErrorAccumulator.

src/utils/shared/k8s/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func GetResourcesFromYAML(yamlFile io.Reader) ([]*Resource, error) {
163163

164164
_, gvk, err := unstructured.UnstructuredJSONScheme.Decode(ext.Raw, nil, nil)
165165
if err != nil {
166-
log.WithError(err).Fatalf(err.Error())
166+
log.WithError(err).Fatal(err.Error())
167167
return nil, err
168168
}
169169

src/vizier/services/metadata/metadata_server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ func cleanupOldPebbleData() {
138138
func mustInitPebbleDatastore() *pebbledb.DataStore {
139139
cleanupOldPebbleData()
140140
log.Infof("Using pebbledb: %s for metadata", pebbleOpenDir)
141-
pebbleDb, err := pebble.Open(pebbleOpenDir, &pebble.Options{})
141+
pebbleDB, err := pebble.Open(pebbleOpenDir, &pebble.Options{})
142142
if err != nil {
143143
log.WithError(err).Fatal("Failed to open pebble database. If out of space, increase the storage size of the `metadata-pv-claim` PersistentVolumeClaim and restart the vizier-metadata pod")
144144
}
145-
return pebbledb.New(pebbleDb, pebbledbTTLDuration)
145+
return pebbledb.New(pebbleDB, pebbledbTTLDuration)
146146
}
147147

148148
func etcdTLSConfig() (*tls.Config, error) {

0 commit comments

Comments
 (0)