Skip to content

Commit

Permalink
Add more linter to golangci-lint
Browse files Browse the repository at this point in the history
- Add a configuration file for golangci-lint
- Add `gofmt`, `goimports`, `errcheck` and `golint` linters
- Fixes code accordingly

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester authored and tekton-robot committed Jul 24, 2019
1 parent deff470 commit 72224f4
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 13 deletions.
8 changes: 8 additions & 0 deletions .errcheck.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(*github.com/tektoncd/pipeline/vendor/go.uber.org/zap.SugaredLogger).Sync
flag.Set
os.Setenv
logger.Sync
fmt.Fprintf
fmt.Fprintln
(io.Closer).Close
updateConfigMap
14 changes: 14 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
run:
build-tags:
- e2e
skip-dirs:
- vendor
linters-settings:
errcheck:
exclude: .errcheck.txt
linters:
enable:
- gofmt
- goimports
- errcheck
- golint
4 changes: 3 additions & 1 deletion cmd/docs/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ func loadLongDescription(cmd *cobra.Command, path ...string) error {
}
fullpath := filepath.Join(path[0], strings.Join(append(path[1:], cmd.Name()), "_")+".md")
if cmd.HasSubCommands() {
loadLongDescription(cmd, path[0], cmd.Name())
if err := loadLongDescription(cmd, path[0], cmd.Name()); err != nil {
return err
}
}

if _, err := os.Stat(fullpath); err != nil {
Expand Down
5 changes: 0 additions & 5 deletions cmd/docs/md_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
return nil
}

// GenMarkdown creates markdown output.
func GenMarkdown(cmd *cobra.Command, w io.Writer) error {
return GenMarkdownCustom(cmd, w, func(s string) string { return s })
}

// GenMarkdownCustom creates custom markdown output.
func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error {
cmd.InitDefaultHelpCmd()
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func Command() *cobra.Command {
// runCompletionZsh generate completion manually, we are not using cobra
// completion since it's not flexible enough for us.
func runCompletionZsh(out io.Writer, tkn *cobra.Command) error {
if _, err := out.Write([]byte(zsh_completion)); err != nil {
if _, err := out.Write([]byte(zshCompletion)); err != nil {
return err
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/completion/zsh_completion.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package completion

var zsh_completion = `
var zshCompletion = `
#compdef _tkn tkn
local -a common_options common_describe_options common_logs_options
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/pipelinerun/log_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package pipelinerun

import (
"fmt"

"github.com/tektoncd/cli/pkg/cli"
"github.com/tektoncd/cli/pkg/formatted"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/pipelinerun/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ package pipelinerun

import (
"fmt"
"github.com/tektoncd/cli/pkg/helper/pods/stream"

"github.com/spf13/cobra"
"github.com/tektoncd/cli/pkg/cli"
"github.com/tektoncd/cli/pkg/helper/pods"
"github.com/tektoncd/cli/pkg/helper/pods/stream"
)

const (
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/taskrun/log_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package taskrun

import (
"fmt"

"github.com/tektoncd/cli/pkg/cli"
"github.com/tektoncd/cli/pkg/formatted"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func checkRelease(outStream io.Writer) error {

var response struct {
TagName string `json:"tag_name"`
HtmlUrl string `json:"html_url"`
HTMLURL string `json:"html_url"`
}
if err := json.Unmarshal(body, &response); err != nil {
return errors.Wrap(err, "failed to unmarshal the latest version response body")
Expand All @@ -93,7 +93,7 @@ func checkRelease(outStream io.Writer) error {
}

if current.LT(*latest) {
fmt.Fprintf(outStream, "A newer version (v%s) of Tekton CLI is available, please check %s\n", latest, response.HtmlUrl)
fmt.Fprintf(outStream, "A newer version (v%s) of Tekton CLI is available, please check %s\n", latest, response.HTMLURL)
} else {
fmt.Fprintf(outStream, "You are running the latest version (v%s) of Tekton CLI\n", latest)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/formatted/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package formatted

import (
"github.com/fatih/color"
"io"

"github.com/fatih/color"
)

//Color formatter to print the colored output on streams
Expand Down
3 changes: 2 additions & 1 deletion pkg/helper/pods/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package pods
import (
"bufio"
"fmt"
"github.com/tektoncd/cli/pkg/helper/pods/stream"
"io"

"github.com/tektoncd/cli/pkg/helper/pods/stream"
corev1 "k8s.io/api/core/v1"
)

Expand Down

0 comments on commit 72224f4

Please sign in to comment.