mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-28 05:43:50 +00:00
d0458469c8
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
69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
// Copyright 2004-present Facebook. All rights reserved.
|
|
|
|
class PfffCppLinter extends ArcanistLinter {
|
|
const PROGRAM = "/home/engshare/tools/checkCpp";
|
|
|
|
public function getLinterName() {
|
|
return "checkCpp";
|
|
}
|
|
public function getLintNameMap() {
|
|
return array(
|
|
);
|
|
}
|
|
|
|
public function getLintSeverityMap() {
|
|
return array(
|
|
);
|
|
}
|
|
|
|
public function willLintPaths(array $paths) {
|
|
$program = false;
|
|
$ret_value = 0;
|
|
$last_line = system("which checkCpp", $ret_value);
|
|
if ($ret_value == 0) {
|
|
$program = $last_line;
|
|
} else if (file_exists(self::PROGRAM)) {
|
|
$program = self::PROGRAM;
|
|
}
|
|
if ($program) {
|
|
$futures = array();
|
|
foreach ($paths as $p) {
|
|
$futures[$p] = new ExecFuture("%s --lint %s 2>&1",
|
|
$program, $this->getEngine()->getFilePathOnDisk($p));
|
|
}
|
|
foreach (Futures($futures)->limit(8) as $p => $f) {
|
|
|
|
list($stdout, $stderr) = $f->resolvex();
|
|
$raw = json_decode($stdout, true);
|
|
if (!is_array($raw)) {
|
|
throw new Exception(
|
|
"checkCpp returned invalid JSON!".
|
|
"Stdout: {$stdout} Stderr: {$stderr}"
|
|
);
|
|
}
|
|
foreach($raw as $err) {
|
|
$this->addLintMessage(
|
|
ArcanistLintMessage::newFromDictionary(
|
|
array(
|
|
'path' => $err['file'],
|
|
'line' => $err['line'],
|
|
'char' => 0,
|
|
'name' => $err['name'],
|
|
'description' => $err['info'],
|
|
'code' => $this->getLinterName(),
|
|
'severity' => ArcanistLintSeverity::SEVERITY_WARNING,
|
|
)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
public function lintPath($path) {
|
|
return;
|
|
}
|
|
}
|