Skip to content

Commit 24c37c5

Browse files
committed
Improve generator code quality
- Remove unnecessary pattern fallbacks (no longer present in Smithy models) - Add type-safe Smithy shape parsing with dedicated structs - Replace map[string]interface{} casting with JSON unmarshaling - Reduce potential panic points from ~20 type assertions to 0 All tests passing. No functional changes to generated code.
1 parent 5327171 commit 24c37c5

File tree

73 files changed

+225
-213
lines changed

Some content is hidden

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

73 files changed

+225
-213
lines changed

rules/models/aws_amplify_app_invalid_basic_auth_credentials.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func NewAwsAmplifyAppInvalidBasicAuthCredentialsRule() *AwsAmplifyAppInvalidBasi
2626
resourceType: "aws_amplify_app",
2727
attributeName: "basic_auth_credentials",
2828
max: 2000,
29-
pattern: regexp.MustCompile(`^(?s).*$`),
29+
pattern: regexp.MustCompile(`^(?s)`),
3030
}
3131
}
3232

@@ -80,7 +80,7 @@ func (r *AwsAmplifyAppInvalidBasicAuthCredentialsRule) Check(runner tflint.Runne
8080
if !r.pattern.MatchString(val) {
8181
runner.EmitIssue(
8282
r,
83-
`basic_auth_credentials does not match valid pattern ^(?s).*$`,
83+
`basic_auth_credentials does not match valid pattern ^(?s)`,
8484
attribute.Expr.Range(),
8585
)
8686
}

rules/models/aws_amplify_app_invalid_description.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewAwsAmplifyAppInvalidDescriptionRule() *AwsAmplifyAppInvalidDescriptionRu
2727
resourceType: "aws_amplify_app",
2828
attributeName: "description",
2929
max: 1000,
30-
pattern: regexp.MustCompile(`^(?s).*$`),
30+
pattern: regexp.MustCompile(`^(?s)`),
3131
}
3232
}
3333

@@ -81,7 +81,7 @@ func (r *AwsAmplifyAppInvalidDescriptionRule) Check(runner tflint.Runner) error
8181
if !r.pattern.MatchString(val) {
8282
runner.EmitIssue(
8383
r,
84-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s).*$`),
84+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s)`),
8585
attribute.Expr.Range(),
8686
)
8787
}

rules/models/aws_amplify_app_invalid_iam_service_role_arn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewAwsAmplifyAppInvalidIAMServiceRoleArnRule() *AwsAmplifyAppInvalidIAMServ
2727
resourceType: "aws_amplify_app",
2828
attributeName: "iam_service_role_arn",
2929
max: 1000,
30-
pattern: regexp.MustCompile(`^(?s).*$`),
30+
pattern: regexp.MustCompile(`^(?s)`),
3131
}
3232
}
3333

@@ -81,7 +81,7 @@ func (r *AwsAmplifyAppInvalidIAMServiceRoleArnRule) Check(runner tflint.Runner)
8181
if !r.pattern.MatchString(val) {
8282
runner.EmitIssue(
8383
r,
84-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s).*$`),
84+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s)`),
8585
attribute.Expr.Range(),
8686
)
8787
}

rules/models/aws_amplify_app_invalid_oauth_token.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func NewAwsAmplifyAppInvalidOAuthTokenRule() *AwsAmplifyAppInvalidOAuthTokenRule
2626
resourceType: "aws_amplify_app",
2727
attributeName: "oauth_token",
2828
max: 1000,
29-
pattern: regexp.MustCompile(`^(?s).*$`),
29+
pattern: regexp.MustCompile(`^(?s)`),
3030
}
3131
}
3232

@@ -80,7 +80,7 @@ func (r *AwsAmplifyAppInvalidOAuthTokenRule) Check(runner tflint.Runner) error {
8080
if !r.pattern.MatchString(val) {
8181
runner.EmitIssue(
8282
r,
83-
`oauth_token does not match valid pattern ^(?s).*$`,
83+
`oauth_token does not match valid pattern ^(?s)`,
8484
attribute.Expr.Range(),
8585
)
8686
}

rules/models/aws_amplify_app_invalid_repository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewAwsAmplifyAppInvalidRepositoryRule() *AwsAmplifyAppInvalidRepositoryRule
2727
resourceType: "aws_amplify_app",
2828
attributeName: "repository",
2929
max: 1000,
30-
pattern: regexp.MustCompile(`^(?s).*$`),
30+
pattern: regexp.MustCompile(`^(?s)`),
3131
}
3232
}
3333

@@ -81,7 +81,7 @@ func (r *AwsAmplifyAppInvalidRepositoryRule) Check(runner tflint.Runner) error {
8181
if !r.pattern.MatchString(val) {
8282
runner.EmitIssue(
8383
r,
84-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s).*$`),
84+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s)`),
8585
attribute.Expr.Range(),
8686
)
8787
}

rules/models/aws_amplify_branch_invalid_backend_environment_arn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewAwsAmplifyBranchInvalidBackendEnvironmentArnRule() *AwsAmplifyBranchInva
2727
resourceType: "aws_amplify_branch",
2828
attributeName: "backend_environment_arn",
2929
max: 1000,
30-
pattern: regexp.MustCompile(`^(?s).*$`),
30+
pattern: regexp.MustCompile(`^(?s)`),
3131
}
3232
}
3333

@@ -81,7 +81,7 @@ func (r *AwsAmplifyBranchInvalidBackendEnvironmentArnRule) Check(runner tflint.R
8181
if !r.pattern.MatchString(val) {
8282
runner.EmitIssue(
8383
r,
84-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s).*$`),
84+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s)`),
8585
attribute.Expr.Range(),
8686
)
8787
}

rules/models/aws_amplify_branch_invalid_basic_auth_credentials.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func NewAwsAmplifyBranchInvalidBasicAuthCredentialsRule() *AwsAmplifyBranchInval
2626
resourceType: "aws_amplify_branch",
2727
attributeName: "basic_auth_credentials",
2828
max: 2000,
29-
pattern: regexp.MustCompile(`^(?s).*$`),
29+
pattern: regexp.MustCompile(`^(?s)`),
3030
}
3131
}
3232

@@ -80,7 +80,7 @@ func (r *AwsAmplifyBranchInvalidBasicAuthCredentialsRule) Check(runner tflint.Ru
8080
if !r.pattern.MatchString(val) {
8181
runner.EmitIssue(
8282
r,
83-
`basic_auth_credentials does not match valid pattern ^(?s).*$`,
83+
`basic_auth_credentials does not match valid pattern ^(?s)`,
8484
attribute.Expr.Range(),
8585
)
8686
}

rules/models/aws_amplify_branch_invalid_description.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewAwsAmplifyBranchInvalidDescriptionRule() *AwsAmplifyBranchInvalidDescrip
2727
resourceType: "aws_amplify_branch",
2828
attributeName: "description",
2929
max: 1000,
30-
pattern: regexp.MustCompile(`^(?s).*$`),
30+
pattern: regexp.MustCompile(`^(?s)`),
3131
}
3232
}
3333

@@ -81,7 +81,7 @@ func (r *AwsAmplifyBranchInvalidDescriptionRule) Check(runner tflint.Runner) err
8181
if !r.pattern.MatchString(val) {
8282
runner.EmitIssue(
8383
r,
84-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s).*$`),
84+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s)`),
8585
attribute.Expr.Range(),
8686
)
8787
}

rules/models/aws_amplify_branch_invalid_display_name.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewAwsAmplifyBranchInvalidDisplayNameRule() *AwsAmplifyBranchInvalidDisplay
2727
resourceType: "aws_amplify_branch",
2828
attributeName: "display_name",
2929
max: 255,
30-
pattern: regexp.MustCompile(`^(?s).*$`),
30+
pattern: regexp.MustCompile(`^(?s)`),
3131
}
3232
}
3333

@@ -81,7 +81,7 @@ func (r *AwsAmplifyBranchInvalidDisplayNameRule) Check(runner tflint.Runner) err
8181
if !r.pattern.MatchString(val) {
8282
runner.EmitIssue(
8383
r,
84-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s).*$`),
84+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s)`),
8585
attribute.Expr.Range(),
8686
)
8787
}

rules/models/aws_amplify_branch_invalid_framework.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewAwsAmplifyBranchInvalidFrameworkRule() *AwsAmplifyBranchInvalidFramework
2727
resourceType: "aws_amplify_branch",
2828
attributeName: "framework",
2929
max: 255,
30-
pattern: regexp.MustCompile(`^(?s).*$`),
30+
pattern: regexp.MustCompile(`^(?s)`),
3131
}
3232
}
3333

@@ -81,7 +81,7 @@ func (r *AwsAmplifyBranchInvalidFrameworkRule) Check(runner tflint.Runner) error
8181
if !r.pattern.MatchString(val) {
8282
runner.EmitIssue(
8383
r,
84-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s).*$`),
84+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(?s)`),
8585
attribute.Expr.Range(),
8686
)
8787
}

0 commit comments

Comments
 (0)