[{"id":29699,"web_url":"https://patchwork.libcamera.org/comment/29699/","msgid":"<ZlnN1iC2ZxKIj7iA@pyrite.rasen.tech>","date":"2024-05-31T13:17:10","subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Fri, May 31, 2024 at 03:18:38PM +0300, Laurent Pinchart wrote:\n> The issue checkers display the line number and line content of each\n> offending line, but don't show the location of the issue within a line.\n> Improve checkstyle by adding a marker that points to the exact location.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  utils/checkstyle.py | 39 +++++++++++++++++++++++++--------------\n>  1 file changed, 25 insertions(+), 14 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 77d6f39011c1..ff885aa98d65 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -556,8 +556,9 @@ class StyleChecker(metaclass=ClassRegistry):\n>  \n>  \n>  class StyleIssue(object):\n> -    def __init__(self, line_number, line, msg):\n> +    def __init__(self, line_number, position, line, msg):\n>          self.line_number = line_number\n> +        self.position = position\n>          self.line = line\n>          self.msg = msg\n>  \n> @@ -584,7 +585,7 @@ class HexValueChecker(StyleChecker):\n>              if value == value.lower():\n>                  continue\n>  \n> -            issues.append(StyleIssue(line_number, line,\n> +            issues.append(StyleIssue(line_number, match.span(0), line,\n>                                       f'Use lowercase hex constant {value.lower()}'))\n>  \n>          return issues\n> @@ -623,7 +624,7 @@ class IncludeChecker(StyleChecker):\n>                  header_type = 'C compatibility'\n>                  header = header[1:] + '.h'\n>  \n> -            issues.append(StyleIssue(line_number, line,\n> +            issues.append(StyleIssue(line_number, match.span(1), line,\n>                                       f'{header_type} header <{header}> is preferred'))\n>  \n>          return issues\n> @@ -641,10 +642,12 @@ class LogCategoryChecker(StyleChecker):\n>          issues = []\n>          for line_number in line_numbers:\n>              line = self.__content[line_number-1]\n> -            if not LogCategoryChecker.log_regex.search(line):\n> +            match = LogCategoryChecker.log_regex.search(line)\n> +            if not match:\n>                  continue\n>  \n> -            issues.append(StyleIssue(line_number, line, 'LOG() should use categories'))\n> +            issues.append(StyleIssue(line_number, match.span(1), line,\n> +                                     'LOG() should use categories'))\n>  \n>          return issues\n>  \n> @@ -660,8 +663,10 @@ class MesonChecker(StyleChecker):\n>          issues = []\n>          for line_number in line_numbers:\n>              line = self.__content[line_number-1]\n> -            if line.find('\\t') != -1:\n> -                issues.append(StyleIssue(line_number, line, 'meson.build should use spaces for indentation'))\n> +            pos = line.find('\\t')\n> +            if pos != -1:\n> +                issues.append(StyleIssue(line_number, [pos, pos], line,\n> +                                         'meson.build should use spaces for indentation'))\n>          return issues\n>  \n>  \n> @@ -681,7 +686,7 @@ class Pep8Checker(StyleChecker):\n>              ret = subprocess.run(['pycodestyle', '--ignore=E501', '-'],\n>                                   input=data, stdout=subprocess.PIPE)\n>          except FileNotFoundError:\n> -            issues.append(StyleIssue(0, None, 'Please install pycodestyle to validate python additions'))\n> +            issues.append(StyleIssue(0, None, None, 'Please install pycodestyle to validate python additions'))\n>              return issues\n>  \n>          results = ret.stdout.decode('utf-8').splitlines()\n> @@ -693,7 +698,7 @@ class Pep8Checker(StyleChecker):\n>  \n>              if line_number in line_numbers:\n>                  line = self.__content[line_number - 1]\n> -                issues.append(StyleIssue(line_number, line, msg))\n> +                issues.append(StyleIssue(line_number, None, line, msg))\n>  \n>          return issues\n>  \n> @@ -714,7 +719,7 @@ class ShellChecker(StyleChecker):\n>              ret = subprocess.run(['shellcheck', '-Cnever', '-'],\n>                                   input=data, stdout=subprocess.PIPE)\n>          except FileNotFoundError:\n> -            issues.append(StyleIssue(0, None, 'Please install shellcheck to validate shell script additions'))\n> +            issues.append(StyleIssue(0, None, None, 'Please install shellcheck to validate shell script additions'))\n>              return issues\n>  \n>          results = ret.stdout.decode('utf-8').splitlines()\n> @@ -727,11 +732,8 @@ class ShellChecker(StyleChecker):\n>              line = results[nr + 1]\n>              msg = results[nr + 2]\n>  \n> -            # Determined, but not yet used\n> -            position = msg.find('^') + 1\n> -\n>              if line_number in line_numbers:\n> -                issues.append(StyleIssue(line_number, line, msg))\n> +                issues.append(StyleIssue(line_number, None, line, msg))\n>  \n>          return issues\n>  \n> @@ -973,6 +975,15 @@ def check_file(top_level, commit, filename, checkers):\n>                  print('%s+%s%s' % (Colours.fg(Colours.Yellow), issue.line.rstrip(),\n>                                     Colours.reset()))\n>  \n> +                if issue.position is not None:\n> +                    # Align the position marker by using the original line with\n> +                    # all characters by tabs replaced with spaces. This ensures\n\nI'm confused by the english here.\n\n\nPaul\n\n> +                    # proper alignment regardless of how the code is indented.\n> +                    start = issue.position[0]\n> +                    prefix = ''.join([c if c == '\\t' else ' ' for c in issue.line[:start]])\n> +                    length = issue.position[1] - start - 1\n> +                    print(' ' + prefix + '^' + '~' * length)\n> +\n>      return len(formatted_diff) + len(issues)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A2E16BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 13:17:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 70D62634B6;\n\tFri, 31 May 2024 15:17:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D978461A46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 15:17:17 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EBD57A06;\n\tFri, 31 May 2024 15:17:11 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RVaRriIi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717161432;\n\tbh=0xGtwVZPmFWdaYpu7r1K2u8+xIUCsaZ2eZX+bvAxD8E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=RVaRriIi1Cj8At4s7HuAf8Htes405hBSV/yQopRGLdG0mXASnCiuMIz1TWn0pwOt8\n\t3W/lSHsOPncpgof8Invqh5iuba6ibSXNkEMEx2e9D3VKCUN9tYjzWwQHNrW11GUFoP\n\tMI7xUqeVDHPKmHAvSuzxplm9XRMEzfdZRXON7+sU=","Date":"Fri, 31 May 2024 22:17:10 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","Message-ID":"<ZlnN1iC2ZxKIj7iA@pyrite.rasen.tech>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-5-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240531121838.27643-5-laurent.pinchart@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29704,"web_url":"https://patchwork.libcamera.org/comment/29704/","msgid":"<20240531133325.GA30354@pendragon.ideasonboard.com>","date":"2024-05-31T13:33:25","subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, May 31, 2024 at 10:17:10PM +0900, Paul Elder wrote:\n> Hi Laurent,\n> \n> On Fri, May 31, 2024 at 03:18:38PM +0300, Laurent Pinchart wrote:\n> > The issue checkers display the line number and line content of each\n> > offending line, but don't show the location of the issue within a line.\n> > Improve checkstyle by adding a marker that points to the exact location.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  utils/checkstyle.py | 39 +++++++++++++++++++++++++--------------\n> >  1 file changed, 25 insertions(+), 14 deletions(-)\n> > \n> > diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> > index 77d6f39011c1..ff885aa98d65 100755\n> > --- a/utils/checkstyle.py\n> > +++ b/utils/checkstyle.py\n> > @@ -556,8 +556,9 @@ class StyleChecker(metaclass=ClassRegistry):\n> >  \n> >  \n> >  class StyleIssue(object):\n> > -    def __init__(self, line_number, line, msg):\n> > +    def __init__(self, line_number, position, line, msg):\n> >          self.line_number = line_number\n> > +        self.position = position\n> >          self.line = line\n> >          self.msg = msg\n> >  \n> > @@ -584,7 +585,7 @@ class HexValueChecker(StyleChecker):\n> >              if value == value.lower():\n> >                  continue\n> >  \n> > -            issues.append(StyleIssue(line_number, line,\n> > +            issues.append(StyleIssue(line_number, match.span(0), line,\n> >                                       f'Use lowercase hex constant {value.lower()}'))\n> >  \n> >          return issues\n> > @@ -623,7 +624,7 @@ class IncludeChecker(StyleChecker):\n> >                  header_type = 'C compatibility'\n> >                  header = header[1:] + '.h'\n> >  \n> > -            issues.append(StyleIssue(line_number, line,\n> > +            issues.append(StyleIssue(line_number, match.span(1), line,\n> >                                       f'{header_type} header <{header}> is preferred'))\n> >  \n> >          return issues\n> > @@ -641,10 +642,12 @@ class LogCategoryChecker(StyleChecker):\n> >          issues = []\n> >          for line_number in line_numbers:\n> >              line = self.__content[line_number-1]\n> > -            if not LogCategoryChecker.log_regex.search(line):\n> > +            match = LogCategoryChecker.log_regex.search(line)\n> > +            if not match:\n> >                  continue\n> >  \n> > -            issues.append(StyleIssue(line_number, line, 'LOG() should use categories'))\n> > +            issues.append(StyleIssue(line_number, match.span(1), line,\n> > +                                     'LOG() should use categories'))\n> >  \n> >          return issues\n> >  \n> > @@ -660,8 +663,10 @@ class MesonChecker(StyleChecker):\n> >          issues = []\n> >          for line_number in line_numbers:\n> >              line = self.__content[line_number-1]\n> > -            if line.find('\\t') != -1:\n> > -                issues.append(StyleIssue(line_number, line, 'meson.build should use spaces for indentation'))\n> > +            pos = line.find('\\t')\n> > +            if pos != -1:\n> > +                issues.append(StyleIssue(line_number, [pos, pos], line,\n> > +                                         'meson.build should use spaces for indentation'))\n> >          return issues\n> >  \n> >  \n> > @@ -681,7 +686,7 @@ class Pep8Checker(StyleChecker):\n> >              ret = subprocess.run(['pycodestyle', '--ignore=E501', '-'],\n> >                                   input=data, stdout=subprocess.PIPE)\n> >          except FileNotFoundError:\n> > -            issues.append(StyleIssue(0, None, 'Please install pycodestyle to validate python additions'))\n> > +            issues.append(StyleIssue(0, None, None, 'Please install pycodestyle to validate python additions'))\n> >              return issues\n> >  \n> >          results = ret.stdout.decode('utf-8').splitlines()\n> > @@ -693,7 +698,7 @@ class Pep8Checker(StyleChecker):\n> >  \n> >              if line_number in line_numbers:\n> >                  line = self.__content[line_number - 1]\n> > -                issues.append(StyleIssue(line_number, line, msg))\n> > +                issues.append(StyleIssue(line_number, None, line, msg))\n> >  \n> >          return issues\n> >  \n> > @@ -714,7 +719,7 @@ class ShellChecker(StyleChecker):\n> >              ret = subprocess.run(['shellcheck', '-Cnever', '-'],\n> >                                   input=data, stdout=subprocess.PIPE)\n> >          except FileNotFoundError:\n> > -            issues.append(StyleIssue(0, None, 'Please install shellcheck to validate shell script additions'))\n> > +            issues.append(StyleIssue(0, None, None, 'Please install shellcheck to validate shell script additions'))\n> >              return issues\n> >  \n> >          results = ret.stdout.decode('utf-8').splitlines()\n> > @@ -727,11 +732,8 @@ class ShellChecker(StyleChecker):\n> >              line = results[nr + 1]\n> >              msg = results[nr + 2]\n> >  \n> > -            # Determined, but not yet used\n> > -            position = msg.find('^') + 1\n> > -\n> >              if line_number in line_numbers:\n> > -                issues.append(StyleIssue(line_number, line, msg))\n> > +                issues.append(StyleIssue(line_number, None, line, msg))\n> >  \n> >          return issues\n> >  \n> > @@ -973,6 +975,15 @@ def check_file(top_level, commit, filename, checkers):\n> >                  print('%s+%s%s' % (Colours.fg(Colours.Yellow), issue.line.rstrip(),\n> >                                     Colours.reset()))\n> >  \n> > +                if issue.position is not None:\n> > +                    # Align the position marker by using the original line with\n> > +                    # all characters by tabs replaced with spaces. This ensures\n> \n> I'm confused by the english here.\n\ns/by tabs/but tabs/\n\nIs that clearer ?\n\n> > +                    # proper alignment regardless of how the code is indented.\n> > +                    start = issue.position[0]\n> > +                    prefix = ''.join([c if c == '\\t' else ' ' for c in issue.line[:start]])\n> > +                    length = issue.position[1] - start - 1\n> > +                    print(' ' + prefix + '^' + '~' * length)\n> > +\n> >      return len(formatted_diff) + len(issues)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DF68FBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 13:33:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A09A6634BB;\n\tFri, 31 May 2024 15:33:40 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA80B634B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 15:33:38 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D682AA06;\n\tFri, 31 May 2024 15:33:33 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"F3p5av/1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717162414;\n\tbh=2p5bpP2/rwYWv80jyBqSDMdPGdeLE6UecDKOkOj+chg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=F3p5av/1B9qQVySby5e7HXtJwdjMiKPhaMaUkpPHxahLOQk775DzW2/B8HXrLdcqs\n\tMONaxVIeIxOMaDCJoYc3rDKVTNlnWnDNE4/YlheVmowxWyeyAVhWxrB5Hjx4Ca3Pjw\n\tq9aVu7TVGWeBKq/L90gzYxfPwZKt7oe77LAUUS1U=","Date":"Fri, 31 May 2024 16:33:25 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","Message-ID":"<20240531133325.GA30354@pendragon.ideasonboard.com>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-5-laurent.pinchart@ideasonboard.com>\n\t<ZlnN1iC2ZxKIj7iA@pyrite.rasen.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<ZlnN1iC2ZxKIj7iA@pyrite.rasen.tech>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29708,"web_url":"https://patchwork.libcamera.org/comment/29708/","msgid":"<ZlnZ4kDqH1BvDw2X@pyrite.rasen.tech>","date":"2024-05-31T14:08:34","subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Fri, May 31, 2024 at 04:33:25PM +0300, Laurent Pinchart wrote:\n> On Fri, May 31, 2024 at 10:17:10PM +0900, Paul Elder wrote:\n> > Hi Laurent,\n> > \n> > On Fri, May 31, 2024 at 03:18:38PM +0300, Laurent Pinchart wrote:\n> > > The issue checkers display the line number and line content of each\n> > > offending line, but don't show the location of the issue within a line.\n> > > Improve checkstyle by adding a marker that points to the exact location.\n> > > \n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  utils/checkstyle.py | 39 +++++++++++++++++++++++++--------------\n> > >  1 file changed, 25 insertions(+), 14 deletions(-)\n> > > \n> > > diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> > > index 77d6f39011c1..ff885aa98d65 100755\n> > > --- a/utils/checkstyle.py\n> > > +++ b/utils/checkstyle.py\n> > > @@ -556,8 +556,9 @@ class StyleChecker(metaclass=ClassRegistry):\n> > >  \n> > >  \n> > >  class StyleIssue(object):\n> > > -    def __init__(self, line_number, line, msg):\n> > > +    def __init__(self, line_number, position, line, msg):\n> > >          self.line_number = line_number\n> > > +        self.position = position\n> > >          self.line = line\n> > >          self.msg = msg\n> > >  \n> > > @@ -584,7 +585,7 @@ class HexValueChecker(StyleChecker):\n> > >              if value == value.lower():\n> > >                  continue\n> > >  \n> > > -            issues.append(StyleIssue(line_number, line,\n> > > +            issues.append(StyleIssue(line_number, match.span(0), line,\n> > >                                       f'Use lowercase hex constant {value.lower()}'))\n> > >  \n> > >          return issues\n> > > @@ -623,7 +624,7 @@ class IncludeChecker(StyleChecker):\n> > >                  header_type = 'C compatibility'\n> > >                  header = header[1:] + '.h'\n> > >  \n> > > -            issues.append(StyleIssue(line_number, line,\n> > > +            issues.append(StyleIssue(line_number, match.span(1), line,\n> > >                                       f'{header_type} header <{header}> is preferred'))\n> > >  \n> > >          return issues\n> > > @@ -641,10 +642,12 @@ class LogCategoryChecker(StyleChecker):\n> > >          issues = []\n> > >          for line_number in line_numbers:\n> > >              line = self.__content[line_number-1]\n> > > -            if not LogCategoryChecker.log_regex.search(line):\n> > > +            match = LogCategoryChecker.log_regex.search(line)\n> > > +            if not match:\n> > >                  continue\n> > >  \n> > > -            issues.append(StyleIssue(line_number, line, 'LOG() should use categories'))\n> > > +            issues.append(StyleIssue(line_number, match.span(1), line,\n> > > +                                     'LOG() should use categories'))\n> > >  \n> > >          return issues\n> > >  \n> > > @@ -660,8 +663,10 @@ class MesonChecker(StyleChecker):\n> > >          issues = []\n> > >          for line_number in line_numbers:\n> > >              line = self.__content[line_number-1]\n> > > -            if line.find('\\t') != -1:\n> > > -                issues.append(StyleIssue(line_number, line, 'meson.build should use spaces for indentation'))\n> > > +            pos = line.find('\\t')\n> > > +            if pos != -1:\n> > > +                issues.append(StyleIssue(line_number, [pos, pos], line,\n> > > +                                         'meson.build should use spaces for indentation'))\n> > >          return issues\n> > >  \n> > >  \n> > > @@ -681,7 +686,7 @@ class Pep8Checker(StyleChecker):\n> > >              ret = subprocess.run(['pycodestyle', '--ignore=E501', '-'],\n> > >                                   input=data, stdout=subprocess.PIPE)\n> > >          except FileNotFoundError:\n> > > -            issues.append(StyleIssue(0, None, 'Please install pycodestyle to validate python additions'))\n> > > +            issues.append(StyleIssue(0, None, None, 'Please install pycodestyle to validate python additions'))\n> > >              return issues\n> > >  \n> > >          results = ret.stdout.decode('utf-8').splitlines()\n> > > @@ -693,7 +698,7 @@ class Pep8Checker(StyleChecker):\n> > >  \n> > >              if line_number in line_numbers:\n> > >                  line = self.__content[line_number - 1]\n> > > -                issues.append(StyleIssue(line_number, line, msg))\n> > > +                issues.append(StyleIssue(line_number, None, line, msg))\n> > >  \n> > >          return issues\n> > >  \n> > > @@ -714,7 +719,7 @@ class ShellChecker(StyleChecker):\n> > >              ret = subprocess.run(['shellcheck', '-Cnever', '-'],\n> > >                                   input=data, stdout=subprocess.PIPE)\n> > >          except FileNotFoundError:\n> > > -            issues.append(StyleIssue(0, None, 'Please install shellcheck to validate shell script additions'))\n> > > +            issues.append(StyleIssue(0, None, None, 'Please install shellcheck to validate shell script additions'))\n> > >              return issues\n> > >  \n> > >          results = ret.stdout.decode('utf-8').splitlines()\n> > > @@ -727,11 +732,8 @@ class ShellChecker(StyleChecker):\n> > >              line = results[nr + 1]\n> > >              msg = results[nr + 2]\n> > >  \n> > > -            # Determined, but not yet used\n> > > -            position = msg.find('^') + 1\n> > > -\n> > >              if line_number in line_numbers:\n> > > -                issues.append(StyleIssue(line_number, line, msg))\n> > > +                issues.append(StyleIssue(line_number, None, line, msg))\n> > >  \n> > >          return issues\n> > >  \n> > > @@ -973,6 +975,15 @@ def check_file(top_level, commit, filename, checkers):\n> > >                  print('%s+%s%s' % (Colours.fg(Colours.Yellow), issue.line.rstrip(),\n> > >                                     Colours.reset()))\n> > >  \n> > > +                if issue.position is not None:\n> > > +                    # Align the position marker by using the original line with\n> > > +                    # all characters by tabs replaced with spaces. This ensures\n> > \n> > I'm confused by the english here.\n> \n> s/by tabs/but tabs/\n> \n> Is that clearer ?\n\nYep, thanks.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> > > +                    # proper alignment regardless of how the code is indented.\n> > > +                    start = issue.position[0]\n> > > +                    prefix = ''.join([c if c == '\\t' else ' ' for c in issue.line[:start]])\n> > > +                    length = issue.position[1] - start - 1\n> > > +                    print(' ' + prefix + '^' + '~' * length)\n> > > +\n> > >      return len(formatted_diff) + len(issues)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id F2DBBBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 14:08:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DBD72634B6;\n\tFri, 31 May 2024 16:08:42 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 839E361A46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 16:08:41 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6CBC7B53;\n\tFri, 31 May 2024 16:08:35 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"YdwgzTsH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717164516;\n\tbh=R7aUG/wHA5uxFOA5ZGxPEq+yDzRxTPmJ/pwwWZ+uuWs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YdwgzTsHevpE4rxBzfih2CarwQ1xJZ281+6IYD9P11UaPzB+1wnMxyOES+tZbErX4\n\tjGrjLb9T/WTMTSAdCTl/e8PWyT0GrQjeWv3Ph1g1aKNYOok5awbAidfFG+TSQmb8am\n\twKlwpvjly9xdh1YhucFuqNhPeQIRzE5PzZv+zgfQ=","Date":"Fri, 31 May 2024 23:08:34 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","Message-ID":"<ZlnZ4kDqH1BvDw2X@pyrite.rasen.tech>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-5-laurent.pinchart@ideasonboard.com>\n\t<ZlnN1iC2ZxKIj7iA@pyrite.rasen.tech>\n\t<20240531133325.GA30354@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240531133325.GA30354@pendragon.ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29709,"web_url":"https://patchwork.libcamera.org/comment/29709/","msgid":"<171716485463.2228432.5034118829285060179@ping.linuxembedded.co.uk>","date":"2024-05-31T14:14:14","subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-05-31 14:33:25)\n> On Fri, May 31, 2024 at 10:17:10PM +0900, Paul Elder wrote:\n> > Hi Laurent,\n> > \n> > On Fri, May 31, 2024 at 03:18:38PM +0300, Laurent Pinchart wrote:\n> > > The issue checkers display the line number and line content of each\n> > > offending line, but don't show the location of the issue within a line.\n> > > Improve checkstyle by adding a marker that points to the exact location.\n> > > \n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  utils/checkstyle.py | 39 +++++++++++++++++++++++++--------------\n> > >  1 file changed, 25 insertions(+), 14 deletions(-)\n> > > \n> > > diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> > > index 77d6f39011c1..ff885aa98d65 100755\n> > > --- a/utils/checkstyle.py\n> > > +++ b/utils/checkstyle.py\n> > > @@ -556,8 +556,9 @@ class StyleChecker(metaclass=ClassRegistry):\n> > >  \n> > >  \n> > >  class StyleIssue(object):\n> > > -    def __init__(self, line_number, line, msg):\n> > > +    def __init__(self, line_number, position, line, msg):\n> > >          self.line_number = line_number\n> > > +        self.position = position\n> > >          self.line = line\n> > >          self.msg = msg\n> > >  \n> > > @@ -584,7 +585,7 @@ class HexValueChecker(StyleChecker):\n> > >              if value == value.lower():\n> > >                  continue\n> > >  \n> > > -            issues.append(StyleIssue(line_number, line,\n> > > +            issues.append(StyleIssue(line_number, match.span(0), line,\n> > >                                       f'Use lowercase hex constant {value.lower()}'))\n> > >  \n> > >          return issues\n> > > @@ -623,7 +624,7 @@ class IncludeChecker(StyleChecker):\n> > >                  header_type = 'C compatibility'\n> > >                  header = header[1:] + '.h'\n> > >  \n> > > -            issues.append(StyleIssue(line_number, line,\n> > > +            issues.append(StyleIssue(line_number, match.span(1), line,\n> > >                                       f'{header_type} header <{header}> is preferred'))\n> > >  \n> > >          return issues\n> > > @@ -641,10 +642,12 @@ class LogCategoryChecker(StyleChecker):\n> > >          issues = []\n> > >          for line_number in line_numbers:\n> > >              line = self.__content[line_number-1]\n> > > -            if not LogCategoryChecker.log_regex.search(line):\n> > > +            match = LogCategoryChecker.log_regex.search(line)\n> > > +            if not match:\n> > >                  continue\n> > >  \n> > > -            issues.append(StyleIssue(line_number, line, 'LOG() should use categories'))\n> > > +            issues.append(StyleIssue(line_number, match.span(1), line,\n> > > +                                     'LOG() should use categories'))\n> > >  \n> > >          return issues\n> > >  \n> > > @@ -660,8 +663,10 @@ class MesonChecker(StyleChecker):\n> > >          issues = []\n> > >          for line_number in line_numbers:\n> > >              line = self.__content[line_number-1]\n> > > -            if line.find('\\t') != -1:\n> > > -                issues.append(StyleIssue(line_number, line, 'meson.build should use spaces for indentation'))\n> > > +            pos = line.find('\\t')\n> > > +            if pos != -1:\n> > > +                issues.append(StyleIssue(line_number, [pos, pos], line,\n> > > +                                         'meson.build should use spaces for indentation'))\n> > >          return issues\n> > >  \n> > >  \n> > > @@ -681,7 +686,7 @@ class Pep8Checker(StyleChecker):\n> > >              ret = subprocess.run(['pycodestyle', '--ignore=E501', '-'],\n> > >                                   input=data, stdout=subprocess.PIPE)\n> > >          except FileNotFoundError:\n> > > -            issues.append(StyleIssue(0, None, 'Please install pycodestyle to validate python additions'))\n> > > +            issues.append(StyleIssue(0, None, None, 'Please install pycodestyle to validate python additions'))\n> > >              return issues\n> > >  \n> > >          results = ret.stdout.decode('utf-8').splitlines()\n> > > @@ -693,7 +698,7 @@ class Pep8Checker(StyleChecker):\n> > >  \n> > >              if line_number in line_numbers:\n> > >                  line = self.__content[line_number - 1]\n> > > -                issues.append(StyleIssue(line_number, line, msg))\n> > > +                issues.append(StyleIssue(line_number, None, line, msg))\n> > >  \n> > >          return issues\n> > >  \n> > > @@ -714,7 +719,7 @@ class ShellChecker(StyleChecker):\n> > >              ret = subprocess.run(['shellcheck', '-Cnever', '-'],\n> > >                                   input=data, stdout=subprocess.PIPE)\n> > >          except FileNotFoundError:\n> > > -            issues.append(StyleIssue(0, None, 'Please install shellcheck to validate shell script additions'))\n> > > +            issues.append(StyleIssue(0, None, None, 'Please install shellcheck to validate shell script additions'))\n> > >              return issues\n> > >  \n> > >          results = ret.stdout.decode('utf-8').splitlines()\n> > > @@ -727,11 +732,8 @@ class ShellChecker(StyleChecker):\n> > >              line = results[nr + 1]\n> > >              msg = results[nr + 2]\n> > >  \n> > > -            # Determined, but not yet used\n> > > -            position = msg.find('^') + 1\n> > > -\n> > >              if line_number in line_numbers:\n> > > -                issues.append(StyleIssue(line_number, line, msg))\n> > > +                issues.append(StyleIssue(line_number, None, line, msg))\n> > >  \n> > >          return issues\n> > >  \n> > > @@ -973,6 +975,15 @@ def check_file(top_level, commit, filename, checkers):\n> > >                  print('%s+%s%s' % (Colours.fg(Colours.Yellow), issue.line.rstrip(),\n> > >                                     Colours.reset()))\n> > >  \n> > > +                if issue.position is not None:\n> > > +                    # Align the position marker by using the original line with\n> > > +                    # all characters by tabs replaced with spaces. This ensures\n> > \n> > I'm confused by the english here.\n> \n> s/by tabs/but tabs/\n> \n> Is that clearer ?\n\nOh I see. Do you mean all up to the point of the marker?\nI'd use \"with all characters except for tabs replaced by spaces\"\n\n(optional by spaces/with spaces)\n\n\n> > > +                    # proper alignment regardless of how the code is indented.\n> > > +                    start = issue.position[0]\n> > > +                    prefix = ''.join([c if c == '\\t' else ' ' for c in issue.line[:start]])\n> > > +                    length = issue.position[1] - start - 1\n> > > +                    print(' ' + prefix + '^' + '~' * length)\n\nI'm not sure I understand how this will correctly determine the position\nwith combinations of tabs/spaces but let see.\n\nI expect you'll have tested it so I look forward to seeing the results.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> > > +\n> > >      return len(formatted_diff) + len(issues)\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9AB07BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 14:14:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 85627634B6;\n\tFri, 31 May 2024 16:14:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1CD7F61A46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 16:14:18 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DD1ADB53;\n\tFri, 31 May 2024 16:14:12 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Z4bS0k8E\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717164853;\n\tbh=eOfVYe1Er0tMzncTUD2l3MntNoMY+gC+SQFOvmfXmsc=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Z4bS0k8EqYZj8sXcc7spBzzaFd5Z0DvvF72XKf3uqr4BpzMNyKo/qIVYLbiZwW6NZ\n\tFrcJiDNH1BWVM34ZrzHthUtSnEDu7scb9wuxyJlbI4oDzDCtzHajf9aXAvBkkHmME0\n\tOJk3sM7J0ua2SNEAOOvifWlNhP2lbDt03M8Fs20w=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240531133325.GA30354@pendragon.ideasonboard.com>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-5-laurent.pinchart@ideasonboard.com>\n\t<ZlnN1iC2ZxKIj7iA@pyrite.rasen.tech>\n\t<20240531133325.GA30354@pendragon.ideasonboard.com>","Subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Date":"Fri, 31 May 2024 15:14:14 +0100","Message-ID":"<171716485463.2228432.5034118829285060179@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29716,"web_url":"https://patchwork.libcamera.org/comment/29716/","msgid":"<20240531170853.GA4534@pendragon.ideasonboard.com>","date":"2024-05-31T17:08:53","subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, May 31, 2024 at 03:14:14PM +0100, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2024-05-31 14:33:25)\n> > On Fri, May 31, 2024 at 10:17:10PM +0900, Paul Elder wrote:\n> > > On Fri, May 31, 2024 at 03:18:38PM +0300, Laurent Pinchart wrote:\n> > > > The issue checkers display the line number and line content of each\n> > > > offending line, but don't show the location of the issue within a line.\n> > > > Improve checkstyle by adding a marker that points to the exact location.\n> > > > \n> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > ---\n> > > >  utils/checkstyle.py | 39 +++++++++++++++++++++++++--------------\n> > > >  1 file changed, 25 insertions(+), 14 deletions(-)\n> > > > \n> > > > diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> > > > index 77d6f39011c1..ff885aa98d65 100755\n> > > > --- a/utils/checkstyle.py\n> > > > +++ b/utils/checkstyle.py\n> > > > @@ -556,8 +556,9 @@ class StyleChecker(metaclass=ClassRegistry):\n> > > >  \n> > > >  \n> > > >  class StyleIssue(object):\n> > > > -    def __init__(self, line_number, line, msg):\n> > > > +    def __init__(self, line_number, position, line, msg):\n> > > >          self.line_number = line_number\n> > > > +        self.position = position\n> > > >          self.line = line\n> > > >          self.msg = msg\n> > > >  \n> > > > @@ -584,7 +585,7 @@ class HexValueChecker(StyleChecker):\n> > > >              if value == value.lower():\n> > > >                  continue\n> > > >  \n> > > > -            issues.append(StyleIssue(line_number, line,\n> > > > +            issues.append(StyleIssue(line_number, match.span(0), line,\n> > > >                                       f'Use lowercase hex constant {value.lower()}'))\n> > > >  \n> > > >          return issues\n> > > > @@ -623,7 +624,7 @@ class IncludeChecker(StyleChecker):\n> > > >                  header_type = 'C compatibility'\n> > > >                  header = header[1:] + '.h'\n> > > >  \n> > > > -            issues.append(StyleIssue(line_number, line,\n> > > > +            issues.append(StyleIssue(line_number, match.span(1), line,\n> > > >                                       f'{header_type} header <{header}> is preferred'))\n> > > >  \n> > > >          return issues\n> > > > @@ -641,10 +642,12 @@ class LogCategoryChecker(StyleChecker):\n> > > >          issues = []\n> > > >          for line_number in line_numbers:\n> > > >              line = self.__content[line_number-1]\n> > > > -            if not LogCategoryChecker.log_regex.search(line):\n> > > > +            match = LogCategoryChecker.log_regex.search(line)\n> > > > +            if not match:\n> > > >                  continue\n> > > >  \n> > > > -            issues.append(StyleIssue(line_number, line, 'LOG() should use categories'))\n> > > > +            issues.append(StyleIssue(line_number, match.span(1), line,\n> > > > +                                     'LOG() should use categories'))\n> > > >  \n> > > >          return issues\n> > > >  \n> > > > @@ -660,8 +663,10 @@ class MesonChecker(StyleChecker):\n> > > >          issues = []\n> > > >          for line_number in line_numbers:\n> > > >              line = self.__content[line_number-1]\n> > > > -            if line.find('\\t') != -1:\n> > > > -                issues.append(StyleIssue(line_number, line, 'meson.build should use spaces for indentation'))\n> > > > +            pos = line.find('\\t')\n> > > > +            if pos != -1:\n> > > > +                issues.append(StyleIssue(line_number, [pos, pos], line,\n> > > > +                                         'meson.build should use spaces for indentation'))\n> > > >          return issues\n> > > >  \n> > > >  \n> > > > @@ -681,7 +686,7 @@ class Pep8Checker(StyleChecker):\n> > > >              ret = subprocess.run(['pycodestyle', '--ignore=E501', '-'],\n> > > >                                   input=data, stdout=subprocess.PIPE)\n> > > >          except FileNotFoundError:\n> > > > -            issues.append(StyleIssue(0, None, 'Please install pycodestyle to validate python additions'))\n> > > > +            issues.append(StyleIssue(0, None, None, 'Please install pycodestyle to validate python additions'))\n> > > >              return issues\n> > > >  \n> > > >          results = ret.stdout.decode('utf-8').splitlines()\n> > > > @@ -693,7 +698,7 @@ class Pep8Checker(StyleChecker):\n> > > >  \n> > > >              if line_number in line_numbers:\n> > > >                  line = self.__content[line_number - 1]\n> > > > -                issues.append(StyleIssue(line_number, line, msg))\n> > > > +                issues.append(StyleIssue(line_number, None, line, msg))\n> > > >  \n> > > >          return issues\n> > > >  \n> > > > @@ -714,7 +719,7 @@ class ShellChecker(StyleChecker):\n> > > >              ret = subprocess.run(['shellcheck', '-Cnever', '-'],\n> > > >                                   input=data, stdout=subprocess.PIPE)\n> > > >          except FileNotFoundError:\n> > > > -            issues.append(StyleIssue(0, None, 'Please install shellcheck to validate shell script additions'))\n> > > > +            issues.append(StyleIssue(0, None, None, 'Please install shellcheck to validate shell script additions'))\n> > > >              return issues\n> > > >  \n> > > >          results = ret.stdout.decode('utf-8').splitlines()\n> > > > @@ -727,11 +732,8 @@ class ShellChecker(StyleChecker):\n> > > >              line = results[nr + 1]\n> > > >              msg = results[nr + 2]\n> > > >  \n> > > > -            # Determined, but not yet used\n> > > > -            position = msg.find('^') + 1\n> > > > -\n> > > >              if line_number in line_numbers:\n> > > > -                issues.append(StyleIssue(line_number, line, msg))\n> > > > +                issues.append(StyleIssue(line_number, None, line, msg))\n> > > >  \n> > > >          return issues\n> > > >  \n> > > > @@ -973,6 +975,15 @@ def check_file(top_level, commit, filename, checkers):\n> > > >                  print('%s+%s%s' % (Colours.fg(Colours.Yellow), issue.line.rstrip(),\n> > > >                                     Colours.reset()))\n> > > >  \n> > > > +                if issue.position is not None:\n> > > > +                    # Align the position marker by using the original line with\n> > > > +                    # all characters by tabs replaced with spaces. This ensures\n> > > \n> > > I'm confused by the english here.\n> > \n> > s/by tabs/but tabs/\n> > \n> > Is that clearer ?\n> \n> Oh I see. Do you mean all up to the point of the marker?\n> I'd use \"with all characters except for tabs replaced by spaces\"\n\nI'll use that.\n\n> (optional by spaces/with spaces)\n> \n> > > > +                    # proper alignment regardless of how the code is indented.\n> > > > +                    start = issue.position[0]\n> > > > +                    prefix = ''.join([c if c == '\\t' else ' ' for c in issue.line[:start]])\n> > > > +                    length = issue.position[1] - start - 1\n> > > > +                    print(' ' + prefix + '^' + '~' * length)\n> \n> I'm not sure I understand how this will correctly determine the position\n> with combinations of tabs/spaces but let see.\n> \n> I expect you'll have tested it so I look forward to seeing the results.\n\n$ ./utils/checkstyle.py 3755d966485d96e76eef7756222baf02dea960a4\n--------------------------------------------------------------------------------------\n3755d966485d96e76eef7756222baf02dea960a4 libcamera: software_isp: Add DebayerCpu class\n--------------------------------------------------------------------------------------\n--- src/libcamera/software_isp/debayer_cpu.cpp\n+++ src/libcamera/software_isp/debayer_cpu.cpp\n#14: C++ header <cmath> is preferred\n+#include <math.h>\n           ^~~~~~\n---\n1 potential issue detected, please review\n\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > > > +\n> > > >      return len(formatted_diff) + len(issues)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BD60BBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 May 2024 17:09:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 94495634B7;\n\tFri, 31 May 2024 19:09:09 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0BA4161A46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2024 19:09:08 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7A5C92D5F;\n\tFri, 31 May 2024 19:09:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dGPyRN/8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717175342;\n\tbh=AyCrheGb+vRFiHL+AJzbEo8hk9+a2Smic57G42bEDkA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=dGPyRN/8oIsd4tfgWkh2SJbE6iBXW30H4APTN1WV9esH9vqiz8l7bxyzia9wyDwfW\n\t5c/6BasBBjUM8zMSW5cbFHwevDQ7e9o1fl9GNdE+28XLC2Uq9L3iJTDOumX8xHvhOq\n\tEIl7sAeuIsIHdV5dCYZe2Z+JL2Q75eocV8XbMtvs=","Date":"Fri, 31 May 2024 20:08:53 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 4/4] utils: checkstyle.py: Show location of coding style\n\tissue within line","Message-ID":"<20240531170853.GA4534@pendragon.ideasonboard.com>","References":"<20240531121838.27643-1-laurent.pinchart@ideasonboard.com>\n\t<20240531121838.27643-5-laurent.pinchart@ideasonboard.com>\n\t<ZlnN1iC2ZxKIj7iA@pyrite.rasen.tech>\n\t<20240531133325.GA30354@pendragon.ideasonboard.com>\n\t<171716485463.2228432.5034118829285060179@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<171716485463.2228432.5034118829285060179@ping.linuxembedded.co.uk>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]