from base import _CheckFunction
from lib import ConsecutiveEmptyLines
from lib import EmptyLastLine
from lib import NewlineAtEof
from lib import TrailingSpace
def _empty_or_comment(text):
return line == "" or line.startswith("#")
def _part_of_help_text(text):
return text.startswith("\t ")
entries_that_should_not_be_indented = [
"choice", "comment", "config", "endchoice", "endif", "endmenu", "if",
"menu", "menuconfig", "source"]
class AttributesOrder(_CheckFunction):
attributes_order_convention = {
"bool": 1, "prompt": 1, "string": 1, "default": 2, "depends": 3,
def check_line(self, lineno, text):
if _empty_or_comment(text) or _part_of_help_text(text):
attribute = text.split()[0]
if attribute in entries_that_should_not_be_indented:
if attribute not in self.attributes_order_convention.keys():
new_state = self.attributes_order_convention[attribute]
wrong_order = self.state > new_state
return ["{}:{}: attributes order: type, default, depends on,"
" select, help ({}#_config_files)"
.format(self.filename, lineno, self.url_to_manual),