Skip to content

Commit

Permalink
Add warning about missing ordering in gdlintrc, fixes #242
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Dec 7, 2023
1 parent 282d3fe commit f261487
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions gdtoolkit/linter/class_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,33 @@ def _class_definitions_order_check_for_class(
for statement in a_class.statements:
if _is_statement_irrelevant(statement):
continue
current_section_rank = order.index(current_section)
statement_section = _map_statement_to_section(statement)
section_rank = order.index(statement_section)
if section_rank >= current_section_rank:
current_section = statement_section
else:
try:
current_section_rank = order.index(current_section)
statement_section = _map_statement_to_section(statement)
section_rank = order.index(statement_section)
if section_rank >= current_section_rank:
current_section = statement_section
else:
problems.append(
Problem(
name="class-definitions-order",
description="Definition out of order in {}".format(
a_class.name
),
line=get_line(statement.lark_node),
column=get_column(statement.lark_node),
)
)
except ValueError:
problems.append(
Problem(
name="class-definitions-order",
description="Definition out of order in {}".format(a_class.name),
description=" ".join(
[
"Definition order not specified for '{}' or '{}',",
"please fix/re-generate your gdlintrc file",
]
).format(current_section, statement_section),
line=get_line(statement.lark_node),
column=get_column(statement.lark_node),
)
Expand Down

0 comments on commit f261487

Please sign in to comment.