-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathConstantNaming.ql
More file actions
35 lines (31 loc) · 877 Bytes
/
ConstantNaming.ql
File metadata and controls
35 lines (31 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @name Public static read-only fields should be named in PascalCase
* @description Constant fields should use the relevant Microsoft-recommended naming scheme.
* @kind problem
* @problem.severity recommendation
* @precision low
* @id cs/bad-constant-name
* @tags maintainability
* readability
* naming
*/
import csharp
class PublicConstantField extends Field {
PublicConstantField() {
this.isPublic() and
this.isStatic() and
this.isReadOnly()
}
}
from PublicConstantField f
where
// The first character of the field's name is not uppercase.
not(f.getName().charAt(0).isUppercase())
or
(
// The field's name is uppercase.
f.getName().isUppercase()
// The field's name is at least 4 characters long.
and f.getName().length() >= 4
)
select f, "Public static read-only fields should be named in PascalCase."