Skip to content

Commit 5870b7a

Browse files
authored
Reactivate some previously removed linters (#4204)
Also fix the various errors reactivation found
1 parent c684c0d commit 5870b7a

File tree

55 files changed

+84
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+84
-405
lines changed

.golangci.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ run:
55
linters:
66
enable:
77
- gofmt
8-
- megacheck
8+
- staticcheck
9+
- gosimple
10+
- unused
911
- tparallel
1012
- paralleltest
1113
- prealloc
@@ -15,11 +17,16 @@ linters:
1517
- unused
1618
disable:
1719
# The below rules are disabled due to bug with go1.18 and generics: https://github.com/golangci/golangci-lint/issues/2859
18-
- staticcheck
19-
- gosimple
2020
- stylecheck
21-
- unused
2221
- musttag # Extremely slow, at least on CI machines
2322
linters-settings:
2423
govet:
2524
check-shadowing: true
25+
unused:
26+
generated-is-used: true
27+
gosimple:
28+
# See https://golangci-lint.run/usage/linters#gosimple for a breakdown of what's checked by this linter
29+
checks:
30+
- "all"
31+
- "-S1002" # Comparison to bool explicitly can sometimes add clarity
32+
- "-S1016" # Uncommon language feature, encourages coupling when it may not be appropriate

v2/api/dataprotection/customizations/backup_vaults_backup_instance_extensions.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ func (extension *BackupVaultsBackupInstanceExtension) PostReconcileCheck(
107107

108108
if protectionStatus == protectionError {
109109
// call sync api only when protection status is ProtectionError and error code is usererror
110-
var protectionStatusErrorCode string
111-
protectionStatusErrorCode = strings.ToLower(*backupInstance.Status.Properties.ProtectionStatus.ErrorDetails.Code)
110+
protectionStatusErrorCode := strings.ToLower(*backupInstance.Status.Properties.ProtectionStatus.ErrorDetails.Code)
112111
log.V(Debug).Info(fmt.Sprintf("Protection Error code is %q", protectionStatusErrorCode))
113112

114113
if strings.Contains(protectionStatusErrorCode, "usererror") {

v2/api/dbformariadb/customizations/server_extensions.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ func secretsSpecified(obj *mariadb.Server) bool {
6161
}
6262

6363
secrets := obj.Spec.OperatorSpec.Secrets
64-
if secrets.FullyQualifiedDomainName != nil {
65-
return true
66-
}
67-
68-
return false
64+
return secrets.FullyQualifiedDomainName != nil
6965
}
7066

7167
func secretsToWrite(obj *mariadb.Server) ([]*v1.Secret, error) {

v2/api/dbformysql/customizations/flexible_server_extensions.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ func secretsSpecified(obj *mysql.FlexibleServer) bool {
6161
}
6262

6363
secrets := obj.Spec.OperatorSpec.Secrets
64-
if secrets.FullyQualifiedDomainName != nil {
65-
return true
66-
}
67-
68-
return false
64+
return secrets.FullyQualifiedDomainName != nil
6965
}
7066

7167
func secretsToWrite(obj *mysql.FlexibleServer) ([]*v1.Secret, error) {

v2/api/dbforpostgresql/customizations/flexible_server_extensions.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ func secretsSpecified(obj *postgresql.FlexibleServer) bool {
6767
}
6868

6969
operatorSecrets := obj.Spec.OperatorSpec.Secrets
70-
if operatorSecrets.FullyQualifiedDomainName != nil {
71-
return true
72-
}
73-
74-
return false
70+
return operatorSecrets.FullyQualifiedDomainName != nil
7571
}
7672

7773
func secretsToWrite(obj *postgresql.FlexibleServer) ([]*v1.Secret, error) {

v2/api/machinelearningservices/customizations/workspace_extension.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ func secretsToWrite(obj *storage.Workspace, keysResp armmachinelearning.ListWork
124124
collector.AddValue(operatorSpecSecrets.PrimaryNotebookAccessKey, to.Value(keysResp.NotebookAccessKeys.PrimaryAccessKey))
125125
collector.AddValue(operatorSpecSecrets.SecondaryNotebookAccessKey, to.Value(keysResp.NotebookAccessKeys.SecondaryAccessKey))
126126
}
127-
if keysResp.ContainerRegistryCredentials != nil {
128-
}
129127

130128
return collector.Values()
131129
}

v2/api/network/customizations/private_endpoints_extensions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (extension *PrivateEndpointExtension) ExportKubernetesResources(
9090
return nil, nil
9191
}
9292

93-
if endpoint.Status.NetworkInterfaces == nil || len(endpoint.Status.NetworkInterfaces) == 0 {
93+
if len(endpoint.Status.NetworkInterfaces) == 0 {
9494
log.V(Debug).Info("no configmap retrieval to perform as there are no NetworkInterfaces attached")
9595
return nil, nil
9696
}

v2/cmd/asoctl/internal/importing/resource_importer_report.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ const (
3737
Failed resourceImportReportStatus = "Failed"
3838
)
3939

40-
var resourceImportReportStatusOrder = map[resourceImportReportStatus]int{
41-
Imported: 0,
42-
Skipped: 1,
43-
Failed: 2,
44-
}
45-
4640
// newResourceImportReport creates a new resourceImportReport
4741
func newResourceImportReport() *resourceImportReport {
4842
return &resourceImportReport{

v2/cmd/controller/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
func main() {
1919
setupLog := ctrl.Log.WithName("setup")
20-
ctrl.SetLogger(klogr.New())
20+
ctrl.SetLogger(klogr.New()) //nolint: staticcheck
2121
ctx := ctrl.SetupSignalHandler()
2222

2323
flgs, err := app.ParseFlags(os.Args)

v2/internal/controllers/cdn_profile_afd_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import (
1212

1313
cdn "github.com/Azure/azure-service-operator/v2/api/cdn/v1api20230501"
1414
frontdoor "github.com/Azure/azure-service-operator/v2/api/network.frontdoor/v1api20220501"
15-
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
16-
1715
"github.com/Azure/azure-service-operator/v2/internal/testcommon"
1816
"github.com/Azure/azure-service-operator/v2/internal/util/to"
1917
)
@@ -127,17 +125,6 @@ func Test_CDN_Profile_AFD_CRUD(t *testing.T) {
127125
tc.Expect(profile.Status.Id).To(tc.MatchAzure.BeDeleted(string(cdn.APIVersion_Value)))
128126
}
129127

130-
func expectCDNDeleteSucceeds(tc *testcommon.KubePerTestContext, obj genruntime.ARMMetaObject, id string) {
131-
tc.DeleteResourceAndWait(obj)
132-
133-
exists, _, err := tc.AzureClient.CheckExistenceWithGetByID(
134-
tc.Ctx,
135-
id,
136-
string(cdn.APIVersion_Value))
137-
tc.Expect(err).ToNot(HaveOccurred())
138-
tc.Expect(exists).To(BeFalse())
139-
}
140-
141128
func newAFDEndpoint(tc *testcommon.KubePerTestContext, profile *cdn.Profile) *cdn.AfdEndpoint {
142129
return &cdn.AfdEndpoint{
143130
ObjectMeta: tc.MakeObjectMeta("cdn-endpoint"),

0 commit comments

Comments
 (0)