| 1 |
from ..errors import CompileError |
| 2 |
from ..language import Property |
| 3 |
from .utils import LinterRule |
| 4 |
|
| 5 |
|
| 6 |
class NoGtkSwitchState(LinterRule): |
| 7 |
id = "gtk_switch_state" |
| 8 |
severity = "problem" |
| 9 |
category = "technical" |
| 10 |
|
| 11 |
def check(self, type, child, stack): |
| 12 |
# rule problem/no-gtkswitch-state |
| 13 |
properties = child.content.children[Property] |
| 14 |
if type == "Gtk.Switch": |
| 15 |
for property in properties: |
| 16 |
if property.name == "state": |
| 17 |
range = property.range |
| 18 |
problem = CompileError( |
| 19 |
f"Use the active property instead of the state property", |
| 20 |
range, |
| 21 |
id=self.id, |
| 22 |
) |
| 23 |
self.problems.append(problem) |