Page MenuHomePhabricator

Added support for `export LC_ALL=C.UTF-8` to the shell linter
ClosedPublic

Authored by jasonbcox on Sep 30 2019, 23:04.

Details

Summary
Test Plan

arc lint on the following cases:

  • script with export LC_ALL=C
  • script with no LC_ALL set. Fails as expected.
  • script with export LC_ALL=C.UTF-8
  • script with export LC_ALL=C.UTF-9 Fails as expected (sanity check that we don't accidentally match on export LC_ALL=C)

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jasonbcox created this revision.Sep 30 2019, 23:04
Fabien requested changes to this revision.Oct 1 2019, 06:31
Fabien added a subscriber: Fabien.
Fabien added inline comments.
arcanist/linter/ShellLocaleLinter.php
1 ↗(On Diff #13279)

You should have a very recent phpcs because this rule is 3 months old according to github:
https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php

It enforces using the new PHP 7 strict_types declaration: https://www.php.net/manual/fr/control-structures.declare.php.

Because none of our code nor arcanist code is compliant, an exception can be added to the rule file (arcanist/phpcs.xml).

61 ↗(On Diff #13279)

PHP has the array_search() built-in for doing this:

if (array_search(trim($matches[0][0]), self::LOCALE_STATEMENTS, true) !== false) {
  return $this->raiseLintAtPath(
      self::INVALID_LOCALE,
      pht('Shell scripts should set the locale to avoid side effects.')
    );
}
This revision now requires changes to proceed.Oct 1 2019, 06:31
Fabien added a comment.Oct 1 2019, 06:33

Maybe there should be an explicit notice of backport here, as the remaining parts of the PR are Travis related ?

jasonbcox marked an inline comment as done.Oct 1 2019, 17:56
jasonbcox added inline comments.
arcanist/linter/ShellLocaleLinter.php
1 ↗(On Diff #13279)
jasonbcox marked 2 inline comments as done.Oct 1 2019, 18:05
jasonbcox added inline comments.
arcanist/linter/ShellLocaleLinter.php
61 ↗(On Diff #13279)

cool. equality is flipped though ;)

jasonbcox updated this revision to Diff 13299.Oct 1 2019, 18:10
jasonbcox marked an inline comment as done.

Rebase + Fix according to feedback

Fabien accepted this revision.Oct 1 2019, 18:47
Fabien added inline comments.
arcanist/linter/ShellLocaleLinter.php
61 ↗(On Diff #13279)

Oops... good catch !

This revision is now accepted and ready to land.Oct 1 2019, 18:47