-
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 S117: Parameter and variable names should comply with a n…
…aming convention (#3782)
- Loading branch information
1 parent
02e886d
commit c0b70e0
Showing
5 changed files
with
119 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"title": "Parameter and variable names should comply with a naming convention" | ||
} |
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 @@ | ||
:identifier_capital_plural: Parameters and variables | ||
:identifier: parameter and variable | ||
:identifier_plural: parameters and variables | ||
:identifier_or: parameter or variable | ||
:regex: ^[a-z][a-zA-Z0-9]*$ | ||
|
||
include::../introduction.adoc[] | ||
|
||
include::../why-is-this-an-issue.adoc[] | ||
|
||
include::../what-is-the-potential-impact.adoc[] | ||
|
||
== How to fix it in ARM templates | ||
|
||
include::../how-to-fix-it-description.adoc[] | ||
|
||
=== Code examples | ||
|
||
==== Noncompliant code example | ||
|
||
[source,json,diff-id=1,diff-type=noncompliant] | ||
---- | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"storage_account_name": { | ||
"type": "string" | ||
} | ||
}, | ||
"variables": { | ||
"string_variable": "example value" | ||
} | ||
} | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,json,diff-id=1,diff-type=compliant] | ||
---- | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"storageAccountName": { | ||
"type": "string" | ||
} | ||
}, | ||
"variables": { | ||
"stringVariable": "example value" | ||
} | ||
} | ||
---- | ||
|
||
== How to fix it in Bicep | ||
|
||
include::../how-to-fix-it-description.adoc[] | ||
|
||
=== Code examples | ||
|
||
==== Noncompliant code example | ||
|
||
[source,bicep,diff-id=2,diff-type=noncompliant] | ||
---- | ||
param storage_account_name string // Noncompliant | ||
var string_variable = 'example val' // Noncompliant | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,bicep,diff-id=2,diff-type=compliant] | ||
---- | ||
param storageAccountName string | ||
var stringVariable = 'example val' | ||
---- | ||
|
||
== Resources | ||
|
||
=== Documentation | ||
|
||
* Microsoft - https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/best-practices#parameters[ARM template best practices] | ||
* Microsoft - https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/best-practices#names[Best practices for Bicep] | ||
* Microsoft - https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/variables[Variables in ARM templates] | ||
* Microsoft - https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/parameters[Parameters in ARM templates] | ||
* Microsoft - https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/variables[Variables in Bicep] | ||
* Microsoft - https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/parameters[Parameters in Bicep] | ||
|
||
ifdef::env-github,rspecator-view[] | ||
|
||
''' | ||
== Implementation Specification | ||
(visible only on this page) | ||
|
||
include::../message.adoc[] | ||
|
||
include::../parameters.adoc[] | ||
|
||
''' | ||
== Comments And Links | ||
(visible only on this page) | ||
|
||
include::../comments-and-links.adoc[] | ||
|
||
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,6 @@ | ||
First, familiarize yourself with the particular naming convention of the project | ||
in question. | ||
Then, update the name to match the convention, as well as all | ||
usages of the name. | ||
For many IDEs, you can use built-in renaming and refactoring features to update | ||
all usages at once. |
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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
== How to fix it | ||
|
||
First, familiarize yourself with the particular naming convention of the project | ||
in question. | ||
Then, update the name to match the convention, as well as all | ||
usages of the name. | ||
For many IDEs, you can use built-in renaming and refactoring features to update | ||
all usages at once. | ||
include::how-to-fix-it-description.adoc[] |
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