protected $appliedToDisk;
protected $dependentMessages = array();
protected $obsolete;
+ protected $uncacheable;
public static function newFromDictionary(array $dict) {
$message = new ArcanistLintMessage();
return $this->appliedToDisk;
}
+ public function setUncacheable($bool) {
+ $this->uncacheable = $bool;
+ return $this;
+ }
+
+ public function isUncacheable() {
+ return $this->uncacheable;
+ }
+
public function setDependentMessages(array $messages) {
assert_instances_of($messages, 'ArcanistLintMessage');
$this->dependentMessages = $messages;
}
$paths = $linter->getPaths();
+ $cache_granularity = $linter->getCacheGranularity();
+
foreach ($paths as $key => $path) {
// Make sure each path has a result generated, even if it is empty
// (i.e., the file has no lint messages).
if (isset($stopped[$path])) {
unset($paths[$key]);
}
- // TODO: Some linters work with the whole directory.
if (isset($this->cachedResults[$path][$this->cacheVersion])) {
- unset($paths[$key]);
+ if ($cache_granularity == ArcanistLinter::GRANULARITY_FILE) {
+ unset($paths[$key]);
+ }
}
}
$paths = array_values($paths);
if (!$this->isRelevantMessage($message)) {
continue;
}
+ if ($cache_granularity != ArcanistLinter::GRANULARITY_FILE) {
+ $message->setUncacheable(true);
+ }
$result = $this->getResultForPath($message->getPath());
$result->addMessage($message);
}
*/
abstract class ArcanistLinter {
+ const GRANULARITY_FILE = 1;
+ const GRANULARITY_DIRECTORY = 2;
+ const GRANULARITY_REPOSITORY = 3;
+ const GRANULARITY_GLOBAL = 4;
+
protected $paths = array();
protected $data = array();
protected $engine;
return array();
}
+ public function getCacheGranularity() {
+ return self::GRANULARITY_FILE;
+ }
+
}
public function lintPath($path) {
return;
}
+
+ public function getCacheGranularity() {
+ return self::GRANULARITY_GLOBAL;
+ }
+
}
if ($this->getArgument('cache')) {
$cache = $this->readScratchJSONFile('lint-cache.json');
$cache = idx($cache, $this->getCacheKey(), array());
+ $cache = array_intersect_key($cache, array_flip($paths));
$cached = array();
foreach ($cache as $path => $messages) {
- $messages = idx($messages, md5_file($engine->getFilePathOnDisk($path)));
+ $abs_path = $engine->getFilePathOnDisk($path);
+ if (!Filesystem::pathExists($abs_path)) {
+ continue;
+ }
+ $messages = idx($messages, md5_file($abs_path));
if ($messages !== null) {
$cached[$path] = $messages;
}
unset($cached[$path]);
continue;
}
- $hash = md5_file($engine->getFilePathOnDisk($path));
+ $abs_path = $engine->getFilePathOnDisk($path);
+ if (!Filesystem::pathExists($abs_path)) {
+ continue;
+ }
+ $hash = md5_file($abs_path);
$version = $result->getCacheVersion();
$cached[$path] = array($hash => array($version => array()));
foreach ($result->getMessages() as $message) {
+ if ($message->isUncacheable()) {
+ continue;
+ }
if (!$message->isPatchApplied()) {
$cached[$path][$hash][$version][] = $message->toDictionary();
}