-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create rule S6975 * SONARIAC-1424 Split S6956 RSPEC into 2 rules * Code review remarks --------- Co-authored-by: mstachniuk <[email protected]> Co-authored-by: Marcin Stachniuk <[email protected]>
- Loading branch information
1 parent
173a43b
commit 848e7c2
Showing
5 changed files
with
135 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"title": "The resource elements should appear in the recommended order", | ||
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "5min" | ||
}, | ||
"tags": [ | ||
], | ||
"defaultSeverity": "Major", | ||
"ruleSpecification": "RSPEC-6975", | ||
"sqKey": "S6975", | ||
"scope": "All", | ||
"defaultQualityProfiles": ["Sonar way"], | ||
"quickfix": "unknown", | ||
"code": { | ||
"impacts": { | ||
"MAINTAINABILITY": "LOW" | ||
}, | ||
"attribute": "CONVENTIONAL" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
== Why is this an issue? | ||
|
||
According to the best practices defined by Azure, a consistent order of elements in a templates is recommended. | ||
This makes it easier to read and understand the template. | ||
|
||
Not following this convention has no technical impact, | ||
but will reduce the template's readability because most developers are used to the standard order. | ||
|
||
== How to fix it in ARM Templates | ||
|
||
*Recommended order of the resource elements*: | ||
|
||
[source,json] | ||
---- | ||
{ | ||
"resources": [ | ||
{ | ||
"comments": "if any", | ||
"condition": true, | ||
"scope": "% parent scope %", | ||
"type": "Microsoft.Compute/virtualMachines", | ||
"apiVersion": "2023-09-01", | ||
"name": "resourceName", | ||
"location": "[parameters('location')]", | ||
"zones": [], | ||
"sku": {}, | ||
"kind": "", | ||
"scale": "", | ||
"plan": {}, | ||
"identity": {}, | ||
"copy": {}, | ||
"dependsOn": [], | ||
"tags": {}, | ||
"properties": {} | ||
} | ||
] | ||
} | ||
---- | ||
|
||
Any other properties not listed here should be placed before the `properties` object for the resource. | ||
|
||
== How to fix it in Bicep | ||
|
||
*Recommended order of the resource elements and decorators*: | ||
|
||
[source,bicep] | ||
---- | ||
@description | ||
@batchSize | ||
resource resourceName | ||
parent | ||
scope | ||
name | ||
location/extendedLocation | ||
zones | ||
sku | ||
kind | ||
scale | ||
plan | ||
identity | ||
dependsOn | ||
tags | ||
properties | ||
---- | ||
|
||
Any other decorated not listed here should be placed before the `resource` object and after the other decorators. | ||
Any other elements not listed here should be placed before the `properties` object for the resource. | ||
|
||
== Resources | ||
=== Documentation | ||
|
||
* Azure quickstart templates best practices - https://github.com/Azure/azure-quickstart-templates/blob/master/1-CONTRIBUTION-GUIDE/best-practices.md#sort-order-of-properties[Sort order of properties] | ||
|
||
ifdef::env-github,rspecator-view[] | ||
|
||
''' | ||
== Implementation Specification | ||
(visible only on this page) | ||
|
||
=== Message | ||
|
||
In case of wrong order of resource elements: | ||
|
||
* Reorder the elements to match the recommended order. | ||
|
||
In case of wrong order in decorators: | ||
|
||
* Reorder the decorators to match the recommended order. | ||
|
||
=== Highlighting | ||
|
||
For wrong order in a resource: | ||
|
||
We want to highlight the first key that is in the wrong order. | ||
|
||
For wrong order decorators: | ||
|
||
We want to highlight the first decorator that is in the wrong order. | ||
|
||
''' | ||
== Comments And Links | ||
(visible only on this page) | ||
|
||
endif::env-github,rspecator-view[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |