Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions vint/linting/policy/prohibit_abbreviation_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ class ProhibitAbbreviationOption(AbstractPolicy):
reference = ':help option-summary'
level = Level.STYLE_PROBLEM

was_scriptencoding_found = False
has_encoding_opt_after_scriptencoding = False


def listen_node_types(self):
return [NodeType.EXCMD, NodeType.OPTION]
Expand Down
15 changes: 11 additions & 4 deletions vint/linting/policy/prohibit_encoding_opt_after_scriptencoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,27 @@ class ProhibitEncodingOptionAfterScriptEncoding(AbstractPolicy):
level = Level.WARNING

was_scriptencoding_found = False
has_encoding_opt_after_scriptencoding = False


def listen_node_types(self):
return [NodeType.EXCMD]
return [NodeType.EXCMD, NodeType.TOPLEVEL]


def is_valid(self, excmd_node, lint_context):
def is_valid(self, node, lint_context):
""" Whether the specified node is valid.

This policy prohibits encoding option after scriptencoding.
"""

cmd_str = excmd_node['str']
node_type = NodeType(node['type'])

if node_type is NodeType.TOPLEVEL:
self.was_scriptencoding_found = False
return True

assert node_type is NodeType.EXCMD

cmd_str = node['str']

if re.match(r':*scripte', cmd_str):
self.was_scriptencoding_found = True
Expand Down