integrated-application-development / integrated-application-development/sonar-delphi
Instantiating a bounded array range should always start from 0
- Dominant language
- Java
- Stars
- 159
- Forks
- 31
- Avg merge
- 5d 4h
- Merged PRs (30d)
- 4
Description
### 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.
```delphi
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.
Contributor guide
Assessment
This issue has not been assessed yet.