diff mbox series

[v2,03/14] Makefile: add target to update .checkpackageignore

Message ID 20220731193521.1217825-4-ricardo.martincoski@gmail.com
State Accepted
Headers show
Series Preventing style regressions using check-package v2 | expand

Commit Message

Ricardo Martincoski July 31, 2022, 7:35 p.m. UTC
When a developer fixes an ignored warning from check-package, he/she
needs to update .checkpackageignore
By running './utils/docker-run make check-package' the developer
receives a warning about this.
Make that change easier to make, by adding a helper target on Makefile.

Add an option --failed-only to check-package that generates output in
the format:
<filename> <check_function> [<check_function> ...]
This is the very same format used by check-package ignore file.

Add the phony target .checkpackageignore

So one can update the ignore file using:
$ ./utils/docker-run make .checkpackageignore

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
---
Changes v1 -> v2:
  - on check-package, do not return error code when --failed-only is
    used
  - add a target to the makefile
  - completely rewrite commit message, in order to clarify why it is
    needed
---
 Makefile            |  5 +++++
 utils/check-package | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

Comments

Thomas Petazzoni Feb. 6, 2023, 9:23 p.m. UTC | #1
On Sun, 31 Jul 2022 16:35:10 -0300
Ricardo Martincoski <ricardo.martincoski@gmail.com> wrote:

> When a developer fixes an ignored warning from check-package, he/she
> needs to update .checkpackageignore
> By running './utils/docker-run make check-package' the developer
> receives a warning about this.
> Make that change easier to make, by adding a helper target on Makefile.
> 
> Add an option --failed-only to check-package that generates output in
> the format:
> <filename> <check_function> [<check_function> ...]
> This is the very same format used by check-package ignore file.
> 
> Add the phony target .checkpackageignore
> 
> So one can update the ignore file using:
> $ ./utils/docker-run make .checkpackageignore
> 
> Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
> ---
> Changes v1 -> v2:
>   - on check-package, do not return error code when --failed-only is
>     used
>   - add a target to the makefile
>   - completely rewrite commit message, in order to clarify why it is
>     needed
> ---
>  Makefile            |  5 +++++
>  utils/check-package | 13 ++++++++++++-
>  2 files changed, 17 insertions(+), 1 deletion(-)

Applied to master, thanks.

Thomas
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index a743e42f91..e49080b110 100644
--- a/Makefile
+++ b/Makefile
@@ -1244,6 +1244,11 @@  check-package:
 	find $(TOPDIR) -type f \( -name '*.mk' -o -name '*.hash' -o -name 'Config.*' -o -name '*.patch' \) \
 		-exec ./utils/check-package --exclude=Sob {} +
 
+.PHONY: .checkpackageignore
+.checkpackageignore:
+	find $(TOPDIR) -type f \( -name '*.mk' -o -name '*.hash' -o -name 'Config.*' -o -name '*.patch' \) \
+		-exec ./utils/check-package --exclude=Sob --failed-only {} > .checkpackageignore +
+
 include docs/manual/manual.mk
 -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk)))
 
diff --git a/utils/check-package b/utils/check-package
index 00be29d02a..d896e8b117 100755
--- a/utils/check-package
+++ b/utils/check-package
@@ -72,11 +72,17 @@  def parse_args():
                         help="do not run the specified functions (debug)")
     parser.add_argument("--dry-run", action="store_true", help="print the "
                         "functions that would be called for each file (debug)")
+    parser.add_argument("--failed-only", action="store_true", help="print only"
+                        " the name of the functions that failed (debug)")
 
     flags = parser.parse_args()
 
     flags.ignore_list = get_ignored_parsers_per_file(flags.intree_only, flags.ignore_filename)
 
+    if flags.failed_only:
+        flags.dry_run = False
+        flags.verbose = -1
+
     return flags
 
 
@@ -230,6 +236,11 @@  def check_file_using_lib(fname):
                   .format(fname, should_fail, IGNORE_FILENAME))
             nwarnings += 1
 
+    if flags.failed_only:
+        if len(failed) > 0:
+            f = " ".join(sorted(failed))
+            print("{} {}".format(fname, f))
+
     return nwarnings, nlines
 
 
@@ -268,7 +279,7 @@  def __main__():
         print("{} lines processed".format(total_lines), file=sys.stderr)
         print("{} warnings generated".format(total_warnings), file=sys.stderr)
 
-    if total_warnings > 0:
+    if total_warnings > 0 and not flags.failed_only:
         sys.exit(1)