Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support noqa before multiline strings #318

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
14 changes: 13 additions & 1 deletion saltlint/linter/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,25 @@ def matchlines(self, file, text):
if not self.is_valid_language(file):
return matches

last = {'line': '', 'skips': []}
# arrays are 0-based, line numbers are 1-based
# so use prev_line_no as the counter
for (prev_line_no, line) in enumerate(text.split("\n")):
skips = []

if line.lstrip().startswith('#'):
continue

rule_id_list = get_rule_skips_from_line(line)
if self.id in rule_id_list:

if last['line'].startswith('-') and '|' in last['line'] or '>' in last['line']:
for previous_skip in last['skips']:
if not previous_skip in rule_id_list:
skips.append(previous_skip)

last = {'line': line.lstrip(), 'skips': rule_id_list}

if self.id in skips:
continue

result = self.match(file, line)
Expand All @@ -71,6 +82,7 @@ def matchlines(self, file, text):
matches.append(Match(prev_line_no+1, line,
file['path'], self, message))


return matches

def matchfulltext(self, file, text):
Expand Down
Loading