Last modified: 2013-10-22 09:33:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T57508, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 55508 - PHP CodeSniffer reports line length based on bytes, not on characters
PHP CodeSniffer reports line length based on bytes, not on characters
Status: RESOLVED FIXED
Product: Wikimedia
Classification: Unclassified
Continuous integration (Other open bugs)
wmf-deployment
All All
: Normal minor (vote)
: ---
Assigned To: Antoine "hashar" Musso (WMF)
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-09 11:37 UTC by Siebrand Mazeland
Modified: 2013-10-22 09:33 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Siebrand Mazeland 2013-10-09 11:37:03 UTC
From https://integration.wikimedia.org/ci/job/mwext-cldr-phpcs-strict/1/console:

11:21:52 FILE: ...nkins-slave/workspace/mwext-cldr-phpcs-strict/CldrNames/CldrNamesMy.php
11:21:52  643 | ERROR   | Line exceeds maximum limit of 120 characters; contains 162
11:21:52  648 | WARNING | Line exceeds 100 characters; contains 109 characters

These are the lines in question:

	'UM' => 'ယူနိုက်တက်စတိတ် အပြင်ထွက် နေသည့် သေးငယ်သောကျွန်းများ',
	'VC' => 'စိန့်ဗင့်ဆင့်နှင့် သည်ဂရဲနာဒင်းစ်',

Assuming tab width is 4, the line lengths are 67 and 48 respectively.
Comment 1 Antoine "hashar" Musso (WMF) 2013-10-09 12:01:39 UTC
phpcs defaults to iso-8859-1 defined in PHP_CODESNIFFER_ENCODING

CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php uses strlen(), whenever the encoding is not iso-8859-1 it would use:

  iconv_strlen($lineContent, PHP_CODESNIFFER_ENCODING);

So need to pass:

 --encoding=UTF-8
Comment 2 Siebrand Mazeland 2013-10-09 13:56:32 UTC
Our PHP files should be UTF-8 encoded, so we should run CodeSniffer in that mode. I'll see if I can submit a patch...
Comment 3 Gerrit Notification Bot 2013-10-09 14:20:52 UTC
Change 88743 had a related patch set uploaded by Siebrand:
Specify encoding of source files as utf-8

https://gerrit.wikimedia.org/r/88743
Comment 4 Gerrit Notification Bot 2013-10-09 14:40:01 UTC
Change 88743 merged by jenkins-bot:
Specify encoding of source files as utf-8

https://gerrit.wikimedia.org/r/88743
Comment 5 Krinkle 2013-10-09 18:27:18 UTC
Have the jobs been pushed? The change is merged but in https://integration.wikimedia.org/ci/job/mwext-VisualEditor-phpcs-HEAD/1524/console I don't see --encoding being passed.
Comment 6 Antoine "hashar" Musso (WMF) 2013-10-10 08:55:46 UTC
(In reply to comment #5)
> Have the jobs been pushed? The change is merged but in
> https://integration.wikimedia.org/ci/job/mwext-VisualEditor-phpcs-HEAD/1524/
> console
> I don't see --encoding being passed.

Good catch Timo. Something went wrong when I refreshed the jobs :(

Refreshing them:


$ grep 'encoding=utf' /var/lib/jenkins/jobs/*phpcs*/config.xml
/var/lib/jenkins/jobs/mwext-AbuseFilter-phpcs-HEAD/config.xml: --encoding=utf-8 \
/var/lib/jenkins/jobs/mwext-ActiveAbstract-phpcs-HEAD/config.xml: --encoding=ut-8 \
/var/lib/jenkins/jobs/mwext-AdminLinks-phpcs-HEAD/config.xml: --encoding=utf-8 \
Comment 7 Antoine "hashar" Musso (WMF) 2013-10-10 09:16:40 UTC
All jobs got refreshed. That should fix the issue now, if that is actually the case I guess we can close the bug report.
Comment 8 Antoine "hashar" Musso (WMF) 2013-10-22 09:33:19 UTC
I have retriggered the original build:

https://integration.wikimedia.org/ci/job/mwext-cldr-phpcs-strict/4/console

The phpcs command being run is:


 phpcs -v -s . --encoding=utf-8 \
  --standard=/var/lib/jenkins/tools/mwcodesniffer/MediaWiki \
  --extensions=php,php5,inc,sample \
  '--ignore=languages/messages/Messages,*.i18n.php,*.i18n.alias.php' \
  --report-checkstyle=checkstyle-phpcs.xml \
  --report-full

And the result is a SUCCESS.  So the fix was indeed to pass '--encoding=utf-8' to phpcs :-]

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links