account for Windows paths

This commit is contained in:
Moritz Raabe
2020-07-06 13:00:28 +02:00
parent 4f6bf0675c
commit 9e0d2ffd7b

View File

@@ -89,7 +89,7 @@ class NamespaceDoesntMatchRulePath(Lint):
if "lib" in rule.meta:
return False
return rule.meta["namespace"] not in posixpath.normpath(rule.meta["capa/path"])
return rule.meta["namespace"] not in get_normpath(rule.meta["capa/path"])
class MissingScope(Lint):
@@ -216,7 +216,7 @@ class LibRuleNotInLibDirectory(Lint):
if "lib" not in rule.meta:
return False
return "/lib/" not in posixpath.normpath(rule.meta["capa/path"])
return "/lib/" not in get_normpath(rule.meta["capa/path"])
class LibRuleHasNamespace(Lint):
@@ -314,6 +314,10 @@ FEATURE_LINTS = (
)
def get_normpath(path):
return posixpath.normpath(path).replace(os.sep, "/")
def lint_features(ctx, rule):
features = get_features(ctx, rule)
return run_feature_lints(FEATURE_LINTS, ctx, features)