integrated-application-development / integrated-application-development/sonar-delphi

False negatives for redundant jump rule

Open
#344 0 comments 0 reactions 1 assignee Claimed by @jgardn3r View on GitHub
enhancement rule
Dominant language
Java
Stars
159
Forks
31
Avg merge
5d 4h
Merged PRs (30d)
4

Description

### Prerequisites

- [x] This improvement has not already been suggested.
- [x] This improvement should not be implemented as a separate rule.

### Rule to improve

RedundantJump

### Improvement description

In the following example there are 2 redundant jumps that are not flagged by the current implementation of the rule

```delphi
function Condition: Boolean;
begin
Result := True;
end;

procedure Con;
begin
for var I := 0 to 1 do begin
if Condition then begin
Continue; // not flagged
end;
Continue; // flagged
end;
end;

procedure Brk;
begin
for var I := 0 to 1 do begin
if Condition then begin
Break; // not flagged
end;
Break;
end;
end;
```

### Rationale

The rule should detect as many redundant jumps as possible, and this is another simple case to include.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.