Page MenuHomePhabricator

Modernize Script-and-Regex linter for ConfigurationDriven
ClosedPublic

Authored by avivey on Oct 14 2014, 10:47 PM.
Tags
None
Referenced Files
F13060568: D10704.diff
Fri, Apr 19, 6:03 PM
Unknown Object (File)
Fri, Apr 19, 2:09 AM
Unknown Object (File)
Mon, Mar 25, 1:47 PM
Unknown Object (File)
Mon, Mar 25, 1:47 PM
Unknown Object (File)
Feb 8 2024, 10:56 PM
Unknown Object (File)
Feb 3 2024, 1:07 AM
Unknown Object (File)
Feb 1 2024, 8:31 PM
Unknown Object (File)
Feb 1 2024, 6:15 PM
Tokens
"Love" token, awarded by vrusinov."Baby Tequila" token, awarded by joshuaspence."Manufacturing Defect?" token, awarded by chad.

Details

Summary

Support and prefer configuration from .arclint over Configuration Manager

Test Plan

arc lint with several combinations of values in .arcconfig and .arclint.

Diff Detail

Repository
rARC Arcanist
Branch
s-re-lint
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 2833
Build 2837: [Placeholder Plan] Wait for 30 Seconds

Event Timeline

avivey retitled this revision from to Modernize Script-and-Regex linter for ConfigurationDriven.
avivey updated this object.
avivey edited the test plan for this revision. (Show Details)
avivey added a reviewer: epriestley.
joshuaspence edited edge metadata.

This generally looks pretty good to me, some minor inlines.

src/lint/linter/ArcanistScriptAndRegexLinter.php
386

Probably just use if ($this->script) { ... }

390–393

Change this to $config->getDeprecatedConfiguration('linter.scriptandregex.script')

414

As above.

417–420

As above.

This revision now requires changes to proceed.Jan 6 2015, 11:20 AM
src/lint/linter/ArcanistScriptAndRegexLinter.php
386

if (strlen($x)) is the convention used, to assure $x is actually a string (@epriestley said so). Or at least it was.

390–393

ok.

417–420

$key is used in the error message below.

avivey edited edge metadata.
  • use getDeprecatedConfiguration
joshuaspence edited edge metadata.

We should maybe change the configuration keys to 'script-and-regex.script' and 'script-and-regex.regex' for consistency with other linters, but otherwise this looks good.

src/lint/linter/ArcanistScriptAndRegexLinter.php
294

We should eventually make this non-optional I guess.

298

As above.

@epriestley, just bumping this as I figured it has fallen off your radar.

joshuaspence edited edge metadata.

Just noticed a couple of things whilst working on D11773.

src/lint/linter/ArcanistScriptAndRegexLinter.php
11

We should update this.

14

We should update this.

293

Change this to script-and-regex.script.

297

Change this to script-and-regex.reged.

308

As above.

311

As above.

393

See line 413.

395–396

See line 420.

414

I still think that we should just use if ($this->regex) { here...

422–423

...or change this to be if (!strlen($config)) {

433–434

I'm thinking that we should just remove the second part of this message, since it encourages the use of deprecated configuration.

This revision now requires changes to proceed.Feb 15 2015, 8:29 PM

I wrote a long text here describing what I think the logic of strlen is, but it turns out that php.
I'll just remove the strlen for now, unless @epriestley want to chime in.

src/lint/linter/ArcanistScriptAndRegexLinter.php
294

Yeah, that's the plan, but I'd like to avoid breaking this so abruptly; Give it some time as "deprecated".

The use of strlen() to test whether strings are set is generally correct, because strings like "0" and "0.0" fail if ($setting) but pass if (strlen($setting)). These cases rarely matter, but occasionally they do things like prevent you from writing rules that affect files literally named "0", making users with the username "0" behave awkwardly, preventing you from making a wiki page titled "0", etc.

Ok, that makes more sense.
In the case of this diff, it can only make scripts named "0" not work, which is probably not so bad?

avivey edited edge metadata.

update config names, remove strlen

joshuaspence edited edge metadata.

LGTM otherwise.

src/lint/linter/ArcanistScriptAndRegexLinter.php
309

Maybe you should do Filesystem::assertExists to ensure that the script actually exists... or maybe this already happens somewhere else?

393

For consistency, maybe this if ($this->script) {

396

Maybe maybe this translatable with pht()

423

Make this translatable with this pht()

432–434

Prefer to write this as pht("%s: Regex '%s' does not compile.", __CLASS__, $regex)

epriestley edited edge metadata.

I'll fix that pht() stuff in the pull.

src/lint/linter/ArcanistScriptAndRegexLinter.php
309

This might be grep or some shell alias or something so I think it's OK to not check.

This revision is now accepted and ready to land.May 5 2015, 10:49 AM
src/lint/linter/ArcanistScriptAndRegexLinter.php
309

Ah, good point.

This revision was automatically updated to reflect the committed changes.