Skip to content

Commit

Permalink
Merge pull request #8232 from hakman/staticcheck-simplify
Browse files Browse the repository at this point in the history
Add code simplifications for staticheck
  • Loading branch information
k8s-ci-robot committed Dec 30, 2019
2 parents e34c12a + 4c4400c commit 388a3cb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions cmd/kops/toolbox_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func runToolBoxTemplate(f *util.Factory, out io.Writer, options *toolboxTemplate
templates = append(templates, list...)
}

snippets := make(map[string]string, 0)
snippets := make(map[string]string)
for _, x := range options.snippetsPath {
list, err := expandFiles(utils.ExpandPath(x))
if err != nil {
Expand Down Expand Up @@ -212,7 +212,7 @@ func runToolBoxTemplate(f *util.Factory, out io.Writer, options *toolboxTemplate

// newTemplateContext is responsible for loading the --values and build a context for the template
func newTemplateContext(files []string, values []string, stringValues []string) (map[string]interface{}, error) {
context := make(map[string]interface{}, 0)
context := make(map[string]interface{})

for _, x := range files {
list, err := expandFiles(utils.ExpandPath(x))
Expand All @@ -225,7 +225,7 @@ func newTemplateContext(files []string, values []string, stringValues []string)
return nil, fmt.Errorf("unable to configuration file: %s, error: %s", j, err)
}

ctx := make(map[string]interface{}, 0)
ctx := make(map[string]interface{})
if err := utils.YamlUnmarshal(content, &ctx); err != nil {
return nil, fmt.Errorf("unable decode the configuration file: %s, error: %v", j, err)
}
Expand Down
3 changes: 1 addition & 2 deletions dns-controller/pkg/watchers/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ func (c *IngressController) updateIngressRecords(ingress *v1beta1.Ingress) strin

fqdn := dns.EnsureDotSuffix(rule.Host)
for _, ingress := range ingresses {
var r dns.Record
r = ingress
r := ingress
r.FQDN = fqdn
records = append(records, r)
}
Expand Down
3 changes: 1 addition & 2 deletions dns-controller/pkg/watchers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ func (c *ServiceController) updateServiceRecords(service *v1.Service) string {

fqdn := dns.EnsureDotSuffix(token)
for _, ingress := range ingresses {
var r dns.Record
r = ingress
r := ingress
r.FQDN = fqdn
records = append(records, r)
}
Expand Down
8 changes: 6 additions & 2 deletions hack/verify-staticcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ FOCUS="${FOCUS%/}"
# See https://staticcheck.io/docs/checks
CHECKS=(
"all"
"-S1*" # Omit code simplifications for now.
"-ST1*" # Mostly stylistic, redundant w/ golint
"-ST1000" # Incorrect or missing package comment
"-ST1003" # Poorly chosen identifier
"-ST1005" # Incorrectly formatted error string
"-ST1006" # Poorly chosen receiver name
"-ST1012" # Poorly chosen name for error variable
"-ST1016" # Use consistent method receiver names
)
export IFS=','; checks="${CHECKS[*]}"; unset IFS

Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/alitasks/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (e *VPC) Find(c *fi.Context) (*VPC, error) {
return nil, fmt.Errorf("error listing VPCs: %v", err)
}

if vpcs == nil || len(vpcs) == 0 {
if len(vpcs) == 0 {
return nil, nil
}

Expand Down
8 changes: 2 additions & 6 deletions upup/pkg/fi/cloudup/openstacktasks/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ func (c *Volume) Find(context *fi.Context) (*Volume, error) {
}
// remove tags "readonly" and "attached_mode", openstack are adding these and if not removed
// kops will always try to update volumes
if _, ok := actual.Tags["readonly"]; ok {
delete(actual.Tags, "readonly")
}
if _, ok := actual.Tags["attached_mode"]; ok {
delete(actual.Tags, "attached_mode")
}
delete(actual.Tags, "readonly")
delete(actual.Tags, "attached_mode")
c.ID = actual.ID
c.AvailabilityZone = actual.AvailabilityZone
return actual, nil
Expand Down

0 comments on commit 388a3cb

Please sign in to comment.