Skip to content

Commit

Permalink
ci(deps): update golangci-lint-action and enable testifylint linter o…
Browse files Browse the repository at this point in the history
…n "integration/*" (#6706)

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored May 17, 2024
1 parent afb4f9d commit 903bd69
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 105 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ jobs:

- name: Lint
id: lint
uses: golangci/golangci-lint-action@v4.0.0
uses: golangci/golangci-lint-action@v6.0.1
with:
version: v1.57
args: --timeout=30m --out-format=line-number
skip-cache: true # https://github.com/golangci/golangci-lint-action/issues/244#issuecomment-1052197778
args: --verbose --out-format=line-number
if: matrix.operating-system == 'ubuntu-latest'

- name: Check if linter failed
Expand Down
5 changes: 1 addition & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ linters-settings:
testifylint:
enable-all: true
disable:
- bool-compare
- expected-actual
- float-compare
- len
- require-error

linters:
Expand All @@ -98,11 +95,11 @@ linters:

run:
go: '1.22'
timeout: 30m

issues:
exclude-files:
- ".*_mock.go$"
- "integration/*"
- "examples/*"
exclude-dirs:
- "pkg/iac/scanners/terraform/parser/funcs" # copies of Terraform functions
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/analyzer/buildinfo/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Test_dockerfileAnalyzer_Analyze(t *testing.T) {

if tt.wantErr != "" {
require.Error(t, err)
assert.Equal(t, err.Error(), tt.wantErr)
assert.Equal(t, tt.wantErr, err.Error())
return
}
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/analyzer/language/nodejs/license/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func Test_IsLicenseRefToFile(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ok, licenseFileName := license.IsLicenseRefToFile(tt.input)
assert.Equal(t, ok, tt.wantOk)
assert.Equal(t, tt.wantOk, ok)
assert.Equal(t, tt.wantFileName, licenseFileName)
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/flag/kubernetes_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestOptionToToleration(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
got, err := optionToTolerations(tt.tolerationsOptions)
assert.NoError(t, err)
assert.Equal(t, got, tt.want)
assert.Equal(t, tt.want, got)
})
}
}
4 changes: 2 additions & 2 deletions pkg/iac/adapters/arm/storage/adapt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Test_AdaptStorageDefaults(t *testing.T) {

account := output.Accounts[0]
assert.Equal(t, "TLS1_0", account.MinimumTLSVersion.Value())
assert.Equal(t, false, account.EnforceHTTPS.Value())
assert.False(t, account.EnforceHTTPS.Value())

}

Expand All @@ -53,6 +53,6 @@ func Test_AdaptStorage(t *testing.T) {

account := output.Accounts[0]
assert.Equal(t, "TLS1_2", account.MinimumTLSVersion.Value())
assert.Equal(t, true, account.EnforceHTTPS.Value())
assert.True(t, account.EnforceHTTPS.Value())

}
2 changes: 1 addition & 1 deletion pkg/iac/adapters/terraform/aws/s3/adapt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ resource "aws_s3_bucket_public_access_block" "example_access_block"{
modules := tftestutil.CreateModulesFromSource(t, tC.source, ".tf")
s3Ctx := Adapt(modules)

assert.Equal(t, tC.expectedBuckets, len(s3Ctx.Buckets))
assert.Len(t, s3Ctx.Buckets, tC.expectedBuckets)

for _, bucket := range s3Ctx.Buckets {
if tC.hasPublicAccess {
Expand Down
34 changes: 17 additions & 17 deletions pkg/iac/adapters/terraform/aws/s3/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "aws_s3_bucket" "bucket1" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)

}

Expand All @@ -38,7 +38,7 @@ resource "aws_s3_bucket" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.Equal(t, "authenticated-read", s3.Buckets[0].ACL.Value())

}
Expand All @@ -58,7 +58,7 @@ resource "aws_s3_bucket_acl" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.Equal(t, "authenticated-read", s3.Buckets[0].ACL.Value())

}
Expand All @@ -80,7 +80,7 @@ resource "aws_s3_bucket" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.True(t, s3.Buckets[0].Logging.Enabled.Value())

}
Expand Down Expand Up @@ -110,7 +110,7 @@ resource "aws_s3_bucket_logging" "example" {

s3 := Adapt(modules)

assert.Equal(t, 2, len(s3.Buckets))
assert.Len(t, s3.Buckets, 2)
for _, bucket := range s3.Buckets {
switch bucket.Name.Value() {
case "yournamehere":
Expand All @@ -135,7 +135,7 @@ resource "aws_s3_bucket" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.True(t, s3.Buckets[0].Versioning.Enabled.Value())
}

Expand All @@ -157,7 +157,7 @@ resource "aws_s3_bucket_versioning" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.True(t, s3.Buckets[0].Versioning.Enabled.Value())
}

Expand All @@ -174,7 +174,7 @@ resource "aws_s3_bucket" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.True(t, s3.Buckets[0].Versioning.Enabled.Value())

}
Expand All @@ -194,7 +194,7 @@ resource "aws_s3_bucket_object_lock_configuration" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.True(t, s3.Buckets[0].Versioning.Enabled.Value())

}
Expand All @@ -220,7 +220,7 @@ resource "aws_s3_bucket_versioning" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.True(t, s3.Buckets[0].Versioning.Enabled.Value())

}
Expand All @@ -245,7 +245,7 @@ func Test_BucketGetEncryption(t *testing.T) {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.True(t, s3.Buckets[0].Encryption.Enabled.Value())
}

Expand Down Expand Up @@ -273,7 +273,7 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "example" {

s3 := Adapt(modules)

assert.Equal(t, 1, len(s3.Buckets))
assert.Len(t, s3.Buckets, 1)
assert.True(t, s3.Buckets[0].Encryption.Enabled.Value())
}

Expand Down Expand Up @@ -312,19 +312,19 @@ data "aws_iam_policy_document" "allow_access_from_another_account" {

s3 := Adapt(modules)

require.Equal(t, 1, len(s3.Buckets))
require.Equal(t, 1, len(s3.Buckets[0].BucketPolicies))
require.Len(t, s3.Buckets, 1)
require.Len(t, s3.Buckets[0].BucketPolicies, 1)

policy := s3.Buckets[0].BucketPolicies[0]

statements, _ := policy.Document.Parsed.Statements()
require.Equal(t, 1, len(statements))
require.Len(t, statements, 1)

principals, _ := statements[0].Principals()
actions, _ := statements[0].Actions()

awsPrincipals, _ := principals.AWS()
require.Equal(t, 1, len(awsPrincipals))
require.Equal(t, 2, len(actions))
require.Len(t, awsPrincipals, 1)
require.Len(t, actions, 2)

}
Loading

0 comments on commit 903bd69

Please sign in to comment.