sonar-delphi
sonar-delphi copied to clipboard
Instantiating a bounded array range should always start from 0
Prerequisites
- [X] This rule has not already been suggested.
- [X] This should be a new rule, not an improvement to an existing rule.
- [X] This rule would be generally useful, not specific to my code or setup.
Suggested rule title
Bounded array range should start from 0
Rule description
This rule would pick up on cases when a bounded array variable has a non-zero start when instantiating.
var
Foo: array[1..5] of String; // non-compliant
Bar: array[0..4] of String; // compliant
Rationale
Since RTL list always start from 0 index, there's no good reason for a bounded array range to start from non-zero. To make looping through such as arrays uniform, we should always start from zero.