Skip to content

Commit

Permalink
test: enable interfacer lint check and fix the generated warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Cosmin Cojocar <[email protected]>
  • Loading branch information
ccojocar authored and jenkins-x-bot committed Oct 7, 2019
1 parent c266d80 commit 1716def
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions hack/linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ golangci-lint run \
-E gofmt \
-E goimports \
-E structcheck \
-E interfacer \
-E typecheck \
--skip-dirs vendor \
--deadline 15m0s \
--verbose

# -E errcheck \
# -E varcheck \
# -E govet \
# -E interfacer \
# -E unparam \
# -E megacheck \
# -E goconst \
# -E typecheck \
# -E ineffassign \
# -E golint
# -E unparam
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/controller/controller_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func (o *ControllerWorkflowOptions) ReloadAndPollGitPipelineStatuses(jxClient ve

// pollGitStatusforPipeline polls the pending PipelineActivity resources to see if the
// PR has merged or the pipeline on master has completed
func (o *ControllerWorkflowOptions) pollGitStatusforPipeline(activity *v1.PipelineActivity, activities typev1.PipelineActivityInterface, environments typev1.EnvironmentInterface, ns string) {
func (o *ControllerWorkflowOptions) pollGitStatusforPipeline(activity *v1.PipelineActivity, activities typev1.PipelineActivityExpansion, environments typev1.EnvironmentInterface, ns string) {
if !o.isReleaseBranch(activity.BranchName()) {
o.removePipelineActivity(activity, activities)
return
Expand Down Expand Up @@ -792,12 +792,12 @@ func setActivityAborted(activity *v1.PipelineActivity) bool {
return true
}

func (o *ControllerWorkflowOptions) removePipelineActivity(activity *v1.PipelineActivity, activities typev1.PipelineActivityInterface) {
func (o *ControllerWorkflowOptions) removePipelineActivity(activity *v1.PipelineActivity, activities typev1.PipelineActivityExpansion) {
o.modifyAndRemovePipelineActivity(activity, activities, noopCallback)
}

// removePipelineActivityIfNoManual only remove the PipelineActivity if there is not any pending Promote
func (o *ControllerWorkflowOptions) removePipelineActivityIfNoManual(activity *v1.PipelineActivity, activities typev1.PipelineActivityInterface) {
func (o *ControllerWorkflowOptions) removePipelineActivityIfNoManual(activity *v1.PipelineActivity, activities typev1.PipelineActivityExpansion) {
for _, step := range activity.Spec.Steps {
promote := step.Promote
if promote != nil {
Expand All @@ -809,13 +809,13 @@ func (o *ControllerWorkflowOptions) removePipelineActivityIfNoManual(activity *v
o.removePipelineActivity(activity, activities)
}

func (o *ControllerWorkflowOptions) modifyAndRemovePipelineActivity(activity *v1.PipelineActivity, activities typev1.PipelineActivityInterface, callback func(activity *v1.PipelineActivity) bool) error {
func (o *ControllerWorkflowOptions) modifyAndRemovePipelineActivity(activity *v1.PipelineActivity, activities typev1.PipelineActivityExpansion, callback func(activity *v1.PipelineActivity) bool) error {
err := modifyPipeline(activities, activity, callback)
delete(o.pipelineMap, activity.Name)
return err
}

func modifyPipeline(activities typev1.PipelineActivityInterface, activity *v1.PipelineActivity, callback func(activity *v1.PipelineActivity) bool) error {
func modifyPipeline(activities typev1.PipelineActivityExpansion, activity *v1.PipelineActivity, callback func(activity *v1.PipelineActivity) bool) error {
old := activity
if callback(activity) {
if !reflect.DeepEqual(activity, &old) {
Expand All @@ -830,7 +830,7 @@ func modifyPipeline(activities typev1.PipelineActivityInterface, activity *v1.Pi
}

// isNewestPipeline returns true if this pipeline is the newest pipeline version for a repo
func (o *ControllerWorkflowOptions) isNewestPipeline(activity *v1.PipelineActivity, activities typev1.PipelineActivityInterface) bool {
func (o *ControllerWorkflowOptions) isNewestPipeline(activity *v1.PipelineActivity, activities typev1.PipelineActivityExpansion) bool {
newest := true
deleteNames := []*v1.PipelineActivity{}
for _, act2 := range o.pipelineMap {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func namespace(o *NamespaceOptions) string {
return ns
}

func changeNamespace(client kubernetes.Interface, config *api.Config, pathOptions *clientcmd.PathOptions, ns string, create bool) (*api.Context, error) {
func changeNamespace(client kubernetes.Interface, config *api.Config, pathOptions clientcmd.ConfigAccess, ns string, create bool) (*api.Context, error) {
_, err := client.CoreV1().Namespaces().Get(ns, meta_v1.GetOptions{})
if err != nil {
switch err.(type) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/step/git/step_git_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package git

import (
"fmt"
"io"
"io/ioutil"
"os"
"strings"
Expand Down Expand Up @@ -193,7 +194,7 @@ var _ = Describe("step git merge", func() {
})
})

func read(r *os.File, w *os.File) (string, error) {
func read(r io.Reader, w io.Closer) (string, error) {
err := w.Close()
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/step/step_blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (o *StepBlogOptions) createNewCommitters() string {
return buffer.String()
}

func (o *StepBlogOptions) printUserMap(out *bufio.Writer, role string, newUsers map[string]*v1.UserDetails) {
func (o *StepBlogOptions) printUserMap(out io.StringWriter, role string, newUsers map[string]*v1.UserDetails) {
if len(newUsers) > 0 {
out.WriteString(`
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/templates/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package templates
import (
"bytes"
"fmt"
"io"
"strings"

"github.com/russross/blackfriday"
Expand Down Expand Up @@ -138,7 +139,7 @@ func (r *ASCIIRenderer) Image(out *bytes.Buffer, link []byte, title []byte, alt
r.fw(out, link)
}

func (r *ASCIIRenderer) fw(out *bytes.Buffer, text ...[]byte) {
func (r *ASCIIRenderer) fw(out io.Writer, text ...[]byte) {
for _, t := range text {
out.Write(t)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gits/git_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func GetRepoName(batchMode, allowExistingRepo bool, provider GitProvider, defaul
return repoName, nil
}

func GetOwner(batchMode bool, provider GitProvider, gitUsername string, in terminal.FileReader, out terminal.FileWriter, errOut io.Writer) (string, error) {
func GetOwner(batchMode bool, provider OrganisationLister, gitUsername string, in terminal.FileReader, out terminal.FileWriter, errOut io.Writer) (string, error) {
owner := ""
if batchMode {
owner = gitUsername
Expand Down
4 changes: 2 additions & 2 deletions pkg/gits/operations/pull_request_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/jenkins-x/jx/pkg/helm"
"github.com/jenkins-x/jx/pkg/vault"
"github.com/jenkins-x/jx/pkg/secreturl"
"gopkg.in/AlecAivazis/survey.v1/terminal"

"github.com/jenkins-x/jx/pkg/cmd/opts"
Expand Down Expand Up @@ -520,7 +520,7 @@ func (o *PullRequestOperation) CreatePullRequestGitReleasesFn(name string) Chang
// empty it will fetch the latest version using helmer, using the vaultClient to get the repo creds or prompting using
// in, out and outErr
func CreateChartChangeFilesFn(name string, version string, kind string, pro *PullRequestOperation, helmer helm.Helmer,
vaultClient vault.Client, in terminal.FileReader, out terminal.FileWriter, outErr io.Writer) ChangeFilesFn {
vaultClient secreturl.Client, in terminal.FileReader, out terminal.FileWriter, outErr io.Writer) ChangeFilesFn {
return func(dir string, gitInfo *gits.GitRepository) ([]string, error) {
if version == "" && kind == string(versionstream.KindChart) {
parts := strings.Split(name, "/")
Expand Down
3 changes: 2 additions & 1 deletion pkg/helm/helm_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -751,7 +752,7 @@ func isWhitespaceOrComments(data []byte) bool {
return true
}

func writeObjectInFile(buf *bytes.Buffer, baseDir string, relativePath, namespace string, fileName string, count int) (string, error) {
func writeObjectInFile(buf io.WriterTo, baseDir string, relativePath, namespace string, fileName string, count int) (string, error) {
relativeDir := filepath.Dir(relativePath)

const filePrefix = "part"
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ func (k *PromoteStepActivityKey) OnPromoteUpdate(jxClient versioned.Interface, n
}

// ListSelectedPipelineActivities retrieves the PipelineActivities instances matching the specified label and field selectors. Selectors can be empty or nil.
func ListSelectedPipelineActivities(activitiesClient typev1.PipelineActivityInterface, labelSelector labels.Selector, fieldSelector fields.Selector) (*v1.PipelineActivityList, error) {
func ListSelectedPipelineActivities(activitiesClient typev1.PipelineActivityInterface, labelSelector fmt.Stringer, fieldSelector fields.Selector) (*v1.PipelineActivityList, error) {
log.Logger().Debugf("looking for PipelineActivities with label selector %v and field selector %v", labelSelector, fieldSelector)

listOptions := metav1.ListOptions{}
Expand Down
5 changes: 2 additions & 3 deletions pkg/surveyutils/jsonschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"testing"
"time"

"github.com/jenkins-x/jx/pkg/secreturl"
"github.com/jenkins-x/jx/pkg/util"

"github.com/jenkins-x/jx/pkg/vault/fake"

"github.com/jenkins-x/jx/pkg/vault"

"gopkg.in/AlecAivazis/survey.v1/core"

expect "github.com/Netflix/go-expect"
Expand Down Expand Up @@ -986,7 +985,7 @@ func TestJSONPointer(t *testing.T) {
}

func GenerateValuesAsYaml(r *tests.R, schemaName string, existingValues map[string]interface{}, askExisting bool, noAsk bool, autoAcceptDefaults bool, ignoreMissingValues bool, answerQuestions func(
console *tests.ConsoleWrapper, donec chan struct{}), vaultClient vault.Client) (string, vault.Client, error) {
console *tests.ConsoleWrapper, donec chan struct{}), vaultClient secreturl.Client) (string, secreturl.Client, error) {

//t.Parallel()
console := tests.NewTerminal(r, &timeout)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/downloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func UnTargzAll(tarball, target string) error {
}

// UnTarFile extracts one file from the tar, or creates a directory
func UnTarFile(header *tar.Header, path string, tarReader *tar.Reader) error {
func UnTarFile(header *tar.Header, path string, tarReader io.Reader) error {
info := header.FileInfo()
if info.IsDir() {
if err := os.MkdirAll(path, info.Mode()); err != nil {
Expand Down

0 comments on commit 1716def

Please sign in to comment.