Page MenuHomePhabricator

Made some additional methods of `ArcanistLinter` and `ArcanistExternalLinter` final
ClosedPublic

Authored by joshuaspence on Jan 14 2014, 4:10 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 17, 6:19 AM
Unknown Object (File)
Thu, Dec 12, 5:39 AM
Unknown Object (File)
Wed, Dec 4, 9:36 AM
Unknown Object (File)
Tue, Dec 3, 5:21 PM
Unknown Object (File)
Fri, Nov 29, 6:10 AM
Unknown Object (File)
Thu, Nov 28, 5:05 PM
Unknown Object (File)
Thu, Nov 28, 5:05 PM
Unknown Object (File)
Thu, Nov 28, 5:05 PM

Details

Summary

To me, it seems that these methods should never be overwritten in subclasses.

Test Plan

arc unit

Diff Detail

Repository
rARC Arcanist
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

joshuaspence updated this revision to Unknown Object (????).Jan 14 2014, 12:33 PM
  • Made some additional methods of ArcanistBaseXHPASTLinter final
  • Made some additional methods of ArcanistFutureLinter final

Just rebasing this and making a few additional changes.

epriestley edited edge metadata.

Pretty sure these are all safe.

src/lint/linter/ArcanistFutureLinter.php
10–31

This might be a little over-restrictive, but we can un-final later if we hit issues.

src/lint/linter/ArcanistLinter.php
90–91

These are gone now, I think, but I can sort that out in the pull...

This revision is now accepted and ready to land.May 12 2014, 4:48 PM
epriestley updated this revision to Diff 21560.

Closed by commit rARC9b05a025b7a6 (authored by @joshuaspence, committed by @epriestley).

I think this change broke lint for fbobjc:

PHP Fatal error: Cannot override final method ArcanistFutureLinter::willLintPaths() in /Users/judyliu/Projects/fbobjc/Configurations/Arcanist/lint/linter/FacebookObjcClangFormatLinter.php on line 8

What is ObjcClangFormatLinter overriding willLintPaths() in order to do?

This comment was removed by judy.liu1.

I haven't worked at Facebook since 2011, so I can't access phabricator.fb.com. :)

oh sorry...didn't realize this wasn't internal. n00b X 1000

We basically do

 // Path regexes to run clang-format on
$whitelist = array(
  // '#^BLAH/.*#',
);

foreach ($paths as $path) {
  foreach ($whitelist as $regex) {
    if (preg_match($regex, $path)) {
      $do_lint[] = $path;
    }
  }
}

parent::willLintPaths($do_lint);

There was some reason why we didn't do it in the engine or use other methods...

I don't mind un-final-ing it if that's easiest since this is purely a quality-of-life change, but that does look like stuff that should ideally live somewhere else. Shoot me a diff to remove the problematic final if you want to go that route?

I'm actually revamping our linters and don't think this will be an issue in the future, so let's keep it this way for now. I'll put up a diff if it later becomes an issue.

It would be nice to have a generic way the linters can override what they run on after the engine has decided to run...otherwise you are shoving a lot of logic into the engine.

Hmm, you could do something like this when building a future:

if ($this->shouldLintPath($path)) {
  return new RealFuture(...);
} else {
  return new ImmediateFuture(null);
}

Then in resolveFutures() just return; if the result is null. Basically, lint the path but don't actually do any linting.

The new .arclint files make it easier to flexibly configure linters, although I'm not sure if they're flexible enough for FB. Here's the docs:

https://secure.phabricator.com/book/phabricator/article/arcanist_lint/#configuring-lint