Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch the linter from golint to revive, and fix warnings. #4212

Merged
merged 1 commit into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ linters:
- goimports
- gosec
- gocritic
- golint
- revive
- misspell
output:
uniq-by-line: false
Expand Down
2 changes: 1 addition & 1 deletion cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func newConfigValidationController(ctx context.Context, cmw configmap.Watcher) *
}

func newConversionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
// nolint: golint
// nolint: revive
var (
v1alpha1GroupVersion = v1alpha1.SchemeGroupVersion.Version
v1beta1GroupVersion = v1beta1.SchemeGroupVersion.Version
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package pipeline

const (
// PipelineRunControllerName holds the name of the PipelineRun controller
// nolint: golint
// nolint: revive
PipelineRunControllerName = "PipelineRun"

// TaskRunControllerName holds the name of the TaskRun controller
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/cluster_task_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1alpha1

import (
Expand Down
5 changes: 1 addition & 4 deletions pkg/apis/pipeline/v1alpha1/condition_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,5 @@ func (cs *ConditionSpec) Validate(ctx context.Context) *apis.FieldError {
}
}

if err := validateSteps([]Step{cs.Check}).ViaField("Check"); err != nil {
return err
}
return nil
return validateSteps([]Step{cs.Check}).ViaField("Check")
}
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/pipeline_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1alpha1

import (
Expand Down
6 changes: 1 addition & 5 deletions pkg/apis/pipeline/v1alpha1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@ func (ps *PipelineSpec) Validate(ctx context.Context) *apis.FieldError {
}

// Validate the pipeline's workspaces.
if err := validatePipelineWorkspaces(ps.Workspaces, ps.Tasks); err != nil {
return err
}

return nil
return validatePipelineWorkspaces(ps.Workspaces, ps.Tasks)
}

func validatePipelineTasks(ctx context.Context, tasks []PipelineTask) *apis.FieldError {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/pipelinerun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1alpha1

import (
Expand Down
6 changes: 1 addition & 5 deletions pkg/apis/pipeline/v1alpha1/run_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,5 @@ func (rs *RunSpec) Validate(ctx context.Context) *apis.FieldError {
return err
}

if err := validateWorkspaceBindings(ctx, rs.Workspaces); err != nil {
return err
}

return nil
return validateWorkspaceBindings(ctx, rs.Workspaces)
}
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/task_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1alpha1

import (
Expand Down
5 changes: 1 addition & 4 deletions pkg/apis/pipeline/v1alpha1/task_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ func (ts *TaskSpec) Validate(ctx context.Context) *apis.FieldError {
return err
}
// Deprecated
if err := validateResourceVariables(ts.Steps, ts.Inputs, ts.Outputs, ts.Resources); err != nil {
return err
}
return nil
return validateResourceVariables(ts.Steps, ts.Inputs, ts.Outputs, ts.Resources)
}

// validateDeclaredWorkspaces will make sure that the declared workspaces do not try to use
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/taskrun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1alpha1

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/cluster_task_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1beta1

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/pipeline_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1beta1

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/pipelinerun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1beta1

import (
Expand Down
5 changes: 1 addition & 4 deletions pkg/apis/pipeline/v1beta1/resource_types_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ func (tr *TaskRunResources) Validate(ctx context.Context) *apis.FieldError {
if err := validateTaskRunResources(ctx, tr.Inputs, "spec.resources.inputs.name"); err != nil {
return err
}
if err := validateTaskRunResources(ctx, tr.Outputs, "spec.resources.outputs.name"); err != nil {
return err
}
return nil
return validateTaskRunResources(ctx, tr.Outputs, "spec.resources.outputs.name")
}

// validateTaskRunResources validates that
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/task_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1beta1

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/taskrun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint: golint
// nolint: revive
package v1beta1

import (
Expand Down
6 changes: 1 addition & 5 deletions pkg/pullrequest/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ func ToDisk(r *Resource, path string) error {
if err := refToDisk("head", path, r.PR.Head); err != nil {
return err
}
if err := refToDisk("base", path, r.PR.Base); err != nil {
return err
}

return nil
return refToDisk("base", path, r.PR.Base)
}

func commentsToDisk(path string, comments []*scm.Comment) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/resources/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func ApplyTaskResultsToPipelineResults(
customTaskStatuses[runStatus.PipelineTaskName] = runStatus
}

var runResults []v1beta1.PipelineRunResult = nil
var runResults []v1beta1.PipelineRunResult
stringReplacements := map[string]string{}
for _, pipelineResult := range results {
variablesInPipelineResult, _ := v1beta1.GetVarSubstitutionExpressionsForPipelineResult(pipelineResult)
Expand Down
5 changes: 1 addition & 4 deletions pkg/termination/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ func WriteMessage(path string, pro []v1beta1.PipelineResourceResult) error {
if _, err = f.Write(jsonOutput); err != nil {
return err
}
if err := f.Sync(); err != nil {
return err
}
return nil
return f.Sync()
}

// MessageLengthError indicate the length of termination message of container is beyond 4096 which is the max length read by kubenates
Expand Down
2 changes: 1 addition & 1 deletion test/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func AddToInformer(t *testing.T, store cache.Store) func(ktesting.Action) (bool,

// SeedTestData returns Clients and Informers populated with the
// given Data.
// nolint: golint
// nolint: revive
func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers) {
c := Clients{
Kube: fakekubeclient.Get(ctx),
Expand Down
2 changes: 1 addition & 1 deletion test/v1alpha1/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type Assets struct {

// SeedTestData returns Clients and Informers populated with the
// given Data.
// nolint: golint
// nolint: revive
func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers) {
c := Clients{
Kube: fakekubeclient.Get(ctx),
Expand Down