Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
Fixes the following errors:
cmd/certificate_info_table.go:29:40: printf: non-constant format string in call to (*github.com/fatih/color.Color).Sprintf (govet)
		Title: color.New(color.Bold).Sprintf(color.YellowString("CERTIFICATE EXPIRY DATE INFORMATION")),
		                                     ^
cmd/certificate_info_table_test.go:33:66: printf: non-constant format string in call to (*github.com/fatih/color.Color).Sprintf (govet)
			Expect(ui.Table.Title).To(Equal(color.New(color.Bold).Sprintf(color.YellowString("CERTIFICATE EXPIRY DATE INFORMATION"))))
			                                                              ^
cmd/environment_test.go:181:43: printf: non-constant format string in call to (*github.com/fatih/color.Color).Sprintf (govet)
					Title: color.New(color.Bold).Sprintf(color.YellowString("CERTIFICATE EXPIRY DATE INFORMATION")),
					                                     ^
deployment/vm/vm.go:27:1: SA9009: ineffectual compiler directive due to extraneous space: "// go:generate counterfeiter . VM" (staticcheck)
// go:generate counterfeiter . VM
^
director/config_diff.go:51:34: printf: non-constant format string in call to github.com/cloudfoundry/bosh-utils/errors.Errorf (govet)
					return resp, bosherr.Errorf(errorDescription[1])
					                            ^
director/config_diff.go:53:34: printf: non-constant format string in call to github.com/cloudfoundry/bosh-utils/errors.Errorf (govet)
					return resp, bosherr.Errorf(err.Error())
					                            ^
ssh/host.go:66:6: S1009: should omit nil check; len() for []string is defined as zero (gosimple)
		if targetVM.IPs == nil || len(targetVM.IPs) == 0 {
		   ^
ui/table/writer.go:140:32: printf: non-constant format string in call to fmt.Fprintf (govet)
				_, err := fmt.Fprintf(w.w, w.borderStr)
				                           ^
ui/table/writer.go:145:32: printf: non-constant format string in call to fmt.Fprintf (govet)
				_, err := fmt.Fprintf(w.w, strings.Repeat(w.bgStr, paddingSize)+w.borderStr)

Signed-off-by: Nitin Ravindran <[email protected]>
  • Loading branch information
selzoc authored and xtreme-nitin-ravindran committed Aug 13, 2024
1 parent 73b4202 commit f6d499e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/certificate_info_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (t CertificateInfoTable) Print() {
}

table := boshtbl.Table{
Title: color.New(color.Bold).Sprintf(color.YellowString("CERTIFICATE EXPIRY DATE INFORMATION")),
Title: color.New(color.Bold, color.FgYellow).Sprint("CERTIFICATE EXPIRY DATE INFORMATION"),
Header: []boshtbl.Header{
boshtbl.NewHeader("Certificate"),
boshtbl.NewHeader("Expiry Date (UTC)"),
Expand Down
2 changes: 1 addition & 1 deletion cmd/certificate_info_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var _ = Describe("CertificateInfoTable", func() {

cmd.CertificateInfoTable{Certificates: certsInfo, UI: ui}.Print()

Expect(ui.Table.Title).To(Equal(color.New(color.Bold).Sprintf(color.YellowString("CERTIFICATE EXPIRY DATE INFORMATION"))))
Expect(ui.Table.Title).To(Equal(color.New(color.Bold, color.FgYellow).Sprint("CERTIFICATE EXPIRY DATE INFORMATION")))
Expect(ui.Table.Header).To(Equal([]boshtbl.Header{
boshtbl.NewHeader("Certificate"),
boshtbl.NewHeader("Expiry Date (UTC)"),
Expand Down
2 changes: 1 addition & 1 deletion cmd/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ var _ = Describe("EnvironmentCmd", func() {
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(ui.Table).To(Equal(boshtbl.Table{
Title: color.New(color.Bold).Sprintf(color.YellowString("CERTIFICATE EXPIRY DATE INFORMATION")),
Title: color.New(color.Bold, color.FgYellow).Sprint("CERTIFICATE EXPIRY DATE INFORMATION"),
Header: []boshtbl.Header{
boshtbl.NewHeader("Certificate"),
boshtbl.NewHeader("Expiry Date (UTC)"),
Expand Down
3 changes: 2 additions & 1 deletion deployment/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type Clock interface {
Now() time.Time
}

// go:generate counterfeiter . VM
// You only need **one** of these per package!
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate

type VM interface {
CID() string
Expand Down
4 changes: 2 additions & 2 deletions director/config_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func (c Client) postConfigDiff(path string, manifest []byte, setHeaders func(*ht
var descriptionExp = regexp.MustCompile(`description":"(.+?)"`)
errorDescription := descriptionExp.FindStringSubmatch(err.Error())
if len(errorDescription) > 0 {
return resp, bosherr.Errorf(errorDescription[1])
return resp, bosherr.Error(errorDescription[1])
} else {
return resp, bosherr.Errorf(err.Error())
return resp, bosherr.Error(err.Error())
}
} else {
// endpoint couldn't be found => return empty diff, just for compatibility with directors which don't have the endpoint
Expand Down
2 changes: 1 addition & 1 deletion ssh/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (h *hostBuilder) BuildHost(slug boshdir.AllOrInstanceGroupOrInstanceSlug, u
if targetVM.JobName == "" {
return boshdir.Host{}, bosherr.Errorf("Instance %s has no active VM", slug)
}
if targetVM.IPs == nil || len(targetVM.IPs) == 0 {
if len(targetVM.IPs) == 0 {
return boshdir.Host{}, bosherr.Errorf("VM %s has no IP address", targetVM.VMID)
}
targetHost = targetVM.IPs[0]
Expand Down
4 changes: 2 additions & 2 deletions ui/table/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ func (w *Writer) Flush() error {

paddingSize := w.widths[colIdx] - len(col.String)
if colIdx == lastColIdx {
_, err := fmt.Fprintf(w.w, w.borderStr)
_, err := fmt.Fprint(w.w, w.borderStr)
if err != nil {
return err
}
} else {
_, err := fmt.Fprintf(w.w, strings.Repeat(w.bgStr, paddingSize)+w.borderStr)
_, err := fmt.Fprint(w.w, strings.Repeat(w.bgStr, paddingSize)+w.borderStr)
if err != nil {
return err
}
Expand Down

0 comments on commit f6d499e

Please sign in to comment.