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

New rule: Identifiers should not shadow compiler intrinsics

Open
#73 1 comment 0 reactions 0 assignees View on GitHub
feature rule
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

Identifiers should not shadow compiler intrinsics

### Rule description

This rule forbids identifiers that share a name with a compiler intrinsic.

This would include a configurable whitelist for acceptable intrinsics to shadow.

### Rationale

This can be confusing for a number of reasons:

- Compiler intrinsics have special "magic" behaviour that is not replaceable if it is shadowed (except by prefacing `System.`)
- Intrinsics are almost always expected to be the intrinsic value (e.g. `Break`, `Continue`, `True`)
- The Delphi IDE adds decorators for certain intrinsics, and does not differentiate between the intrinsic and a shadowing identifier of the same name

![image](https://github.com/integrated-application-development/sonar-delphi/assets/28214458/c959e3ab-484a-4518-bab9-19f26e706b0e)

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.