mirror of
https://github.com/mandiant/capa.git
synced 2025-12-21 23:00:29 -08:00
@@ -648,11 +648,11 @@ class FormatStringQuotesIncorrect(Lint):
|
|||||||
continue
|
continue
|
||||||
if value.style is None:
|
if value.style is None:
|
||||||
# no quotes
|
# no quotes
|
||||||
self.recommendation = 'add double quotes to "%s"' % value.value
|
self.recommendation = f'add double quotes to "{value.value}"'
|
||||||
return True
|
return True
|
||||||
if value.style == "'":
|
if value.style == "'":
|
||||||
# single quote
|
# single quote
|
||||||
self.recommendation = 'change single quotes to double quotes for "%s"' % value.value
|
self.recommendation = f'change single quotes to double quotes for "{value.value}"'
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif isinstance(key, ruamel.yaml.ScalarEvent) and key.value == "substring":
|
elif isinstance(key, ruamel.yaml.ScalarEvent) and key.value == "substring":
|
||||||
@@ -662,11 +662,11 @@ class FormatStringQuotesIncorrect(Lint):
|
|||||||
continue
|
continue
|
||||||
if value.style is None:
|
if value.style is None:
|
||||||
# no quotes
|
# no quotes
|
||||||
self.recommendation = 'add double quotes to "%s"' % value.value
|
self.recommendation = f'add double quotes to "{value.value}"'
|
||||||
return True
|
return True
|
||||||
if value.style == "'":
|
if value.style == "'":
|
||||||
# single quote
|
# single quote
|
||||||
self.recommendation = 'change single quotes to double quotes for "%s"' % value.value
|
self.recommendation = f'change single quotes to double quotes for "{value.value}"'
|
||||||
return True
|
return True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -816,25 +816,12 @@ def lint_rule(ctx: Context, rule: Rule):
|
|||||||
# and ends up just producing a lot of noise.
|
# and ends up just producing a lot of noise.
|
||||||
if not (is_nursery_rule(rule) and len(violations) == 1 and violations[0].name == "missing examples"):
|
if not (is_nursery_rule(rule) and len(violations) == 1 and violations[0].name == "missing examples"):
|
||||||
print("")
|
print("")
|
||||||
print(
|
print(f'{" (nursery) " if is_nursery_rule(rule) else ""} {rule.name}')
|
||||||
"%s%s"
|
|
||||||
% (
|
|
||||||
" (nursery) " if is_nursery_rule(rule) else "",
|
|
||||||
rule.name,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
for violation in violations:
|
for violation in violations:
|
||||||
print(
|
print(
|
||||||
"%s %s: %s: %s"
|
f"{' ' if is_nursery_rule(rule) else ''} {Lint.WARN if is_nursery_rule(rule) else violation.level}: {violation.name}: {violation.recommendation}"
|
||||||
% (
|
|
||||||
" " if is_nursery_rule(rule) else "",
|
|
||||||
Lint.WARN if is_nursery_rule(rule) else violation.level,
|
|
||||||
violation.name,
|
|
||||||
violation.recommendation,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
if is_nursery_rule(rule):
|
if is_nursery_rule(rule):
|
||||||
@@ -860,8 +847,8 @@ def lint_rule(ctx: Context, rule: Rule):
|
|||||||
|
|
||||||
if (not lints_failed) and (not lints_warned) and has_examples:
|
if (not lints_failed) and (not lints_warned) and has_examples:
|
||||||
print("")
|
print("")
|
||||||
print("%s%s" % (" (nursery) ", rule.name))
|
print(f'{" (nursery) " if is_nursery_rule(rule) else ""} {rule.name}')
|
||||||
print("%s %s: %s: %s" % (" ", Lint.WARN, green("no lint failures"), "Graduate the rule"))
|
print(f" {Lint.WARN}: {green('no lint failures')}: Graduate the rule")
|
||||||
print("")
|
print("")
|
||||||
else:
|
else:
|
||||||
lints_failed = len(tuple(filter(lambda v: v.level == Lint.FAIL, violations)))
|
lints_failed = len(tuple(filter(lambda v: v.level == Lint.FAIL, violations)))
|
||||||
@@ -921,7 +908,7 @@ def lint(ctx: Context):
|
|||||||
with redirecting_print_to_tqdm():
|
with redirecting_print_to_tqdm():
|
||||||
for rule in pbar:
|
for rule in pbar:
|
||||||
name = rule.name
|
name = rule.name
|
||||||
pbar.set_description(width("linting rule: %s" % (name), 48))
|
pbar.set_description(width(f"linting rule: {name}", 48))
|
||||||
ret[name] = lint_rule(ctx, rule)
|
ret[name] = lint_rule(ctx, rule)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|||||||
Reference in New Issue
Block a user