All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricardo Martincoski <ricardo.martincoski@gmail.com>
To: james.d.knight@live.com
Cc: ricardo.martincoski@datacom.com.br, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 2/4] utils/check-package: support a file-state instance for library types
Date: Sun, 03 Sep 2023 13:11:23 -0300	[thread overview]
Message-ID: <64f4b02b4985c_809f62afed050d0f819062@xultri.mail> (raw)
In-Reply-To: SN4P221MB0682AE13FB1ACA5A755024F1A0689@SN4P221MB0682.NAMP221.PROD.OUTLOOK.COM

[-- Attachment #1: Type: text/plain, Size: 2952 bytes --]

Hello,

Sorry the long delay.

On Sat, Apr 29, 2023 at 03:12 PM, James Knight wrote:

> from: James Knight <james.d.knight@live.com>
> date: Sat, Apr 29 02:12 PM -04:00 2023
> to: buildroot@buildroot.org
> cc: James Knight <james.d.knight@live.com>, Ricardo Martincoski <ricardo.martincoski@datacom.com.br>
> subject: [Buildroot] [PATCH 2/4] utils/check-package: support a file-state instance for library types
> 
> The following adds support to the checkpackage library to have a
> file-specific state instance that can be changed across multiple
> `check_line` calls. This allows a given library type to provide hints
> across different lines (if needed).

This is a great idea.

> 
> This is in preparation for a future commit to provide support for
> linter suppression that is configured in the files being processed.
> 
> Signed-off-by: James Knight <james.d.knight@live.com>
> ---
>  utils/check-package                 |  8 ++++++++
>  utils/checkpackagelib/base.py       |  2 +-
>  utils/checkpackagelib/lib.py        | 10 +++++-----
>  utils/checkpackagelib/lib_config.py | 10 +++++-----
>  utils/checkpackagelib/lib_hash.py   |  6 +++---
>  utils/checkpackagelib/lib_mk.py     | 22 +++++++++++-----------
>  utils/checkpackagelib/lib_patch.py  |  6 +++---
>  utils/checkpackagelib/lib_sysv.py   |  4 ++--
>  utils/checkpackagelib/test_util.py  |  4 ++--
>  9 files changed, 40 insertions(+), 32 deletions(-)
> 
> diff --git a/utils/check-package b/utils/check-package
> index db3a00b524bc2c2aa663d3621c94fb11a6db7cb3..890420fe6992d49ad7d50f311007689e35ab7681 100755
> --- a/utils/check-package
> +++ b/utils/check-package
> @@ -220,6 +220,12 @@ def check_file_using_lib(fname):
>          print("{}: would run: {}".format(fname, functions_to_run))
>          return nwarnings, nlines
>  
> +    # Check if there is a state tracker we can create for this library type,
> +    # and then forward to each `check_line` invoked
> +    fstate = None
> +    if hasattr(lib, 'State') and inspect.isclass(lib.State):
> +        fstate = lib.State()
> +
>      objects = [[c[0], c[1](fname, flags.manual_url)] for c in internal_functions]
>  
>      for name, cf in objects:
> @@ -231,6 +237,8 @@ def check_file_using_lib(fname):
>      lastline = ""
>      with open(fname, "r", errors="surrogateescape") as f:
>          for lineno, text in enumerate(f):
> +            if fstate:
> +                fstate.process(text)
>              nlines += 1
>              for name, cf in objects:
>                  if cf.disable.search(lastline):

This line of code (that is already there) made me wonder if we can
factor-out this code to the base class and add the new implementation
there.
The advantages of this alternative are:
 - avoid adding code to the main check-package script that currently is
   not covered by unit tests
 - avoid the need to change all users of the base class

I will send shortly a patch with this factor-out.

Regards,
Ricardo

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2023-09-03 16:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230429181205.3620-1-james.d.knight@live.com>
2023-04-29 18:12 ` [Buildroot] [PATCH 1/4] utils/check-package: cleanup line reading James Knight
2023-08-26 20:09   ` Thomas Petazzoni via buildroot
2023-04-29 18:12 ` [Buildroot] [PATCH 2/4] utils/check-package: support a file-state instance for library types James Knight
2023-09-03 16:11   ` Ricardo Martincoski [this message]
2023-04-29 18:12 ` [Buildroot] [PATCH 3/4] utils/check-package: support ignore-indent flag for configurations James Knight
2023-09-03 16:13   ` Ricardo Martincoski
2023-04-29 18:12 ` [Buildroot] [PATCH 4/4] utils/check-package: utilize ignore-indent flag for special configs James Knight

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=64f4b02b4985c_809f62afed050d0f819062@xultri.mail \
    --to=ricardo.martincoski@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=james.d.knight@live.com \
    --cc=ricardo.martincoski@datacom.com.br \
    /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.