Skip to content

Commit

Permalink
rules: Use EmitIssueOnExpr when emitting an issue for an expression (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Nov 6, 2021
1 parent ae135f5 commit ed75fbe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions rules/aws_elasticache_cluster_previous_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func (r *AwsElastiCacheClusterPreviousTypeRule) Check(runner tflint.Runner) erro

return runner.EnsureNoError(err, func() error {
if r.previousNodeTypes[nodeType] {
runner.EmitIssue(
runner.EmitIssueOnExpr(
r,
fmt.Sprintf("\"%s\" is previous generation node type.", nodeType),
attribute.Expr.Range(),
attribute.Expr,
)
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions rules/aws_elasticache_replication_group_previous_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func (r *AwsElastiCacheReplicationGroupPreviousTypeRule) Check(runner tflint.Run

return runner.EnsureNoError(err, func() error {
if r.previousNodeTypes[nodeType] {
runner.EmitIssue(
runner.EmitIssueOnExpr(
r,
fmt.Sprintf("\"%s\" is previous generation node type.", nodeType),
attribute.Expr.Range(),
attribute.Expr,
)
}
return nil
Expand Down
8 changes: 4 additions & 4 deletions rules/aws_s3_bucket_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ func (r *AwsS3BucketNameRule) Check(runner tflint.Runner) error {
return runner.EnsureNoError(err, func() error {
if config.Prefix != "" {
if !strings.HasPrefix(name, config.Prefix) {
runner.EmitIssue(
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`Bucket name "%s" does not have prefix "%s"`, name, config.Prefix),
attribute.Expr.Range(),
attribute.Expr,
)
}
}

if config.Regex != "" {
if !regex.MatchString(name) {
runner.EmitIssue(
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`Bucket name "%s" does not match regex "%s"`, name, config.Regex),
attribute.Expr.Range(),
attribute.Expr,
)
}
}
Expand Down

0 comments on commit ed75fbe

Please sign in to comment.