Page MenuHomePhabricator

PHPCS sometimes reports incorrect line numbers
Closed, InvalidPublic

Description

Seen on:
https://gerrit.wikimedia.org/r/#/c/401575/6/repo/Wikibase.hooks.php

where phpcs (mediawiki-extensions-hhvm-jessie job) reported error at line 1107 (empty) where in fact the error was at line 1102:

17:00:10 FILE: ...ions-hhvm-jessie/src/extensions/Wikibase/repo/Wikibase.hooks.php
17:00:10 ----------------------------------------------------------------------
17:00:10 FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
17:00:10 ----------------------------------------------------------------------
17:00:10  1107 | WARNING | [x] Single space expected before closing
17:00:10       |         |     parenthesis
17:00:10       |         |     (MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceBeforeCloseParenthesis)
17:00:10 ----------------------------------------------------------------------
17:00:10 PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY

Event Timeline

My suspicion is that your patch was not based on master, so jenkins merged it on top of master, which changed the line numbers when PHPCS was run as part of jenkins.

Parent of the linked version was 375c3eb1e3e5793d8191aec81f8e1f21e43b7c8c which is from Jan 2.

Run of phpcs was Feb 1 so I would support Legoktm answer, because history of that files shows merges with addition of lines - https://phabricator.wikimedia.org/diffusion/EWBA/history/master/repo/Wikibase.hooks.php

Thanks!
This makes perfect sense. Then I'm not sure this problem is fixable, I'm tempted to mark this ticket as invalid unless you think there are solutions to make this more obvious for devs that read jenkins output. I don't see any great solutions other than a small information line in the build output prior PHPCS that says: "The lines reported by PHPCS may not align with your patch as seen in gerrit if it was rebased".
Or perhaps outputting the faulty line in the PHPCS report if this is possible?
Anyways, please feel free to close this task as Invalid.

I don't really have any great ideas, including the line in the output seems like an interesting idea, but that would need to be implemented by upstream PHPCS.