Skip to content

Commit

Permalink
Merge pull request #37511 from hashicorp/t-acctest-literal-value2-val…
Browse files Browse the repository at this point in the history
…ue1-TRUE-FALSE-key1-key2-string-constant

ci: Prefer constants for test string literals
  • Loading branch information
YakDriver authored May 14, 2024
2 parents 7712b6e + 86eb0c2 commit f6efa6c
Show file tree
Hide file tree
Showing 608 changed files with 5,278 additions and 5,183 deletions.
60 changes: 60 additions & 0 deletions .ci/.semgrep-test-constants.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Generated by internal/generate/acctestconsts/main.go; DO NOT EDIT.
rules:
- id: literal-FalseCaps-string-test-constant
languages: [go]
message: Use the constant `acctest.CtFalseCaps` for the string literal "FALSE"
paths:
include:
- "internal/service/**/*_test.go"
patterns:
- pattern: '"FALSE"'
severity: ERROR
fix: "acctest.CtFalseCaps"
- id: literal-Key1-string-test-constant
languages: [go]
message: Use the constant `acctest.CtKey1` for the string literal "key1"
paths:
include:
- "internal/service/**/*_test.go"
patterns:
- pattern: '"key1"'
severity: ERROR
fix: "acctest.CtKey1"
- id: literal-Key2-string-test-constant
languages: [go]
message: Use the constant `acctest.CtKey2` for the string literal "key2"
paths:
include:
- "internal/service/**/*_test.go"
patterns:
- pattern: '"key2"'
severity: ERROR
fix: "acctest.CtKey2"
- id: literal-One-string-test-constant
languages: [go]
message: Use the constant `acctest.CtOne` for the string literal "1"
Expand All @@ -20,6 +50,16 @@ rules:
- pattern: '"tags.%"'
severity: ERROR
fix: "acctest.CtTagsPercent"
- id: literal-TrueCaps-string-test-constant
languages: [go]
message: Use the constant `acctest.CtTrueCaps` for the string literal "TRUE"
paths:
include:
- "internal/service/**/*_test.go"
patterns:
- pattern: '"TRUE"'
severity: ERROR
fix: "acctest.CtTrueCaps"
- id: literal-Two-string-test-constant
languages: [go]
message: Use the constant `acctest.CtTwo` for the string literal "2"
Expand All @@ -30,6 +70,26 @@ rules:
- pattern: '"2"'
severity: ERROR
fix: "acctest.CtTwo"
- id: literal-Value1-string-test-constant
languages: [go]
message: Use the constant `acctest.CtValue1` for the string literal "value1"
paths:
include:
- "internal/service/**/*_test.go"
patterns:
- pattern: '"value1"'
severity: ERROR
fix: "acctest.CtValue1"
- id: literal-Value2-string-test-constant
languages: [go]
message: Use the constant `acctest.CtValue2` for the string literal "value2"
paths:
include:
- "internal/service/**/*_test.go"
patterns:
- pattern: '"value2"'
severity: ERROR
fix: "acctest.CtValue2"
- id: literal-Zero-string-test-constant
languages: [go]
message: Use the constant `acctest.CtZero` for the string literal "0"
Expand Down
6 changes: 6 additions & 0 deletions internal/acctest/consts.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
0,Zero
1,One
2,Two
FALSE,FalseCaps
TRUE,TrueCaps
key1,Key1
key2,Key2
tags.%,TagsPercent
value1,Value1
value2,Value2
12 changes: 12 additions & 0 deletions internal/acctest/consts_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f6efa6c

Please sign in to comment.