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

add blank line check #24936

Merged
merged 3 commits into from
May 26, 2020
Merged

add blank line check #24936

merged 3 commits into from
May 26, 2020

Conversation

incebellipipo
Copy link
Contributor

In PR #24685 I made mistake and add a blank line at the bottom of the yaml file. @clalancette replied with #24685 (comment) and pointed out that blank line check is missing in linter script. So I add this functionality to check_rosdep.py script and update contributing guide accordingly.

Proposal: #24685 (comment)

Adding this will do.

def no_empty_lines(buf):
   clean = True 
   for i, l in enumerate(buf.split('\n')[:-1]):
       if re.match(r'^\s*$', l):
           print_err("empty line %u" % (i+1))
           clean = False
   return clean

Results:

checking for trailing spaces...
checking for empty lines...
 ERR: empty line 6225
checking for incorrect indentation...
checking for non-bracket package lists...
checking for item order...
building yaml dict...
there were errors, please correct the file

I also checked for a case where an empty line also has trailing whitespaces which is kinda rare. If that happens script returns this:

$ ./check_rosdep.py ../rosdep/base.yaml
checking for trailing spaces...
 ERR: trailing space line 6225
checking for empty lines...
 ERR: empty line 6225
checking for incorrect indentation...
 ERR: line 6224:   
Traceback (most recent call last):
 File "./check_rosdep.py", line 223, in <module>
   if not main(args.infile):
 File "./check_rosdep.py", line 181, in main
   my_assert(correct_indent(buf))
 File "./check_rosdep.py", line 116, in correct_indent
   return generic_parser(buf, fun)
 File "./check_rosdep.py", line 82, in generic_parser
   s = re.search(r'(?!' + indent_atom + ')[^\s]', l).start()
AttributeError: 'NoneType' object has no attribute 'start'
$ echo $?
1

I didn't want to commit my local change, since it will automatically be a part of this PR which labelled as rosdep. If its ok, I can commit it, if its not I'll wait for this PR to be merged and create a new PR.

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

Two small things to fix, but otherwise looks good to me. Thanks for the change.

CONTRIBUTING.md Outdated Show resolved Hide resolved
scripts/check_rosdep.py Show resolved Hide resolved
@clalancette clalancette merged commit 279f0f0 into ros:master May 26, 2020
sloretz pushed a commit that referenced this pull request Aug 5, 2020
* add blank line check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants