-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement v2->v1 conversion for rules dictionary #1228
Changes from 9 commits
76feeec
0f346de
be72499
c82cd69
841b088
46c273d
8ab228c
21c4f9b
e2ce115
713f359
f66d0b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,18 +8,18 @@ | |
"language": "en-US" | ||
}, | ||
"logicalLocations": { | ||
"collections::list::add": { | ||
"name": "add", | ||
"parentKey": "collections::list", | ||
"kind": "function" | ||
"collections": { | ||
"kind": "namespace" | ||
}, | ||
"collections::list": { | ||
"name": "list", | ||
"parentKey": "collections", | ||
"kind": "type" | ||
}, | ||
"collections": { | ||
"kind": "namespace" | ||
"collections::list::add": { | ||
"name": "add", | ||
"parentKey": "collections::list", | ||
"kind": "function" | ||
} | ||
}, | ||
"results": [ | ||
|
@@ -101,14 +101,14 @@ | |
} | ||
], | ||
"rules": { | ||
"WEB1079.AttributeValueIsNotQuoted": { | ||
"WEB1079": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When we were converting a dictionary of v2 rules to a dictionary of v1 rules, we could preserve the v2 keys in the v1 dictionary. Now that the In fact, the v2 format has no place for this "friendly compound id". If you want a place for it, we could add it to v2 rule. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This compound id is a very useful construct and highly utilized internally. I'll open a TC issue. In reply to: 249559914 [](ancestors = 249559914) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, right. These terms should be persisted to rule.name, can you go ahead and do that? still an open question whether we document using rule.id and rule.name in this way to compose a compound id (with an opaque stable and instable readable component in well known locations). In reply to: 249572234 [](ancestors = 249572234,249559914) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good idea and makes sense for this file. The problem is that the dictionary key is not always a friendly name (consider In reply to: 249572657 [](ancestors = 249572657,249572234,249559914) |
||
"id": "WEB1079", | ||
"shortDescription": "The attribute value is not quoted.", | ||
"messageFormats": { | ||
"default": "The value of the '{0}' attribute is not quoted. Wrap the attribute value in single or double quotes." | ||
} | ||
}, | ||
"WEB1066.TagNameIsNotLowercase": { | ||
"WEB1066": { | ||
"id": "WEB1066", | ||
"shortDescription": "The tag name is not lowercase.", | ||
"messageFormats": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,14 +156,14 @@ | |
} | ||
], | ||
"rules": { | ||
"WEB1079.AttributeValueIsNotQuoted": { | ||
"WEB1079": { | ||
"id": "WEB1079", | ||
"shortDescription": "The attribute value is not quoted.", | ||
"messageFormats": { | ||
"default": "The value of the '{0}' attribute is not quoted. Wrap the attribute value in single or double quotes." | ||
} | ||
}, | ||
"WEB1066.TagNameIsNotLowercase": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
same note, move the readable names to rule.name: NIT There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my response to your other comment on this issue. In reply to: 249572746 [](ancestors = 249572746) |
||
"WEB1066": { | ||
"id": "WEB1066", | ||
"shortDescription": "The tag name is not lowercase.", | ||
"messageFormats": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,25 +9,29 @@ | |
}, | ||
"results": [ | ||
{ | ||
"ruleId": "C2009", | ||
"ruleId": "C2001", | ||
"ruleIndex": 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
why couldn't the prerelease transformer fix things up for you? i.e., was there a reason you had to introduce the ruleIndex object? generally, i think we should avoid piecemeal upgrade of these files to current format. #ByDesign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In reply to: 249573084 [](ancestors = 249573084) |
||
"message": { "text": "Some testing occurred." } | ||
}, | ||
{ | ||
"ruleId": "C2002", | ||
"ruleIndex": 1, | ||
"message": { "text": "Some testing occurred." } | ||
}, | ||
{ | ||
"ruleId": "C2003", | ||
"ruleIndex": 2, | ||
"message": { "text": "Some testing occurred." } | ||
}, | ||
{ | ||
"ruleId": "C2003-1", | ||
"ruleId": "C2003", | ||
"ruleIndex": 3, | ||
"message": { "text": "Some testing occurred." } | ||
} | ||
], | ||
"resources": { | ||
"rules": { | ||
"C2001": { | ||
"rules": [ | ||
{ | ||
"id": "C2001", | ||
"shortDescription": { | ||
"text": "A variable was used without being initialized." | ||
|
@@ -39,7 +43,7 @@ | |
"some_key": "FoxForceFive" | ||
} | ||
}, | ||
"C2002": { | ||
{ | ||
"id": "C2002", | ||
"fullDescription": { | ||
"text": "Catfish season continuous hen lamb include dose copy grant." | ||
|
@@ -50,19 +54,31 @@ | |
}, | ||
"helpUri": "http://www.domain.com/rules/c2002.html" | ||
}, | ||
"C2003-1": { | ||
{ | ||
"id": "C2003", | ||
"name": { | ||
"text": "Rule C2003" | ||
"text": "Rule C2003 for C#" | ||
}, | ||
"shortDescription": { | ||
"text": "Rules were meant to be broken." | ||
"text": "C# rules were meant to be broken." | ||
}, | ||
"fullDescription": { | ||
"text": "Rent internal rebellion competence biography photograph." | ||
} | ||
}, | ||
{ | ||
"id": "C2003", | ||
"name": { | ||
"text": "Rule C2003 for VB" | ||
}, | ||
"shortDescription": { | ||
"text": "VB rules were meant to be broken." | ||
}, | ||
"fullDescription": { | ||
"text": "Rent internal rebellion competence biography photograph." | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,23 +44,21 @@ protected override string ConstructTestOutputFromInputResource(string inputResou | |
[Fact] | ||
public void SarifTransformerTests_ToVersionOne_OneRunWithFiles() => RunTest("OneRunWithFiles.sarif"); | ||
|
||
#if TRANSFORM_CODE_AUTHORED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yay! #Closed |
||
[Fact] | ||
public void SarifTransformerTests_ToVersionOne_OneRunWithRules() => RunTest("OneRunWithRules.sarif"); | ||
#endif | ||
|
||
[Fact] | ||
public void SarifTransformerTests_ToVersionOne_OneRunWithBasicInvocation() => RunTest("OneRunWithBasicInvocation.sarif"); | ||
|
||
[Fact] | ||
public void SarifTransformerTests_ToVersionOne_NotificationExceptionWithStack() => RunTest("NotificationExceptionWithStack.sarif"); | ||
|
||
#if TRANSFORM_CODE_AUTHORED | ||
[Fact] | ||
public void SarifTransformerTests_ToVersionOne_ResultLocations() => RunTest("ResultLocations.sarif"); | ||
|
||
[Fact] | ||
public void SarifTransformerTests_ToVersionOne_TwoResultsWithFixes() => RunTest("TwoResultsWithFixes.sarif"); | ||
#endif | ||
|
||
[Fact] | ||
public void SarifTransformerTests_ToVersionOne_Regions() => RunTest("Regions.sarif"); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"title": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta.2018-10-10 JSON Schema", | ||
"title": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta.2018-11-28 JSON Schema", | ||
"description": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2018-11-28 JSON Schema: a standard format for the output of static analysis tools.", | ||
"additionalProperties": false, | ||
"type": "object", | ||
|
@@ -347,7 +347,7 @@ | |
"description": "An array of external property files containing run.results arrays to be merged with the root log file.", | ||
"type": "array", | ||
"minItems": 1, | ||
"uniqueItems": true, | ||
"uniqueItems": false, | ||
"items": { | ||
"$ref": "#/definitions/externalPropertyFile" | ||
} | ||
|
@@ -1002,10 +1002,17 @@ | |
}, | ||
|
||
"ruleId": { | ||
"description": "The stable, unique identifier of the rule (if any) to which this notification is relevant. This member can be used to retrieve rule metadata from the rules dictionary, if it exists.", | ||
"description": "The stable, unique identifier of the rule, if any, to which this notification is relevant.", | ||
"type": "string" | ||
}, | ||
|
||
"ruleIndex": { | ||
"description": "The index within the run resources array of the rule object, if any, associated with this notification.", | ||
"type": "integer", | ||
"default": -1, | ||
"minimum": -1 | ||
}, | ||
|
||
"physicalLocation": { | ||
"description": "The file and region relevant to this notification.", | ||
"$ref": "#/definitions/physicalLocation" | ||
|
@@ -1274,7 +1281,7 @@ | |
"properties": { | ||
|
||
"ruleId": { | ||
"description": "The stable, unique identifier of the rule (if any) to which this notification is relevant. This member can be used to retrieve rule metadata from the rules dictionary, if it exists.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is the only place we used parens instead of commas on "if any". #ByDesign |
||
"description": "The stable, unique identifier of the rule, if any, to which this notification is relevant. This member can be used to retrieve rule metadata from the rules dictionary, if it exists.", | ||
"type": "string" | ||
}, | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reordered the properties in this object to match the actual output. The JToken comparison doesn't care; the test passes either way. But when the test fails for some other reason -- as it did for reasons I'll explain below -- then this additional, non-significant difference was just confusing. #ByDesign