From: Joshua Spence Date: Fri, 23 May 2014 14:59:57 +0000 (-0700) Subject: Add an `ArcanistGoLintLinter`. X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=042aa2ee38df81bdae7002f35b5b723a88b66f8b;p=arcanist.git Add an `ArcanistGoLintLinter`. Summary: Create bindings for `golint` as an external linter. Test Plan: Wrote and executed unit tests. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9246 --- diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4bcdf253..8ad2b8a4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -80,6 +80,8 @@ phutil_register_library_map(array( 'ArcanistGetConfigWorkflow' => 'workflow/ArcanistGetConfigWorkflow.php', 'ArcanistGitAPI' => 'repository/api/ArcanistGitAPI.php', 'ArcanistGitHookPreReceiveWorkflow' => 'workflow/ArcanistGitHookPreReceiveWorkflow.php', + 'ArcanistGoLintLinter' => 'lint/linter/ArcanistGoLintLinter.php', + 'ArcanistGoLintLinterTestCase' => 'lint/linter/__tests__/ArcanistGoLintLinterTestCase.php', 'ArcanistHelpWorkflow' => 'workflow/ArcanistHelpWorkflow.php', 'ArcanistHgClientChannel' => 'hgdaemon/ArcanistHgClientChannel.php', 'ArcanistHgProxyClient' => 'hgdaemon/ArcanistHgProxyClient.php', @@ -258,6 +260,8 @@ phutil_register_library_map(array( 'ArcanistGetConfigWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistGitAPI' => 'ArcanistRepositoryAPI', 'ArcanistGitHookPreReceiveWorkflow' => 'ArcanistBaseWorkflow', + 'ArcanistGoLintLinter' => 'ArcanistExternalLinter', + 'ArcanistGoLintLinterTestCase' => 'ArcanistArcanistLinterTestCase', 'ArcanistHelpWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistHgClientChannel' => 'PhutilProtocolChannel', 'ArcanistHgServerChannel' => 'PhutilProtocolChannel', diff --git a/src/lint/linter/ArcanistGoLintLinter.php b/src/lint/linter/ArcanistGoLintLinter.php new file mode 100644 index 00000000..806bda6d --- /dev/null +++ b/src/lint/linter/ArcanistGoLintLinter.php @@ -0,0 +1,60 @@ +setPath($path); + $message->setLine($matches[1]); + $message->setChar($matches[2]); + $message->setCode($this->getLinterName()); + $message->setDescription(ucfirst(trim($matches[3]))); + $message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE); + + $messages[] = $message; + } + } + + return $messages; + } + +} diff --git a/src/lint/linter/__tests__/ArcanistGoLintLinterTestCase.php b/src/lint/linter/__tests__/ArcanistGoLintLinterTestCase.php new file mode 100644 index 00000000..fb9c62eb --- /dev/null +++ b/src/lint/linter/__tests__/ArcanistGoLintLinterTestCase.php @@ -0,0 +1,12 @@ +executeTestsInDirectory( + dirname(__FILE__).'/golint/', + new ArcanistGoLintLinter()); + } + +} diff --git a/src/lint/linter/__tests__/golint/1.lint-test b/src/lint/linter/__tests__/golint/1.lint-test new file mode 100644 index 00000000..231946c3 --- /dev/null +++ b/src/lint/linter/__tests__/golint/1.lint-test @@ -0,0 +1,18 @@ +package main + +import ( + "rand" +) + +type Exported string + +func main() { + if rand.Intn(10) > 5 { + return true + } else { + return false + } +} +~~~~~~~~~~ +advice:7:6 +advice:12:12