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

Make lint run when directories are passed in #9995

Merged
merged 17 commits into from Mar 16, 2018
17 changes: 15 additions & 2 deletions tools/lint/lint.py
Expand Up @@ -747,8 +747,21 @@ def changed_files(wpt_root):

def lint_paths(kwargs, wpt_root):
if kwargs.get("paths"):
r = os.path.realpath(wpt_root)
paths = [os.path.relpath(os.path.realpath(x), r) for x in kwargs["paths"]]
#make new list in case there are multiple added directories
paths=[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces between operators and operands, please.

for path in kwargs.get("paths"):
if os.path.isdir(path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this if is missing an else clause to just add the path to the list of paths.

# create extension for called directory and merge it with the existing path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indent is wrong.

new_Path = os.path.realpath(os.path.join(wpt_root, path))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable names should be all lowercase.

extension = path+'/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this should use os.path.sep, but I'm not sure why it should be necessary.

# get all files from new path
path_dir = list(all_filesystem_paths(new_Path))
# add the extension to the strings for all files from the new path,
# so they may be called from the current directory
paths = [extension + extended_path for extended_path in path_dir]
# add all files from a given directory to our master list of files to check
paths=paths+path_dir

elif kwargs["all"]:
paths = list(all_filesystem_paths(wpt_root))
else:
Expand Down