| 1 |
from ..errors import CompileWarning |
| 2 |
from ..language import Property |
| 3 |
from .utils import LinterRule |
| 4 |
|
| 5 |
|
| 6 |
class OrderPropertiesGtkAdjustment(LinterRule): |
| 7 |
id = "adjustment_prop_order" |
| 8 |
severity = "problem" |
| 9 |
category = "technical" |
| 10 |
|
| 11 |
def check(self, type, child, stack): |
| 12 |
properties = child.content.children[Property] |
| 13 |
preferred_order = ["lower", "upper", "value"] |
| 14 |
current_order = [] |
| 15 |
if type in type_order_properties: |
| 16 |
for property in properties: |
| 17 |
current_order.append(property.name) |
| 18 |
if current_order != preferred_order: |
| 19 |
self.problems.append( |
| 20 |
CompileWarning( |
| 21 |
f"{type} properties should be ordered as lower, upper, and then value.", |
| 22 |
child.range, |
| 23 |
id=self.id, |
| 24 |
) |
| 25 |
) |
| 26 |
|
| 27 |
|
| 28 |
type_order_properties = ["Gtk.Adjustment"] |