Skip to content

Commit e49da06

Browse files
Add fields to warnings and errors
- Add code field to Proposal.Issue - Add suggestion field to Proposal.Issue - Update test snapshots with new expected resuls
1 parent 0ebf0b3 commit e49da06

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

Sources/EvolutionMetadataModel/Proposal+Issue.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ extension Proposal {
1818
/// Kind of issue, warning or error
1919
public let kind: Kind
2020

21+
/// Numeric code to identify the issue
22+
public let code: Int
23+
2124
/// Processing stage where the issue was detected.
2225
public let stage: Stage
2326

2427
/// Message describing the issue
2528
public let message: String
26-
29+
30+
/// Suggestion for addressing the issue
31+
public let suggestion: String
32+
2733
public enum Kind: String, Equatable, Sendable, Codable {
2834
case warning
2935
case error
@@ -34,10 +40,12 @@ extension Proposal {
3440
case validate
3541
}
3642

37-
public init(kind: Kind, stage: Stage, message: String) {
43+
public init(kind: Kind, code: Int = 0, stage: Stage, message: String, suggestion: String = "") {
3844
self.kind = kind
45+
self.code = code
3946
self.message = message
4047
self.stage = stage
48+
self.suggestion = suggestion
4149
}
4250
}
4351
}

Tests/ExtractionTests/Resources/AllProposals.evosnapshot/expected-results.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141
],
4242
"warnings" : [
4343
{
44+
"code" : 0,
4445
"kind" : "warning",
4546
"message" : "Missing review manager.",
47+
"suggestion" : "",
4648
"stage" : "parse"
4749
}
4850
]
@@ -77,8 +79,10 @@
7779
"title" : "Removing currying `func` declaration syntax",
7880
"warnings" : [
7981
{
82+
"code" : 0,
8083
"kind" : "warning",
8184
"message" : "Missing review manager.",
85+
"suggestion" : "",
8286
"stage" : "parse"
8387
}
8488
]
@@ -142,8 +146,10 @@
142146
"title" : "Remove the `++` and `--` operators",
143147
"warnings" : [
144148
{
149+
"code" : 0,
145150
"kind" : "warning",
146151
"message" : "Missing review manager.",
152+
"suggestion" : "",
147153
"stage" : "parse"
148154
}
149155
]
@@ -13367,8 +13373,10 @@
1336713373
"title" : "Dynamic actor isolation enforcement from non-strict-concurrency contexts",
1336813374
"warnings" : [
1336913375
{
13376+
"code" : 0,
1337013377
"kind" : "warning",
1337113378
"message" : "Review ended on 2024-03-01 00:00:00 +0000.",
13379+
"suggestion" : "",
1337213380
"stage" : "validate"
1337313381
}
1337413382
]
@@ -13486,8 +13494,10 @@
1348613494
"title" : "Noncopyable Generics",
1348713495
"warnings" : [
1348813496
{
13497+
"code" : 0,
1348913498
"kind" : "warning",
1349013499
"message" : "Review ended on 2024-03-22 00:00:00 +0000.",
13500+
"suggestion" : "",
1349113501
"stage" : "validate"
1349213502
}
1349313503
]
@@ -13527,8 +13537,10 @@
1352713537
"title" : "Resolve DistributedActor protocols",
1352813538
"warnings" : [
1352913539
{
13540+
"code" : 0,
1353013541
"kind" : "warning",
1353113542
"message" : "Review ended on 2024-03-26 00:00:00 +0000.",
13543+
"suggestion" : "",
1353213544
"stage" : "validate"
1353313545
}
1353413546
]
@@ -13560,8 +13572,10 @@
1356013572
"title" : "Partial consumption of noncopyable values",
1356113573
"warnings" : [
1356213574
{
13575+
"code" : 0,
1356313576
"kind" : "warning",
1356413577
"message" : "Review ended on 2024-03-26 00:00:00 +0000.",
13578+
"suggestion" : "",
1356513579
"stage" : "validate"
1356613580
}
1356713581
]

Tests/ExtractionTests/Resources/Malformed.evosnapshot/expected-results.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
],
1515
"errors" : [
1616
{
17+
"code" : 0,
1718
"kind" : "error",
1819
"message" : "Missing valid proposal ID; SE-0000 is reserved.",
20+
"suggestion" : "",
1921
"stage" : "validate"
2022
}
2123
],
@@ -46,8 +48,10 @@
4648
],
4749
"warnings" : [
4850
{
51+
"code" : 0,
4952
"kind" : "warning",
5053
"message" : "Missing review manager.",
54+
"suggestion" : "",
5155
"stage" : "parse"
5256
}
5357
]
@@ -61,8 +65,10 @@
6165
],
6266
"errors" : [
6367
{
68+
"code" : 0,
6469
"kind" : "error",
6570
"message" : "Missing proposal ID link (SE-NNNN)[NNNN-filename.md].",
71+
"suggestion" : "",
6672
"stage" : "parse"
6773
}
6874
],
@@ -93,8 +99,10 @@
9399
],
94100
"warnings" : [
95101
{
102+
"code" : 0,
96103
"kind" : "warning",
97104
"message" : "Missing review manager.",
105+
"suggestion" : "",
98106
"stage" : "parse"
99107
}
100108
]
@@ -104,8 +112,10 @@
104112
],
105113
"errors" : [
106114
{
115+
"code" : 0,
107116
"kind" : "error",
108117
"message" : "Missing list of metadata fields.",
118+
"suggestion" : "",
109119
"stage" : "parse"
110120
}
111121
],
@@ -153,8 +163,10 @@
153163
"title" : "Removing `var` from Function Parameters",
154164
"warnings" : [
155165
{
166+
"code" : 0,
156167
"kind" : "warning",
157168
"message" : "Status not found in the proposal's details list.",
169+
"suggestion" : "",
158170
"stage" : "parse"
159171
}
160172
]
@@ -168,8 +180,10 @@
168180
],
169181
"errors" : [
170182
{
183+
"code" : 0,
171184
"kind" : "error",
172185
"message" : "Missing or invalid proposal status.",
186+
"suggestion" : "",
173187
"stage" : "parse"
174188
}
175189
],
@@ -196,8 +210,10 @@
196210
"title" : "Remove the `++` and `--` operators",
197211
"warnings" : [
198212
{
213+
"code" : 0,
199214
"kind" : "warning",
200215
"message" : "Missing review manager.",
216+
"suggestion" : "",
201217
"stage" : "parse"
202218
}
203219
]
@@ -228,8 +244,10 @@
228244
"title" : "Better Translation of Objective-C APIs Into Swift",
229245
"warnings" : [
230246
{
247+
"code" : 0,
231248
"kind" : "warning",
232249
"message" : "Status not found in the proposal's details list.",
250+
"suggestion" : "",
233251
"stage" : "parse"
234252
}
235253
]
@@ -268,8 +286,10 @@
268286
],
269287
"errors" : [
270288
{
289+
"code" : 0,
271290
"kind" : "error",
272291
"message" : "Proposal Markdown file is empty.",
292+
"suggestion" : "",
273293
"stage" : "parse"
274294
}
275295
],
@@ -292,8 +312,10 @@
292312
],
293313
"errors" : [
294314
{
315+
"code" : 0,
295316
"kind" : "error",
296317
"message" : "Proposal Markdown file is empty.",
318+
"suggestion" : "",
297319
"stage" : "parse"
298320
}
299321
],
@@ -320,8 +342,10 @@
320342
],
321343
"errors" : [
322344
{
345+
"code" : 0,
323346
"kind" : "error",
324347
"message" : "Proposal contains no content.",
348+
"suggestion" : "",
325349
"stage" : "parse"
326350
}
327351
],
@@ -347,8 +371,10 @@
347371
],
348372
"errors" : [
349373
{
374+
"code" : 0,
350375
"kind" : "error",
351376
"message" : "Proposal ID must include four decimal digits.",
377+
"suggestion" : "",
352378
"stage" : "parse"
353379
}
354380
],
@@ -370,8 +396,10 @@
370396
],
371397
"errors" : [
372398
{
399+
"code" : 0,
373400
"kind" : "error",
374401
"message" : "Missing author(s).",
402+
"suggestion" : "",
375403
"stage" : "parse"
376404
}
377405
],
@@ -424,8 +452,10 @@
424452
"title" : "Remove Partial Application of Non-Final Super Methods (Swift 2.2)",
425453
"warnings" : [
426454
{
455+
"code" : 0,
427456
"kind" : "warning",
428457
"message" : "Missing or invalid dates for a review period.",
458+
"suggestion" : "",
429459
"stage" : "parse"
430460
}
431461
]
@@ -465,8 +495,10 @@
465495
],
466496
"warnings" : [
467497
{
498+
"code" : 0,
468499
"kind" : "warning",
469500
"message" : "Missing or invalid dates for a review period.",
501+
"suggestion" : "",
470502
"stage" : "parse"
471503
}
472504
]
@@ -542,8 +574,10 @@
542574
],
543575
"errors" : [
544576
{
577+
"code" : 0,
545578
"kind" : "error",
546579
"message" : "Author name contains extra markup; expected a link with plaintext contents.",
580+
"suggestion" : "",
547581
"stage" : "parse"
548582
}
549583
],
@@ -615,8 +649,10 @@
615649
],
616650
"warnings" : [
617651
{
652+
"code" : 0,
618653
"kind" : "warning",
619654
"message" : "Proposal ID contains extra markup; expected a link with plaintext contents.",
655+
"suggestion" : "",
620656
"stage" : "parse"
621657
}
622658
]
@@ -657,8 +693,10 @@
657693
"title" : "Swift Language Version Build Configuration",
658694
"warnings" : [
659695
{
696+
"code" : 0,
660697
"kind" : "warning",
661698
"message" : "Implementation links to a non-Swift repository.",
699+
"suggestion" : "",
662700
"stage" : "validate"
663701
}
664702
]
@@ -685,8 +723,10 @@
685723
"title" : "Naming Functions with Argument Labels",
686724
"warnings" : [
687725
{
726+
"code" : 0,
688727
"kind" : "warning",
689728
"message" : "Implementation links to a non-Swift repository.",
729+
"suggestion" : "",
690730
"stage" : "validate"
691731
}
692732
]
@@ -721,8 +761,10 @@
721761
"title" : "Referencing the Objective-C selector of a method",
722762
"warnings" : [
723763
{
764+
"code" : 0,
724765
"kind" : "warning",
725766
"message" : "Review manager's link doesn't refer to a GitHub profile. Link removed.",
767+
"suggestion" : "",
726768
"stage" : "validate"
727769
}
728770
]
@@ -781,8 +823,10 @@
781823
"title" : "API Design Guidelines",
782824
"warnings" : [
783825
{
826+
"code" : 0,
784827
"kind" : "warning",
785828
"message" : "Author's link doesn't refer to a GitHub profile. Link removed.",
829+
"suggestion" : "",
786830
"stage" : "validate"
787831
}
788832
]
@@ -810,8 +854,10 @@
810854
"title" : "Optional Value Setter `??=`",
811855
"warnings" : [
812856
{
857+
"code" : 0,
813858
"kind" : "warning",
814859
"message" : "Review ended on 2024-01-05 00:00:00 +0000.",
860+
"suggestion" : "",
815861
"stage" : "validate"
816862
}
817863
]
@@ -851,8 +897,10 @@
851897
],
852898
"warnings" : [
853899
{
900+
"code" : 0,
854901
"kind" : "warning",
855902
"message" : "Review ended on 2024-01-31 00:00:00 +0000.",
903+
"suggestion" : "",
856904
"stage" : "validate"
857905
}
858906
]

0 commit comments

Comments
 (0)