
org.sonar.l10n.yaml.rules.yaml.IntValueInRangeCheck.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-yaml-plugin Show documentation
Show all versions of sonar-yaml-plugin Show documentation
YAML 1.1 plugin for SonarQube
The newest version!
Use this rule to control that the YAML documents for a specified key, only contain int values within a specified range.
The range can be defined with a minimum and a maximum value. The specific key can be defined with a regular expression
and the location of the key can be defined with two ancestor regular expressions.
Parameters
- key-name
- Regular expression that matches keys for which the value must be in range. In order to match any key, set it to
.*
. The start and end line markers ^
and $
are implicit: this means that
setting foo
is equivalent to ^foo$
.
- included-ancestors
- Regular expression that matches against an ancestor string made of joining the parent chain of the matching key.
The parents are separated by a colon (
:
) and always start with an implicit <root>
parent.
So, the ancestor string for a connectionTimeout key could be: <root>:spring:datasource:hikari
.
If the includedAncestors regex matches the ancestor string of the key, the value is range checked.
The start and end line markers ^
and $
are implicit, just like the key regex.
Leave empty for no ancestor matching.
- excluded-ancestors
- Regular expression that matches against the ancestor string of the matching key, just like above.
However, if this regex matches, the value is *not* range checked.
The start and end line markers
^
and $
are implicit, just like the key regex.
Leave empty for no ancestor matching.
- minValue
- Integer defining the minimum allowed value.
- maxValue
- Integer defining the maximum allowed value.
Examples
With:
key-name = connect(ion)?-?[tT]imeout.*
included-ancestors = <root>:[a-z\\-]+service[a-z0-9\\-]+:[a-z\\-]+endpoint[a-z0-9\\-]+
excluded-ancestors = .*datasource:hikari
minValue = 50
maxValue = 699
the following code snippet would PASS:
my-service-2:
my-endpoint-2:
connectionTimeout: 600 # no violation
spring:
datasource:
hikari:
connectionTimeout: 5000 # no violation
the following code snippet would FAIL:
my-service-1:
my-endpoint-1:
connectionTimeout: 700 # violation, > 699 ms
- Note that defining only one of includedAncestors end excludedAncestors above will yield the same results in this example.
- Current limitation: yaml list notation is not supported by ancestor matching.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy