-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
featureNew feature or requestNew feature or requestruleImprovements or additions to rulesImprovements or additions to rules
Description
Prerequisites
- This rule has not already been suggested.
- This should be a new rule, not an improvement to an existing rule.
- This rule would be generally useful, not specific to my code or setup.
Suggested rule title
Array iteration should be in range
Rule description
This rule would pick up on cases where a loop iterator may become out of range of the underlying array, by determining that the upper bound of iteration is less than or equal to the length of the array - 1. For example:
for I := 0 to Length(MyArr) do begin
// ...
end;This could also be extended to lists:
for I := 0 to MyList.Count do begin
// ...
end;Rationale
It's a very common problem to write for I := 0 to Length(MyArr), as it looks correct at first glance. This rule would catch those cases before causing a range check error.
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or requestruleImprovements or additions to rulesImprovements or additions to rules