2 // Copyright 2004-present Facebook. All Rights Reserved.
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree. An additional grant
5 // of patent rights can be found in the PATENTS file in the same directory.
7 final class FbcodeClangFormatLinter
extends BaseDirectoryScopedFormatLinter
{
9 const LINT_FORMATTING
= 1;
10 const CLANG_FORMAT_BINARY
= '/mnt/vol/engshare/admin/scripts/clang-format';
12 protected function getPathsToLint() {
16 public function getLinterName() {
17 return 'CLANG_FORMAT';
20 public function getLintSeverityMap() {
22 self
::LINT_FORMATTING
=> ArcanistLintSeverity
::SEVERITY_ADVICE
,
26 public function getLintNameMap() {
28 self
::LINT_FORMATTING
=> pht('Changes are not clang-formatted'),
32 protected function getFormatFuture($path, array $changed) {
34 foreach ($changed as $key => $value) {
35 $args .= " --lines=$key:$key";
38 $binary = self
::CLANG_FORMAT_BINARY
;
39 if (!file_exists($binary)) {
41 $binary = "clang-format";
44 return new ExecFuture(
47 $this->getEngine()->getFilePathOnDisk($path));
50 protected function getLintMessage($diff) {
51 $link_to_clang_format =
52 "[[ http://fburl.com/clang-format | clang-format ]]";
54 Changes in this file were not formatted using $link_to_clang_format.
55 Please run build_tools/format-diff.sh or `make format`