SONARIAC-1429 S1192: String literals should be raised less often (#3903)
* SONARIAC-1429 S1192: String literals should be raised less often * Code review remarks Co-authored-by: Peter Trifanov <peter.trifanov@sonarsource.com> --------- Co-authored-by: Peter Trifanov <peter.trifanov@sonarsource.com>
This commit is contained in:
parent
399f313abf
commit
def7b6c0ee
@ -3,3 +3,7 @@ The following are ignored:
|
||||
* literals with fewer than 5 characters
|
||||
* literals with only letters, numbers, underscores, hyphens and periods
|
||||
* `apiVersion` property of a resource (see rule S6874)
|
||||
* `type` in nested templates
|
||||
* `$schema` property
|
||||
* version numbers like `1.0.0` or `1-0-0`
|
||||
* escaped template expressions starting with `[[`, like `[[variables('variableName')]`
|
||||
|
@ -14,7 +14,7 @@ include::howtofix-arm.adoc[]
|
||||
|
||||
==== Noncompliant code example
|
||||
|
||||
With the default threshold of 3:
|
||||
With the default threshold of 5:
|
||||
|
||||
[source,json,diff-id=1,diff-type=noncompliant]
|
||||
----
|
||||
@ -29,7 +29,9 @@ With the default threshold of 3:
|
||||
"name": "appSuperStorage",
|
||||
"tags": {
|
||||
"displayName": "appSuperStorage",
|
||||
"shortName" : "appSuperStorage"
|
||||
"shortName" : "appSuperStorage",
|
||||
"someName": "appSuperStorage",
|
||||
"yetAnotherName": "appSuperStorage"
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -53,7 +55,9 @@ With the default threshold of 3:
|
||||
"name": "[variables('storageAccountName')]",
|
||||
"tags": {
|
||||
"displayName": "[variables('storageAccountName')]",
|
||||
"shortName" : "[variables('storageAccountName')]"
|
||||
"shortName" : "[variables('storageAccountName')]",
|
||||
"someName": "[variables('storageAccountName')]",
|
||||
"yetAnotherName": "[variables('storageAccountName')]"
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -68,15 +72,17 @@ include::howtofix-arm.adoc[]
|
||||
|
||||
==== Noncompliant code example
|
||||
|
||||
With the default threshold of 3:
|
||||
With the default threshold of 5:
|
||||
|
||||
[source,bicep,diff-id=2,diff-type=noncompliant]
|
||||
----
|
||||
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-01-01' = {
|
||||
name: 'appSuperStorage' // Noncompliant
|
||||
name: 'appSuperStorage' // Noncompliant
|
||||
tags: {
|
||||
displayName: 'appSuperStorage' // Noncompliant
|
||||
shortName: 'appSuperStorage' // Noncompliant
|
||||
displayName: 'appSuperStorage' // Noncompliant
|
||||
shortName: 'appSuperStorage' // Noncompliant
|
||||
someName: 'appSuperStorage' // Noncompliant
|
||||
yetAnotherName: 'appSuperStorage' // Noncompliant
|
||||
}
|
||||
}
|
||||
----
|
||||
@ -92,6 +98,8 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2021-01-01' = {
|
||||
tags: {
|
||||
displayName: storageAccountName
|
||||
shortName: storageAccountName
|
||||
someName: storageAccountName
|
||||
yetAnotherName: storageAccountName
|
||||
}
|
||||
}
|
||||
----
|
||||
|
Loading…
x
Reference in New Issue
Block a user