private $minimumSeverity = ArcanistLintSeverity::SEVERITY_DISABLED;
private $changedLines = array();
+ private $textChanges = array();
private $commitHookMode = false;
public function __construct() {
return idx($this->changedLines, $path);
}
+ public function setTextChange($path) {
+ $this->textChanges[$path] = true;
+ return $this;
+ }
+
+ public function isTextChange($path) {
+ return idx($this->textChanges, $path, false);
+ }
+
public function setFileData($data) {
$this->fileData = $data + $this->fileData;
return $this;
if (!ArcanistLintSeverity::isAtLeastAsSevere($message, $minimum)) {
continue;
}
- // When a user runs "arc diff", we default to raising only warnings on
+ // When a user runs "arc lint", we default to raising only warnings on
// lines they have changed (errors are still raised anywhere in the
// file).
+ $text_change = $this->isTextChange($message->getPath());
$changed = $this->getPathChangedLines($message->getPath());
- if ($changed !== null && !$message->isError()) {
+ if ($text_change === true &&
+ $changed !== null &&
+ !$message->isError()) {
if (empty($changed[$message->getLine()])) {
continue;
}
return $bundle;
}
+ protected function isTextChange($path) {
+ $change = $this->getChange($path);
+ return $change->getFileType() == ArcanistDiffChangeType::FILE_TEXT;
+ }
+
protected function getChangedLines($path, $mode) {
if (is_dir($path)) {
return array();
phutil_require_module('arcanist', 'parser/bundle');
phutil_require_module('arcanist', 'parser/diff');
phutil_require_module('arcanist', 'parser/diff/change');
+phutil_require_module('arcanist', 'parser/diff/changetype');
phutil_require_module('phutil', 'conduit/client');
phutil_require_module('phutil', 'console');
$engine->setMinimumSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
}
+ // Propagate information about which lines changed to the lint engine.
+ // This is used so that the lint engine can drop messages concerning
+ // lines that weren't in the change.
$engine->setPaths($paths);
if (!$should_lint_all) {
foreach ($paths as $path) {
- $engine->setPathChangedLines(
- $path,
- $this->getChangedLines($path, 'new'));
+ // Explicitly flag text changes, as line information doesn't apply
+ // to non-text files.
+ if ($this->isTextChange($path)) {
+ $engine->setTextChange($path);
+ $engine->setPathChangedLines(
+ $path,
+ $this->getChangedLines($path, 'new'));
+ }
}
}