Skip to content

Commit

Permalink
chore: enable var-declaration from revive (#21370)
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 3, 2025
1 parent 4e5db16 commit e66068c
Show file tree
Hide file tree
Showing 19 changed files with 26 additions and 28 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ linters-settings:
- name: use-any
# report when a variable declaration can be simplified
- name: var-declaration
disabled: true
# warns when initialism, variable or package naming conventions are not followed.
- name: var-naming
disabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ func NewCommand() *cobra.Command {
}

// By default, watch all namespaces
var watchedNamespace string = ""

var watchedNamespace string
// If the applicationset-namespaces contains only one namespace it corresponds to the current namespace
if len(applicationSetNamespaces) == 1 {
watchedNamespace = (applicationSetNamespaces)[0]
Expand Down
2 changes: 1 addition & 1 deletion cmd/argocd/commands/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ argocd cluster rm cluster-name`,
conn, clusterIf := headless.NewClientOrDie(clientOpts, c).NewClusterClientOrDie()
defer io.Close(conn)
numOfClusters := len(args)
var isConfirmAll bool = false
var isConfirmAll bool

for _, clusterSelector := range args {
clusterQuery := getQueryBySelector(clusterSelector)
Expand Down
4 changes: 2 additions & 2 deletions controller/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ var (
clusterCacheAttemptLimit int32 = 1

// clusterCacheRetryUseBackoff specifies whether to use a backoff strategy on cluster cache sync, if retry is enabled
clusterCacheRetryUseBackoff bool = false
clusterCacheRetryUseBackoff = false

// clusterCacheBatchEventsProcessing specifies whether to enable batch events processing
clusterCacheBatchEventsProcessing bool = false
clusterCacheBatchEventsProcessing = false

// clusterCacheEventProcessingInterval specifies the interval between processing events when BatchEventsProcessing is enabled
clusterCacheEventProcessingInterval = 100 * time.Millisecond
Expand Down
6 changes: 3 additions & 3 deletions controller/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,9 @@ func Test_getAppRecursive(t *testing.T) {

func TestSkipResourceUpdate(t *testing.T) {
var (
hash1_x string = "x"
hash2_y string = "y"
hash3_x string = "x"
hash1_x = "x"
hash2_y = "y"
hash3_x = "x"
)
info := &ResourceInfo{
manifestHash: hash1_x,
Expand Down
2 changes: 1 addition & 1 deletion controller/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/argoproj/argo-cd/v2/util/rand"
)

var syncIdPrefix uint64 = 0
var syncIdPrefix uint64

const (
// EnvVarSyncWaveDelay is an environment variable which controls the delay in seconds between
Expand Down
2 changes: 1 addition & 1 deletion hack/known_types/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
)

func newCommand() *cobra.Command {
var docsOutputPath string = ""
var docsOutputPath string
command := &cobra.Command{
Use: "go run github.com/argoproj/argo-cd/hack/known_types ALIAS PACKAGE_PATH OUTPUT_PATH",
Example: "go run github.com/argoproj/argo-cd/hack/known_types corev1 k8s.io/api/core/v1 corev1_known_types.go",
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ func (d *ApplicationDestination) SetIsServerInferred(inferred bool) {
type ResourceHealthLocation string

var (
ResourceHealthLocationInline ResourceHealthLocation = ""
ResourceHealthLocationInline ResourceHealthLocation
ResourceHealthLocationAppTree ResourceHealthLocation = "appTree"
)

Expand Down
2 changes: 1 addition & 1 deletion reposerver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type ArgoCDRepoServer struct {
}

// The hostnames to generate self-signed issues with
var tlsHostList []string = []string{"localhost", "reposerver"}
var tlsHostList = []string{"localhost", "reposerver"}

// NewServer returns a new instance of the Argo CD Repo server
func NewServer(metricsServer *metrics.MetricsServer, cache *reposervercache.Cache, tlsConfCustomizer tlsutil.ConfigCustomizer, initConstants repository.RepoServerInitConstants, gitCredsStore git.CredsStore) (*ArgoCDRepoServer, error) {
Expand Down
2 changes: 1 addition & 1 deletion server/badge/badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

if displayAppName && applicationName != "" {
titleRectWidth := len(applicationName) * widthPerChar
var longerWidth int = max(titleRectWidth, svgWidth)
longerWidth := max(titleRectWidth, svgWidth)
rightRectWidth := longerWidth - leftRectWidth
badge = titleRectWidthPattern.ReplaceAllString(badge, fmt.Sprintf(`$1"%d"`, longerWidth))
badge = rightRectWidthPattern.ReplaceAllString(badge, fmt.Sprintf(`$1"%d"`, rightRectWidth))
Expand Down
2 changes: 1 addition & 1 deletion util/argo/audit_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
_test = "test"
)

var testEnableEventLog []string = []string{_somecomponent, _test}
var testEnableEventLog = []string{_somecomponent, _test}

// Helper to capture log entries generated by the logger and return it as string
func captureLogEntries(run func()) string {
Expand Down
2 changes: 1 addition & 1 deletion util/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func AddCacheFlagsToCmd(cmd *cobra.Command, opts ...Options) func() (*Cache, err
redisCACertificate := redisCACertificateSrc()
compressionStr := compressionStrSrc()

var tlsConfig *tls.Config = nil
var tlsConfig *tls.Config
if redisUseTLS {
tlsConfig = &tls.Config{}
if redisClientCertificate != "" {
Expand Down
6 changes: 3 additions & 3 deletions util/db/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func (db *db) GetRepoCertificate(ctx context.Context, serverType string, serverN
// actually created.
func (db *db) CreateRepoCertificate(ctx context.Context, certificates *appsv1.RepositoryCertificateList, upsert bool) (*appsv1.RepositoryCertificateList, error) {
var (
saveSSHData bool = false
saveTLSData bool = false
saveSSHData = false
saveTLSData = false
)

sshKnownHostsList, err := db.getSSHKnownHostsData()
Expand Down Expand Up @@ -243,7 +243,7 @@ func (db *db) CreateRepoCertificate(ctx context.Context, certificates *appsv1.Re
saveSSHData = true
}
} else if certificate.CertType == "https" {
var tlsCertificate *TLSCertificate = nil
var tlsCertificate *TLSCertificate
newEntry := true
upserted := false
pemCreated := make([]string, 0)
Expand Down
8 changes: 4 additions & 4 deletions util/db/certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
Test_Cert2CN = "CN=bar.example.com,OU=Testsuite,O=Testing Corp,L=Hanover,ST=Lower Saxony,C=DE"
)

var Test_TLS_Subjects []string = []string{
var Test_TLS_Subjects = []string{
"CN=foo.example.com,OU=SpecOps,O=Capone\\, Inc,L=Chicago,ST=IL,C=US",
"CN=bar.example.com,OU=Testsuite,O=Testing Corp,L=Hanover,ST=Lower Saxony,C=DE",
}
Expand Down Expand Up @@ -213,7 +213,7 @@ ssh.dev.azure.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7Hr1oTWqNqOlzGJOfGJ4Nak
vs-ssh.visualstudio.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7Hr1oTWqNqOlzGJOfGJ4NakVyIzf1rXYd4d7wo6jBlkLvCA4odBlL0mDUyZ0/QUfTTqeu+tm22gOsv+VrVTMk6vwRU75gY/y9ut5Mb3bR5BV58dKXyq9A9UeB5Cakehn5Zgm6x1mKoVyf+FFn26iYqXJRgzIZZcZ5V6hrE0Qg39kZm4az48o0AUbf6Sp4SLdvnuMa2sVNwHBboS7EJkm57XQPVU3/QpyNLHbWDdzwtrlS+ez30S3AdYhLKEOxAG8weOnyrtLJAUen9mTkol8oII1edf7mWWbWVf0nBmly21+nZcmCTISQBtdcyPaEno7fFQMDD26/s0lfKob4Kw8H
`

var Test_SSH_Hostname_Entries []string = []string{
var Test_SSH_Hostname_Entries = []string{
"bitbucket.org",
"github.com",
"gitlab.com",
Expand All @@ -223,7 +223,7 @@ var Test_SSH_Hostname_Entries []string = []string{
"vs-ssh.visualstudio.com",
}

var Test_SSH_Subtypes []string = []string{
var Test_SSH_Subtypes = []string{
"ssh-rsa",
"ssh-rsa",
"ecdsa-sha2-nistp256",
Expand All @@ -233,7 +233,7 @@ var Test_SSH_Subtypes []string = []string{
"ssh-rsa",
}

var Test_TLS_Hostnames []string = []string{
var Test_TLS_Hostnames = []string{
"test.example.com",
"test.example.com",
"github.com",
Expand Down
2 changes: 1 addition & 1 deletion util/db/gpgkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func validatePGPKey(keyData string) (*appsv1.GnuPGPublicKey, error) {
return nil, errors.New("More than one key found in input data")
}

var retKey *appsv1.GnuPGPublicKey = nil
var retKey *appsv1.GnuPGPublicKey
// Is there a better way to get the first element from a map without knowing its key?
for _, k := range parsed {
retKey = k
Expand Down
2 changes: 1 addition & 1 deletion util/git/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (f sshPrivateKeyFile) Close() error {
// Remove a list of files that have been created as temp files while creating
// HTTPCreds object above.
func (f authFilePaths) Close() error {
var retErr error = nil
var retErr error
for _, path := range f {
err := os.Remove(path)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion util/gpg/gpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ func GetInstalledPGPKeys(kids []string) ([]*appsv1.GnuPGPublicKey, error) {
}

scanner := bufio.NewScanner(strings.NewReader(out))
var curKey *appsv1.GnuPGPublicKey = nil
var curKey *appsv1.GnuPGPublicKey
for scanner.Scan() {
if strings.HasPrefix(scanner.Text(), "pub ") {
// This is the beginning of a new key, time to store the previously parsed one in our list and start fresh.
Expand Down
2 changes: 1 addition & 1 deletion util/io/path/resolved_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Test_isURLSchemeAllowed(t *testing.T) {
allowed []string
expected bool
}
var tts []testdata = []testdata{
tts := []testdata{
{
name: "Allowed scheme matches",
scheme: "http",
Expand Down
2 changes: 1 addition & 1 deletion util/lua/custom_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func getExpectedObjectList(t *testing.T, path string) *unstructured.Unstructured
}

func findFirstMatchingItem(items []unstructured.Unstructured, f func(unstructured.Unstructured) bool) *unstructured.Unstructured {
var matching *unstructured.Unstructured = nil
var matching *unstructured.Unstructured
for _, item := range items {
if f(item) {
matching = &item
Expand Down

0 comments on commit e66068c

Please sign in to comment.