[Bug 268640] ports-mgmt/portlint: reported line numbers are sometimes wrong

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 29 Dec 2022 14:24:01 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268640

            Bug ID: 268640
           Summary: ports-mgmt/portlint: reported line numbers are
                    sometimes wrong
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: marcus@FreeBSD.org
          Reporter: vidar@karlsen.tech
             Flags: maintainer-feedback?(marcus@FreeBSD.org)
          Assignee: marcus@FreeBSD.org

I have noticed that portlint sometimes reports the wrong line numbers for
warnings and errors.
Below, I have inserted errors into a port's Makefile to demonstrate how it gets
reported by portlint.


Putting a != on line 15, portlint says it is on line 13:
# grep -n THIS Makefile
15:TRYTHIS!=    echo

# portlint
WARN: Makefile: [13]: use of != in assignments is almost never a good thing to
do.  Try to avoid using them.  See
http://lists.freebsd.org/pipermail/freebsd-ports/2008-July/049777.html for some
helpful hints on what to do instead.
WARN: Makefile: [13]: possible direct use of command "echo" found. use
${ECHO_CMD} or ${ECHO_MSG} instead.
0 fatal errors and 2 warnings found.


Putting some trailing whitespaces on line 13, portlint gets the whitespaces
right, but thinks the != is on the same line:
# grep -n "   " Makefile
13:USES=                gmake tar:tgz   <-- three whitespaces at the end of the
line here

# portlint
WARN: Makefile: [13]: whitespace before end of line.
WARN: Makefile: [13]: use of != in assignments is almost never a good thing to
do.  Try to avoid using them.  See
http://lists.freebsd.org/pipermail/freebsd-ports/2008-July/049777.html for some
helpful hints on what to do instead.
WARN: Makefile: [13]: possible direct use of command "echo" found. use
${ECHO_CMD} or ${ECHO_MSG} instead.
0 fatal errors and 3 warnings found.


Adding another variable above the != line, portlint now thinks the != is on
line 15 while it should say 16:
# egrep -n "THIS|SOMEOTHER|   " Makefile
13:USES=                gmake tar:tgz   
15:SOMEOTHER=   1
16:TRYTHIS!=    echo

# portlint
WARN: Makefile: [13]: whitespace before end of line.
WARN: Makefile: [15]: use of != in assignments is almost never a good thing to
do.  Try to avoid using them.  See
http://lists.freebsd.org/pipermail/freebsd-ports/2008-July/049777.html for some
helpful hints on what to do instead.
WARN: Makefile: [15]: possible direct use of command "echo" found. use
${ECHO_CMD} or ${ECHO_MSG} instead.
0 fatal errors and 3 warnings found.

-- 
You are receiving this mail because:
You are the assignee for the bug.