This rule raises an issue when template directives do not have a whitespace after the opening braces and before the closing braces. It’s based on best practices in Helm and emphasizes the importance of maintaining this whitespace for better readability and understanding of the code.
The absence of whitespace in template directives in Helm can lead to several issues:
Readability: Code is read more often than it is written. When template directives are tightly packed without whitespaces, it can be challenging to distinguish between the braces and the content inside. This can slow down the process of understanding the code, especially for those who are new to the codebase.
Maintainability: Hard-to-read code is also hard to maintain. If a developer struggles to understand what a piece of code does due to poor formatting, they may introduce bugs when they try to modify it.
In summary, not having a whitespace after the opening brace and before the closing brace in template directives can make the code harder to read, understand, and maintain.
To fix this issue, add a whitespace after the opening braces {{ and before the closing braces }} in template
directives.
apiVersion: v1
kind: Pod
metadata:
name: {{.Values.podName}} # Noncompliant
spec:
containers:
- name: containerName
apiVersion: v1
kind: Pod
metadata:
name: {{ .Values.podName }}
spec:
containers:
- name: containerName