Skip to content

Commit

Permalink
chore: enable redundant-import-alias from revive (#21386)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Jan 6, 2025
1 parent 41dec01 commit 9f0dc94
Show file tree
Hide file tree
Showing 22 changed files with 259 additions and 251 deletions.
14 changes: 14 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ linters-settings:
alias:
- alias: jwtgo
pkg: github.com/golang-jwt/jwt/v5
- alias: appsv1
pkg: k8s.io/api/apps/v1
- alias: corev1
pkg: k8s.io/api/core/v1
- alias: rbacv1
pkg: k8s.io/api/rbac/v1
- alias: apierrors
pkg: k8s.io/apimachinery/pkg/api/errors
- alias: metav1
pkg: k8s.io/apimachinery/pkg/apis/meta/v1
- alias: informersv1
pkg: k8s.io/client-go/informers/core/v1
- alias: stderrors
pkg: errors
perfsprint:
Expand Down Expand Up @@ -106,19 +112,24 @@ linters-settings:
disabled: true
# report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible
- name: errorf
disabled: false
# incrementing an integer variable by 1 is recommended to be done using the `++` operator
- name: increment-decrement
disabled: false
# highlights redundant else-blocks that can be eliminated from the code
- name: indent-error-flow
disabled: true
# This rule suggests a shorter way of writing ranges that do not use the second value.
- name: range
disabled: false
# receiver names in a method should reflect the struct name (p for Person, for example)
- name: receiver-naming
disabled: true
# redefining built in names (true, false, append, make) can lead to bugs very difficult to detect.
- name: redefines-builtin-id
disabled: true
- name: redundant-import-alias
disabled: false
# redundant else-blocks that can be eliminated from the code.
- name: superfluous-else
disabled: true
Expand All @@ -130,13 +141,16 @@ linters-settings:
disabled: true
# spots and proposes to remove unreachable code. also helps to spot errors
- name: unreachable-code
disabled: false
# Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug.
- name: unused-parameter
disabled: true
# Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any.
- name: use-any
disabled: false
# report when a variable declaration can be simplified
- name: var-declaration
disabled: false
# warns when initialism, variable or package naming conventions are not followed.
- name: var-naming
disabled: true
Expand Down
16 changes: 6 additions & 10 deletions applicationset/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ import (
"testing"
"time"

"github.com/argoproj/argo-cd/v2/applicationset/utils"
argoappv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/runtime"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
fake "sigs.k8s.io/controller-runtime/pkg/client/fake"

prometheus "github.com/prometheus/client_golang/prometheus"

metricsutil "github.com/argoproj/argo-cd/v2/util/metrics"

"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/metrics"

"sigs.k8s.io/yaml"

"github.com/argoproj/argo-cd/v2/applicationset/utils"
argoappv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
metricsutil "github.com/argoproj/argo-cd/v2/util/metrics"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions applicationset/services/pull_request/azure_devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"

"github.com/microsoft/azure-devops-go-api/azuredevops"
core "github.com/microsoft/azure-devops-go-api/azuredevops/core"
git "github.com/microsoft/azure-devops-go-api/azuredevops/git"
"github.com/microsoft/azure-devops-go-api/azuredevops/core"
"github.com/microsoft/azure-devops-go-api/azuredevops/git"
)

const AZURE_DEVOPS_DEFAULT_URL = "https://dev.azure.com"
Expand Down
2 changes: 1 addition & 1 deletion applicationset/services/pull_request/azure_devops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/microsoft/azure-devops-go-api/azuredevops/webapi"

"github.com/microsoft/azure-devops-go-api/azuredevops/core"
git "github.com/microsoft/azure-devops-go-api/azuredevops/git"
"github.com/microsoft/azure-devops-go-api/azuredevops/git"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion cmd/argocd/commands/admin/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/argoproj/argo-cd/v2/reposerver/apiclient"
"github.com/argoproj/argo-cd/v2/util/env"
service "github.com/argoproj/argo-cd/v2/util/notification/argocd"
settings "github.com/argoproj/argo-cd/v2/util/notification/settings"
"github.com/argoproj/argo-cd/v2/util/notification/settings"
"github.com/argoproj/argo-cd/v2/util/tls"

"github.com/argoproj/notifications-engine/pkg/cmd"
Expand Down
2 changes: 1 addition & 1 deletion cmd/argocd/commands/app_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
argocdclient "github.com/argoproj/argo-cd/v2/pkg/apiclient"
applicationpkg "github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
"github.com/argoproj/argo-cd/v2/pkg/apis/application"
v1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/v2/util/argo"
"github.com/argoproj/argo-cd/v2/util/errors"
"github.com/argoproj/argo-cd/v2/util/io"
Expand Down
8 changes: 4 additions & 4 deletions controller/appcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/argoproj/gitops-engine/pkg/utils/kube"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
v1 "k8s.io/api/apps/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -1696,7 +1696,7 @@ func TestUpdateReconciledAt(t *testing.T) {
}

func TestUpdateHealthStatusTransitionTime(t *testing.T) {
deployment := kube.MustToUnstructured(&v1.Deployment{
deployment := kube.MustToUnstructured(&appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "Deployment",
Expand Down Expand Up @@ -1798,7 +1798,7 @@ apps/Deployment:

func TestUpdateHealthStatusProgression(t *testing.T) {
app := newFakeAppWithHealthAndTime(health.HealthStatusDegraded, testTimestamp)
deployment := kube.MustToUnstructured(&v1.Deployment{
deployment := kube.MustToUnstructured(&appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "Deployment",
Expand All @@ -1807,7 +1807,7 @@ func TestUpdateHealthStatusProgression(t *testing.T) {
Name: "demo",
Namespace: "default",
},
Status: v1.DeploymentStatus{
Status: appsv1.DeploymentStatus{
ObservedGeneration: 0,
},
})
Expand Down
2 changes: 1 addition & 1 deletion controller/sharding/sharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"hash/fnv"
"math"
"os"
"slices"
"sort"
"strconv"
"strings"
"time"

slices "golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down
8 changes: 4 additions & 4 deletions controller/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
logrustest "github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/apps/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -684,7 +684,7 @@ func TestCompareAppStateWithManifestGeneratePath(t *testing.T) {

func TestSetHealth(t *testing.T) {
app := newFakeApp()
deployment := kube.MustToUnstructured(&v1.Deployment{
deployment := kube.MustToUnstructured(&appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "Deployment",
Expand Down Expand Up @@ -721,7 +721,7 @@ func TestSetHealth(t *testing.T) {
func TestPreserveStatusTimestamp(t *testing.T) {
timestamp := metav1.Now()
app := newFakeAppWithHealthAndTime(health.HealthStatusHealthy, timestamp)
deployment := kube.MustToUnstructured(&v1.Deployment{
deployment := kube.MustToUnstructured(&appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "Deployment",
Expand Down Expand Up @@ -758,7 +758,7 @@ func TestPreserveStatusTimestamp(t *testing.T) {
func TestSetHealthSelfReferencedApp(t *testing.T) {
app := newFakeApp()
unstructuredApp := kube.MustToUnstructured(app)
deployment := kube.MustToUnstructured(&v1.Deployment{
deployment := kube.MustToUnstructured(&appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "Deployment",
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/application/v1alpha1/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package v1alpha1
import (
"encoding/json"
"fmt"
reflect "reflect"
"reflect"
"strings"

runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/yaml"
)

Expand Down
5 changes: 2 additions & 3 deletions reposerver/apiclient/mocks/Clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions reposerver/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/apps/v1"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -1113,7 +1113,7 @@ func TestGenerateHelmWithValues(t *testing.T) {
require.NoError(t, err)

if obj.GetKind() == "Deployment" && obj.GetName() == "test-redis-slave" {
var dep v1.Deployment
var dep appsv1.Deployment
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &dep)
require.NoError(t, err)
assert.Equal(t, int32(2), *dep.Spec.Replicas)
Expand Down Expand Up @@ -1175,7 +1175,7 @@ func TestGenerateHelmWithEnvVars(t *testing.T) {
require.NoError(t, err)

if obj.GetKind() == "Deployment" && obj.GetName() == "production-redis-slave" {
var dep v1.Deployment
var dep appsv1.Deployment
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &dep)
require.NoError(t, err)
assert.Equal(t, int32(3), *dep.Spec.Replicas)
Expand Down
Loading

0 comments on commit 9f0dc94

Please sign in to comment.