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

New rule: Attribute groups should only contain one attribute

Open
#66 2 comments 0 reactions 0 assignees View on GitHub
feature good first issue 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

Attribute groups should only contain one attribute

### Rule description

This rule would detect instances of multiple attributes within the same square brackets (e.g. `[Foo, Bar]`).

```delphi
type
[Foo, Bar('test')] // Noncompliant
TMyClass = class(TObject)
public
[Foo]
[Bar('test')] // Compliant
procedure Baz;
end;
```

### Rationale

Having multiple attributes combined under a single square brackets is confusing, difficult to read, and error-prone. It's not immediately clear that there are multiple attributes applied, instead of a single attribute with constructor arguments.

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.