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

Allow specific overloads to be specified in ForbiddenMethod

Open
#64 4 comments 0 reactions 0 assignees 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

ForbiddenMethod

### Improvement description

Custom rules based off the ForbiddenMethod template rule should be able to optionally specify which overloads should be forbidden.

This could look like optionally including an argument list of type names to the blacklist, e.g. `MyUnit.MyType.MyProc(Integer, string)`.

* These type names could have to be an exact string match for the types as they are in the method declaration, which would ease name resolution issues.
* Explicitly specifying an overload with no parameters is as easy as adding an empty argument list `()`.

### Rationale

It's currently impossible to specify some overloads as forbidden, which is a fairly common use case (e.g. an outdated or suboptimal version of the method that is only maintained for compatibility). A great example of where SonarDelphi already acknowledges this is in the rule forbidding the Single overloads of math functions.

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.