[2/3] utils: checkstye: Show issue position for python issues
diff mbox series

Message ID 20240830125311.1702053-3-stefan.klug@ideasonboard.com
State Superseded
Headers show
Series
  • Python improvements to checkstyle.py
Related show

Commit Message

Stefan Klug Aug. 30, 2024, 12:52 p.m. UTC
pycodestyle doesn't report the issue length. But it reports the
position. Use that as indicator with zero length. This is better than no
indicator at all and reduces confusion when multiple issues occur on the
same line.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 utils/checkstyle.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Aug. 30, 2024, 2:51 p.m. UTC | #1
Hi Stefan,

Thank you for the patch.

On Fri, Aug 30, 2024 at 02:52:59PM +0200, Stefan Klug wrote:
> pycodestyle doesn't report the issue length. But it reports the
> position. Use that as indicator with zero length. This is better than no
> indicator at all and reduces confusion when multiple issues occur on the
> same line.

An example would be nice too.

> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>  utils/checkstyle.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/checkstyle.py b/utils/checkstyle.py
> index c6016f60a446..5901f1a71562 100755
> --- a/utils/checkstyle.py
> +++ b/utils/checkstyle.py
> @@ -737,7 +737,7 @@ class Pep8Checker(StyleChecker):
>  
>              if line_number in line_numbers:
>                  line = self.__content[line_number - 1]
> -                issues.append(StyleIssue(line_number, None, line, msg))
> +                issues.append(StyleIssue(line_number, [position, position + 1], line, msg))

I think this should be [position - 1, position].

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  
>          return issues
>

Patch
diff mbox series

diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index c6016f60a446..5901f1a71562 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -737,7 +737,7 @@  class Pep8Checker(StyleChecker):
 
             if line_number in line_numbers:
                 line = self.__content[line_number - 1]
-                issues.append(StyleIssue(line_number, None, line, msg))
+                issues.append(StyleIssue(line_number, [position, position + 1], line, msg))
 
         return issues