Skip to content

Commit e79701e

Browse files
authored
Merge pull request #1368 from Adirio/go-report-card
Fix issues raised by Go Report Card
2 parents 83afe04 + ed8438e commit e79701e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+156
-86
lines changed

cmd/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (o *apiOptions) validate(c *config.Config) error {
206206

207207
func (o *apiOptions) scaffolder(c *config.Config) (scaffold.Scaffolder, error) {
208208
// Load the boilerplate
209-
bp, err := ioutil.ReadFile(filepath.Join("hack", "boilerplate.go.txt")) // nolint:gosec
209+
bp, err := ioutil.ReadFile(filepath.Join("hack", "boilerplate.go.txt")) //nolint:gosec
210210
if err != nil {
211211
return nil, fmt.Errorf("unable to load boilerplate: %v", err)
212212
}

cmd/edit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (o *editOptions) validate(c *config.Config) error {
8989
return nil
9090
}
9191

92-
func (o *editOptions) scaffolder(c *config.Config) (scaffold.Scaffolder, error) { // nolint:unparam
92+
func (o *editOptions) scaffolder(c *config.Config) (scaffold.Scaffolder, error) { //nolint:unparam
9393
return scaffold.NewEditScaffolder(c, o.multigroup), nil
9494
}
9595

cmd/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (o *initOptions) validate(c *config.Config) error {
179179
return nil
180180
}
181181

182-
func (o *initOptions) scaffolder(c *config.Config) (scaffold.Scaffolder, error) { // nolint:unparam
182+
func (o *initOptions) scaffolder(c *config.Config) (scaffold.Scaffolder, error) { //nolint:unparam
183183
return scaffold.NewInitScaffolder(c, o.license, o.owner), nil
184184
}
185185

cmd/internal/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func ConfiguredAndV1() bool {
4343
return projectConfig.IsV1()
4444
}
4545

46+
// PrintV1DeprecationWarning prints a deprecation warning if some v1 feature is used
4647
func PrintV1DeprecationWarning() {
4748
fmt.Printf(noticeColor, "[Deprecation Notice] The v1 projects are deprecated and will not be supported beyond "+
4849
"Feb 1, 2020.\nSee how to upgrade your project to v2: https://book.kubebuilder.io/migration/guide.html\n")

cmd/internal/exec.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import (
2323
"strings"
2424
)
2525

26+
// RunCmd prints the provided message and command and then executes it binding stdout and stderr
2627
func RunCmd(msg, cmd string, args ...string) error {
27-
c := exec.Command(cmd, args...) // #nolint:gosec
28+
c := exec.Command(cmd, args...) //nolint:gosec
2829
c.Stdout = os.Stdout
2930
c.Stderr = os.Stderr
3031
fmt.Println(msg + ":\n$ " + strings.Join(c.Args, " "))

cmd/internal/go_version.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"strings"
2525
)
2626

27+
// ValidateGoVersion verifies that Go is installed and the current go version is supported by kubebuilder
2728
func ValidateGoVersion() error {
2829
err := fetchAndCheckGoVersion()
2930
if err != nil {

cmd/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (o *updateOptions) validate(c *config.Config) error {
8181
return nil
8282
}
8383

84-
func (o *updateOptions) scaffolder(c *config.Config) (scaffold.Scaffolder, error) { // nolint:unparam
84+
func (o *updateOptions) scaffolder(c *config.Config) (scaffold.Scaffolder, error) { //nolint:unparam
8585
return scaffold.NewUpdateScaffolder(&c.Config), nil
8686
}
8787

cmd/version/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
3535
)
3636

37+
// Version contains all the information related to the CLI version
3738
type Version struct {
3839
KubeBuilderVersion string `json:"kubeBuilderVersion"`
3940
KubernetesVendor string `json:"kubernetesVendor"`
@@ -54,10 +55,12 @@ func getVersion() Version {
5455
}
5556
}
5657

58+
// Print prints the CLI version
5759
func (v Version) Print() {
5860
fmt.Printf("Version: %#v\n", v)
5961
}
6062

63+
// NewVersionCmd creates a new command that prints the CLI version
6164
func NewVersionCmd() *cobra.Command {
6265
return &cobra.Command{
6366
Use: "version",

cmd/webhook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (o *webhookV1Options) validate(c *config.Config) error {
114114

115115
func (o *webhookV1Options) scaffolder(c *config.Config) (scaffold.Scaffolder, error) {
116116
// Load the boilerplate
117-
bp, err := ioutil.ReadFile(filepath.Join("hack", "boilerplate.go.txt")) // nolint:gosec
117+
bp, err := ioutil.ReadFile(filepath.Join("hack", "boilerplate.go.txt")) //nolint:gosec
118118
if err != nil {
119119
return nil, fmt.Errorf("unable to load boilerplate: %v", err)
120120
}
@@ -220,9 +220,9 @@ func (o *webhookV2Options) validate(c *config.Config) error {
220220
return nil
221221
}
222222

223-
func (o *webhookV2Options) scaffolder(c *config.Config) (scaffold.Scaffolder, error) { // nolint:unparam
223+
func (o *webhookV2Options) scaffolder(c *config.Config) (scaffold.Scaffolder, error) { //nolint:unparam
224224
// Load the boilerplate
225-
bp, err := ioutil.ReadFile(filepath.Join("hack", "boilerplate.go.txt")) // nolint:gosec
225+
bp, err := ioutil.ReadFile(filepath.Join("hack", "boilerplate.go.txt")) //nolint:gosec
226226
if err != nil {
227227
return nil, fmt.Errorf("unable to load boilerplate: %v", err)
228228
}

docs/book/utils/litgo/literate.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ type Literate struct {
4545
BaseSourcePath *url.URL
4646
}
4747

48-
func (_ Literate) SupportsOutput(_ string) bool { return true }
48+
// SupportsOutput implements plugin.Plugin
49+
func (Literate) SupportsOutput(_ string) bool { return true }
50+
51+
// Process implements plugin.Plugin
4952
func (l Literate) Process(input *plugin.Input) error {
5053
bookSrcDir := filepath.Join(input.Context.Root, input.Context.Config.Book.Src)
5154
return plugin.EachCommand(&input.Book, "literatego", func(chapter *plugin.BookChapter, relPath string) (string, error) {

0 commit comments

Comments
 (0)