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)
Wed, Apr 24, 10:28 PM
Unknown Object (File)
Thu, Apr 11, 8:54 AM
Unknown Object (File)
Thu, Apr 11, 5:06 AM
Unknown Object (File)
Mon, Apr 1, 5:51 PM
Unknown Object (File)
Sat, Mar 30, 3:13 AM
Unknown Object (File)
Fri, Mar 29, 3:27 PM
Unknown Object (File)
Wed, Mar 27, 9:40 PM
Unknown Object (File)
Mar 20 2024, 3:57 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