Add google-style checker to "arc lint"

Summary:
After we reached a consensus on code format, which follows exactly
Google's coding style, a natural follow-up is to have a style checker
that can handle stuffs beyond format.

Google already has a powerful style checker "cpplint.py" and,
luckily, phabricator already provides the built-in linter for it!
Next time with "arc lint" most style inconsistency will be detected
(but will not be fixed).

Also I copied cpplint.py to linters directory, which is mostly
because we may need the flexibility to make some modifications on
it for our own need.

Test Plan:
ran arc lint table/block_based_table_builder.cc to see the amazing
results.

Reviewers: haobo, sdong, igor, dhruba

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D15369
main
kailiu 11 years ago
parent fb01755aa4
commit d0458469c8
  1. 9
      .arcconfig
  2. 1
      .gitignore
  3. 0
      linters/__phutil_library_init__.php
  4. 0
      linters/__phutil_library_map__.php
  5. 0
      linters/cpp_linter/FbcodeCppLinter.php
  6. 0
      linters/cpp_linter/PfffCppLinter.php
  7. 4759
      linters/cpplint.py
  8. 28
      linters/lint_engine/FacebookFbcodeLintEngine.php
  9. 1
      linters/src/.phutil_module_cache

@ -1,10 +1,11 @@
{
"project_id" : "leveldb",
"project_id" : "rocksdb",
"conduit_uri" : "https://reviews.facebook.net/",
"copyright_holder" : "",
"copyright_holder" : "Facebook",
"load" : [
"linters/src/"
"linters"
],
"lint.engine" : "FacebookFbcodeLintEngine",
"lint.engine.single.linter" : "FbcodeCppLinter"
"lint.engine.single.linter" : "FbcodeCppLinter",
"lint.cpplint.prefix" : "linters"
}

1
.gitignore vendored

@ -20,3 +20,4 @@ util/build_version.cc
build_tools/VALGRIND_LOGS/
coverage/COVERAGE_REPORT
.gdbhistory
.phutil_module_cache

4759
linters/cpplint.py vendored

File diff suppressed because it is too large Load Diff

@ -49,10 +49,15 @@ class FacebookFbcodeLintEngine extends ArcanistLintEngine {
// Currently we can't run cpplint in commit hook mode, because it
// depends on having access to the working directory.
if (!$this->getCommitHookMode()) {
$cpp_linter = new FbcodeCppLinter();
$cpp_linter2 = new PfffCppLinter();
$linters[] = $cpp_linter;
$linters[] = $cpp_linter2;
$cpp_linters = array();
$google_linter = new ArcanistCpplintLinter();
$google_linter->setConfig(array(
'lint.cpplint.prefix' => '',
'lint.cpplint.bin' => 'cpplint',
));
$cpp_linters[] = $linters[] = $google_linter;
$cpp_linters[] = $linters[] = new FbcodeCppLinter();
$cpp_linters[] = $linters[] = new PfffCppLinter();
}
$spelling_linter = new ArcanistSpellingLinter();
@ -93,13 +98,11 @@ class FacebookFbcodeLintEngine extends ArcanistLintEngine {
$spelling_linter->addPath($path);
$spelling_linter->addData($path, $this->loadData($path));
}
if (isset($cpp_linter) && isset($cpp_linter2) &&
preg_match('/\.(cpp|c|cc|cxx|h|hh|hpp|hxx|tcc)$/', $path)) {
$cpp_linter->addPath($path);
$cpp_linter->addData($path, $this->loadData($path));
$cpp_linter2->addPath($path);
$cpp_linter2->addData($path, $this->loadData($path));
if (preg_match('/\.(cpp|c|cc|cxx|h|hh|hpp|hxx|tcc)$/', $path)) {
foreach ($cpp_linters as &$linter) {
$linter->addPath($path);
$linter->addData($path, $this->loadData($path));
}
}
// Match *.py and contbuild config files
@ -130,9 +133,6 @@ class FacebookFbcodeLintEngine extends ArcanistLintEngine {
));
}
}
}
$name_linter = new ArcanistFilenameLinter();

@ -1 +0,0 @@
{"__symbol_cache_version__":8,"b937ad5f80a8bd1156038b730ff56ec5":{"have":{"class":{"FacebookFbcodeLintEngine":71}},"need":{"class":{"ArcanistLintEngine":104,"ArcanistGeneratedLinter":488,"ArcanistNoLintLinter":577,"ArcanistTextLinter":658,"ArcanistPEP8Linter":1227,"FbcodeCppLinter":1715,"PfffCppLinter":1759,"ArcanistSpellingLinter":1875,"ArcanistFilenameLinter":4207,"Filesystem":357,"ArcanistLintSeverity":778}},"xmap":{"FacebookFbcodeLintEngine":["ArcanistLintEngine"]}},"02e2a613e371424b2108d2d6cb849d39":{"have":{"class":{"PfffCppLinter":71}},"need":{"function":{"Futures":875},"class":{"ArcanistLinter":93,"ExecFuture":756,"ArcanistLintMessage":1270,"ArcanistLintSeverity":1607}},"xmap":{"PfffCppLinter":["ArcanistLinter"]}},"4443484928afb005f585843d07b04190":{"have":{"class":{"FbcodeCppLinter":13}},"need":{"function":{"Futures":1265},"class":{"ArcanistLinter":37,"ExecFuture":934,"ArcanistLintSeverity":1729}},"xmap":{"FbcodeCppLinter":["ArcanistLinter"]}}}
Loading…
Cancel
Save