File tree Expand file tree Collapse file tree 2 files changed +35
-6
lines changed
delphi-checks/src/main/resources/org/sonar/l10n/delphi/rules/community-delphi Expand file tree Collapse file tree 2 files changed +35
-6
lines changed Original file line number Diff line number Diff line change
1
+ < h2 > Why is this an issue?</ h2 >
1
2
< p >
2
- Attribute names should follow Pascal case and possess an < code > Attribute</ code >
3
- suffix.
4
- < br />
5
- < code > attributeSuffix</ code > can be < code > allowed</ code > for an optional suffix,
6
- < code > required</ code > , or < code > forbidden</ code > .
3
+ Code that follows a consistent naming convention is self-documenting. In Delphi, all custom
4
+ attribute class names should be in PascalCase and end with < code > Attribute</ code > . No prefix
5
+ is required.
7
6
</ p >
7
+ < p >
8
+ Custom attributes suffixed with < code > Attribute</ code > may have the suffix omitted when
9
+ used. This means that attributes can be defined with the same name (e.g. < code > MyCustom</ code >
10
+ and < code > MyCustomAttribute</ code > ), which may cause unexpected behaviour.
11
+ </ p >
12
+ < p >
13
+ To safeguard against this, the < code > Attribute</ code > suffix should be used consistently.
14
+ The suffix is also recommended for clarity, as attribute classes should not be used in other ways
15
+ or instantiated directly.
16
+ </ p >
17
+ < h2 > How to fix it</ h2 >
18
+ < p > Rename the attribute class name to follow the convention.</ p >
19
+ < h2 > Resources</ h2 >
20
+ < ul >
21
+ < li >
22
+ < a href ="https://docwiki.embarcadero.com/RADStudio/en/Type_Declarations ">
23
+ Delphi's Object Pascal Style Guide: Type Declarations
24
+ </ a >
25
+ </ li >
26
+ < li >
27
+ < a href ="https://docwiki.embarcadero.com/RADStudio/en/Declaring_Custom_Attributes_(RTTI) ">
28
+ RAD Studio documentation: Declaring Custom Attributes (RTTI)
29
+ </ a >
30
+ </ li >
31
+ < li >
32
+ < a href ="https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#names-of-common-types ">
33
+ .NET documentation: Names of Classes, Structs, and Interfaces
34
+ </ a >
35
+ </ li >
36
+ </ ul >
Original file line number Diff line number Diff line change 12
12
"MAINTAINABILITY" : " LOW"
13
13
}
14
14
},
15
- "tags" : [],
15
+ "tags" : [" confusing " , " convention " ],
16
16
"defaultSeverity" : " Minor" ,
17
17
"scope" : " ALL" ,
18
18
"quickfix" : " unknown"
You can’t perform that action at this time.
0 commit comments