| 1 |
from .. import annotations |
| 2 |
from ..errors import CompileWarning |
| 3 |
from ..language import Property |
| 4 |
from .utils import LinterRule |
| 5 |
|
| 6 |
|
| 7 |
class AvoidAllCaps(LinterRule): |
| 8 |
id = "avoid_all_caps" |
| 9 |
severity = "suggestion" |
| 10 |
category = "hig" |
| 11 |
|
| 12 |
def check(self, type, child, stack): |
| 13 |
for property in child.content.children[Property]: |
| 14 |
if annotations.is_property_user_facing_string(property.gir_property): |
| 15 |
string, range = self.get_string_value(property) |
| 16 |
# Show linter error for upper case and multi letter strings |
| 17 |
if string and string.isupper() and len(string) > 1: |
| 18 |
self.problems.append( |
| 19 |
CompileWarning( |
| 20 |
f"Avoid using all upper case for {type} {property.name}", |
| 21 |
range, |
| 22 |
id=self.id, |
| 23 |
) |
| 24 |
) |