Skip to content

Commit

Permalink
Modify rule S117: Add exception to kubernetes language (#4558)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-wielage-sonarsource authored Dec 10, 2024
1 parent 2bd1df5 commit 17fa0b5
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions rules/S117/kubernetes/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@
:identifier: local variable and function parameter
:identifier_plural: local variables and function parameters
:identifier_or: local variable or function parameter
:regex: ^[a-z][a-zA-Z0-9]*$
:regex: ^\$[a-z][a-zA-Z0-9]*$

include::../rule.adoc[]

include::../introduction.adoc[]

include::../why-is-this-an-issue.adoc[]

=== Exceptions

The rule does not raise an issue on the usages of the blank identifier `$_` or the root context `$`.

include::../what-is-the-potential-impact.adoc[]

include::../how-to-fix-it.adoc[]

As a default, we suggest using the camelCase naming convention, as this is widely adopted for variables in Helm.


=== Code examples

==== Noncompliant code example
Expand Down Expand Up @@ -51,11 +63,20 @@ data:
{{ $keyC }}: {{ $valC | quote }}
{{- end }}
----

[source,text]
----
# Usage of blank identifier
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className -}}
# Usage of root context
{{- $ := . -}}
----
== Resources

=== Documentation


* Helm documentation - https://helm.sh/docs/chart_template_guide/variables/[Helm - Variables]
* Go documentation - https://go.dev/doc/effective_go#names[Effective Go - Names]
* Wikipedia - https://en.wikipedia.org/wiki/Naming_convention_(programming)[Naming Convention (programming)]

Expand Down

0 comments on commit 17fa0b5

Please sign in to comment.