All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricardo Martincoski <ricardo.martincoski@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 6/8] utils/check-package: allow to disable warning for a line
Date: Sun, 27 Jan 2019 16:59:41 -0200	[thread overview]
Message-ID: <20190127185943.1136-7-ricardo.martincoski@gmail.com> (raw)
In-Reply-To: <20190127185943.1136-1-ricardo.martincoski@gmail.com>

Currently any exceptions for a check function need to be coded into the
check-package script itself.

Create a pattern that can be used in a comment to make check-package
ignore one or more warning types in the line immediately below:
 # check-package Indent, VariableWithBraces

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
---
 utils/check-package           | 4 ++++
 utils/checkpackagelib/base.py | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/utils/check-package b/utils/check-package
index 26439f08eb..ce1fe98d67 100755
--- a/utils/check-package
+++ b/utils/check-package
@@ -119,36 +119,40 @@ def check_file_using_lib(fname):
         return nwarnings, nlines
     classes = inspect.getmembers(lib, is_a_check_function)
 
     if flags.dry_run:
         functions_to_run = [c[0] for c in classes]
         print("{}: would run: {}".format(fname, functions_to_run))
         return nwarnings, nlines
 
     objects = [c[1](fname, flags.manual_url) for c in classes]
 
     for cf in objects:
         nwarnings += print_warnings(cf.before())
     if six.PY3:
         f = open(fname, "r", errors="surrogateescape")
     else:
         f = open(fname, "r")
+    lastline = ""
     for lineno, text in enumerate(f.readlines()):
         nlines += 1
         for cf in objects:
+            if cf.disable.search(lastline):
+                continue
             nwarnings += print_warnings(cf.check_line(lineno + 1, text))
+        lastline = text
     f.close()
     for cf in objects:
         nwarnings += print_warnings(cf.after())
 
     return nwarnings, nlines
 
 
 def __main__():
     global flags
     flags = parse_args()
 
     if flags.intree_only:
         # change all paths received to be relative to the base dir
         base_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
         files_to_check = [os.path.relpath(os.path.abspath(f), base_dir) for f in flags.files]
         # move current dir so the script find the files
diff --git a/utils/checkpackagelib/base.py b/utils/checkpackagelib/base.py
index fc09bec9a2..9544a64e5a 100644
--- a/utils/checkpackagelib/base.py
+++ b/utils/checkpackagelib/base.py
@@ -1,16 +1,18 @@
 # See utils/checkpackagelib/readme.txt before editing this file.
+import re
 
 
 class _CheckFunction(object):
     def __init__(self, filename, url_to_manual):
         self.filename = filename
         self.url_to_manual = url_to_manual
+        self.disable = re.compile(r"^\s*# check-package .*\b{}\b".format(self.__class__.__name__))
 
     def before(self):
         pass
 
     def check_line(self, lineno, text):
         pass
 
     def after(self):
         pass
-- 
2.17.1

  parent reply	other threads:[~2019-01-27 18:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-27 18:59 [Buildroot] [PATCH 0/8] Detect and fix overridden variables in .mk files Ricardo Martincoski
2019-01-27 18:59 ` [Buildroot] [PATCH 1/8] package/s6-networking: fix dependency when libressl is enabled Ricardo Martincoski
2019-01-27 19:52   ` Thomas Petazzoni
2019-01-28  2:26     ` Ricardo Martincoski
2019-01-27 21:15   ` Peter Korsgaard
2019-01-29 21:56   ` Peter Korsgaard
2019-01-27 18:59 ` [Buildroot] [PATCH 2/8] package/sdl_sound: actually use the optional CONF_OPTS Ricardo Martincoski
2019-01-27 21:16   ` Peter Korsgaard
2019-01-29 21:57   ` Peter Korsgaard
2019-01-27 18:59 ` [Buildroot] [PATCH 3/8] Revert "avrdude: add license information" Ricardo Martincoski
2019-01-27 21:17   ` Peter Korsgaard
2019-01-29 21:59   ` Peter Korsgaard
2019-01-27 18:59 ` [Buildroot] [PATCH 4/8] package/usb_modeswitch: drop unicode space in comment Ricardo Martincoski
2019-01-27 21:19   ` Peter Korsgaard
2019-01-29 22:00   ` Peter Korsgaard
2019-01-27 18:59 ` [Buildroot] [PATCH 5/8] package/usb_modeswitch: avoid overriding variables Ricardo Martincoski
2019-01-27 21:28   ` Peter Korsgaard
2019-01-29 22:01   ` Peter Korsgaard
2019-01-27 18:59 ` Ricardo Martincoski [this message]
2019-01-28 17:16   ` [Buildroot] [PATCH 6/8] utils/check-package: allow to disable warning for a line Arnout Vandecappelle
2019-01-29 15:38   ` Peter Korsgaard
2019-01-27 18:59 ` [Buildroot] [PATCH 7/8] utils/check-package: handle ifdef/ifndef in .mk files Ricardo Martincoski
2019-01-28 17:07   ` Arnout Vandecappelle
2019-01-29 15:39   ` Peter Korsgaard
2019-01-27 18:59 ` [Buildroot] [PATCH 8/8] utils/check-package: warn about overridden variables Ricardo Martincoski
2019-02-04 15:15   ` Titouan Christophe
2019-02-05 19:25   ` Peter Korsgaard
2019-05-26  9:20   ` Yann E. MORIN
2019-05-26 11:05     ` Arnout Vandecappelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190127185943.1136-7-ricardo.martincoski@gmail.com \
    --to=ricardo.martincoski@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.