From c2a87c9b07882b2df37e6ecd1e07ce28ca33aa2a Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 30 Apr 2021 21:09:12 +0000 Subject: [PATCH] Bug 1708592 - Normalize paths when filtering in clippy and rustfmt lints. r=sylvestre Without normalization, the paths don't match the filters on Windows. Differential Revision: https://phabricator.services.mozilla.com/D113904 --- tools/lint/clippy/__init__.py | 4 +++- tools/lint/rust/__init__.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/lint/clippy/__init__.py b/tools/lint/clippy/__init__.py index 99ef2f3a6f1c..99b3111caded 100644 --- a/tools/lint/clippy/__init__.py +++ b/tools/lint/clippy/__init__.py @@ -39,6 +39,8 @@ And make sure that it is in the PATH def parse_issues(log, config, issues, path, onlyIn): results = [] + if onlyIn: + onlyIn = os.path.normcase(os.path.normpath(onlyIn)) for issue in issues: try: @@ -70,7 +72,7 @@ def parse_issues(log, config, issues, path, onlyIn): continue l = detail["spans"][0] - if onlyIn and onlyIn not in p: + if onlyIn and onlyIn not in os.path.normcase(os.path.normpath(p)): # Case when we have a .rs in the include list in the yaml file log.debug( "{} is not part of the list of files '{}'".format(p, onlyIn) diff --git a/tools/lint/rust/__init__.py b/tools/lint/rust/__init__.py index 3dcf240eca3a..b7dadd1ecb09 100644 --- a/tools/lint/rust/__init__.py +++ b/tools/lint/rust/__init__.py @@ -60,13 +60,14 @@ def parse_issues(config, output, paths): diff += line + "\n" # the algorithm above will always skip adding the last issue issues.append(RustfmtDiff(file, line_no, diff)) + file = os.path.normcase(os.path.normpath(file)) results = [] for issue in issues: # rustfmt can not be supplied the paths to the files we want to analyze # therefore, for each issue detected, we check if any of the the paths # supplied are part of the file name. # This just filters out the issues that are not part of paths. - if any([path in file for path in paths]): + if any([os.path.normcase(os.path.normpath(path)) in file for path in paths]): res = { "path": issue.file, "diff": issue.diff,