Skip to content

Commit eefce0b

Browse files
committed
Add "Since" suffix to timestamp linter
1 parent 772d5cd commit eefce0b

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

docs/source-2.0/guides/model-linters.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ A name is assumed to represent a time value if it:
777777
* Begins or ends with the word "date"
778778
* Ends with the word "at"
779779
* Ends with the word "on"
780+
* Ends with the word "since"
780781
* Contains the exact string "timestamp" or "Timestamp"
781782

782783
For the purpose of this validator, words are matched case insensitively. Words

smithy-linters/src/main/java/software/amazon/smithy/linters/ShouldHaveUsedTimestampValidator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* <li>Begins or Ends with the word "date"</li>
4646
* <li>Ends with the word "at"</li>
4747
* <li>Ends with the word "on"</li>
48+
* <li>Ends with the word "since"</li>
4849
* </ul>
4950
*
5051
* <p>When checking for one of the above words, the first character may be
@@ -87,7 +88,8 @@ public Provider() {
8788
Pattern.compile("^.*([a-z]T|_[Tt])ime$"), // ends with the word "time"
8889
Pattern.compile("^.*([a-z]D|_[Dd])ate$"), // ends with the word "date"
8990
Pattern.compile("^.*([a-z]A|_[Aa])t$"), // ends with the word "at"
90-
Pattern.compile("^.*([a-z]O|_[Oo])n$") // ends with the word "on"
91+
Pattern.compile("^.*([a-z]O|_[Oo])n$"), // ends with the word "on"
92+
Pattern.compile("^.*([a-z]S|_[Ss])ince$") // ends with the word "since"
9193
);
9294

9395
private final List<Pattern> patterns = new ArrayList<>(DEFAULT_PATTERNS);

smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/should-have-used-timestamp.errors

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
[DANGER] example.namespace#OopsString: Shape `OopsString` is named like a timestamp but is a `string` shape. | ShouldHaveUsedTimestamp
1212
[DANGER] example.namespace#StartedAt: Shape `StartedAt` is named like a timestamp but is a `string` shape. | ShouldHaveUsedTimestamp
1313
[DANGER] example.namespace#StartedOn: Shape `StartedOn` is named like a timestamp but is a `string` shape. | ShouldHaveUsedTimestamp
14+
[DANGER] example.namespace#IfModifiedSince: Shape `IfModifiedSince` is named like a timestamp but is a `string` shape. | ShouldHaveUsedTimestamp
1415
[DANGER] example.namespace#Structure$OopsStructureMember: Member `OopsStructureMember` is named like a timestamp but references a `string` shape | ShouldHaveUsedTimestamp
1516
[DANGER] example.namespace#TaggedUnion$OopsTaggedUnionMember: Member `OopsTaggedUnionMember` is named like a timestamp but references a `string` shape | ShouldHaveUsedTimestamp
1617
[DANGER] example.namespace#Time: Shape `Time` is named like a timestamp but is a `string` shape. | ShouldHaveUsedTimestamp

smithy-linters/src/test/resources/software/amazon/smithy/linters/errorfiles/should-have-used-timestamp.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
},
7171
"example.namespace#StartedOn": {
7272
"type": "string"
73+
},
74+
"example.namespace#IfModifiedSince": {
75+
"type": "string"
7376
}
7477
},
7578
"metadata": {

0 commit comments

Comments
 (0)