diff mbox

[ovs-dev] checkpatch: Also allow .at files to have leading tabs.

Message ID 20170606153934.6483-1-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff June 6, 2017, 3:39 p.m. UTC
Autotest .at files often have lines with samples of expected output from
various programs, which fairly often includes leading tabs, so this warning
causes false positives there.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 utilities/checkpatch.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Aaron Conole June 7, 2017, 10:57 p.m. UTC | #1
Ben Pfaff <blp@ovn.org> writes:

> Autotest .at files often have lines with samples of expected output from
> various programs, which fairly often includes leading tabs, so this warning
> causes false positives there.
>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---

I'm assuming the list is there because probably there could be other
extensions where we wish to disable this, and it matches the line length
blacklist.

I haven't tested it yet, but am confident enough to give:

Reviewed-by: Aaron Conole <aconole@redhat.com>
Ben Pfaff June 8, 2017, 4:22 p.m. UTC | #2
On Wed, Jun 07, 2017 at 06:57:31PM -0400, Aaron Conole wrote:
> Ben Pfaff <blp@ovn.org> writes:
> 
> > Autotest .at files often have lines with samples of expected output from
> > various programs, which fairly often includes leading tabs, so this warning
> > causes false positives there.
> >
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > ---
> 
> I'm assuming the list is there because probably there could be other
> extensions where we wish to disable this, and it matches the line length
> blacklist.

That's right, I was imitating the structure there.

> I haven't tested it yet, but am confident enough to give:
> 
> Reviewed-by: Aaron Conole <aconole@redhat.com>

Thanks!  I applied this to master.
diff mbox

Patch

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 5ca4b9e2f8d3..df926e437c38 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -99,6 +99,11 @@  skip_signoff_check = False
 line_length_blacklist = ['.am', '.at', 'etc', '.in', '.m4', '.mk', '.patch',
                          '.py']
 
+# Don't enforce a requirement that leading whitespace be all spaces on
+# files that include these characters in their name, since these kinds
+# of files need lines with leading tabs.
+leading_whitespace_blacklist = ['.mk', '.am', '.at']
+
 
 def is_subtracted_line(line):
     """Returns TRUE if the line in question has been removed."""
@@ -200,8 +205,9 @@  checks = [
      'check': lambda x: line_length_check(x),
      'print': lambda: print_warning("Line length is >79-characters long")},
 
-    {'regex': '$(?<!\.mk|\.am)',
-     'match_name': None,
+    {'regex': None,
+     'match_name':
+     lambda x: not any([fmt in x for fmt in leading_whitespace_blacklist]),
      'check': lambda x: not leading_whitespace_is_spaces(x),
      'print': lambda: print_warning("Line has non-spaces leading whitespace")},