$py_paths = preg_grep('/\.py$/', $paths);
$linters[] = id(new ArcanistPyFlakesLinter())->setPaths($py_paths);
$linters[] = id(new ArcanistPEP8Linter())
- ->setConfig(array('options' => $this->getPEP8WithTextOptions()))
+ ->setConfig(array('flags' => array($this->getPEP8WithTextOptions())))
->setPaths($py_paths);
$linters[] = id(new ArcanistRubyLinter())
}
public function getDefaultFlags() {
- // TODO: Deprecation warning.
- $config = $this->getEngine()->getConfigurationManager();
- return $config->getConfigFromAnySource('lint.csslint.options', array());
+ return $this->getDeprecatedConfiguration('lint.csslint.options', array());
}
public function getDefaultBinary() {
- // TODO: Deprecation warning.
- $config = $this->getEngine()->getConfigurationManager();
- return $config->getConfigFromAnySource('lint.csslint.bin', 'csslint');
+ return $this->getDeprecatedConfiguration('lint.csslint.bin', 'csslint');
}
public function getVersion() {
}
public function getDefaultBinary() {
- // TODO: Warn that all of this is deprecated.
- $config = $this->getEngine()->getConfigurationManager();
- $prefix = $config->getConfigFromAnySource('lint.cpplint.prefix');
- $bin = $config->getConfigFromAnySource('lint.cpplint.bin', 'cpplint.py');
+ $prefix = $this->getDeprecatedConfiguration('lint.cpplint.prefix');
+ $bin = $this->getDeprecatedConfiguration('lint.cpplint.bin', 'cpplint.py');
if ($prefix) {
return $prefix.'/'.$bin;
}
protected function getDefaultFlags() {
- $config = $this->getEngine()->getConfigurationManager();
- return $config->getConfigFromAnySource('lint.cpplint.options', array());
+ return $this->getDeprecatedConfiguration('lint.cpplint.options', array());
}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
* @task bin
*/
final public function setFlags($flags) {
- $this->flags = (array) $flags;
+ $this->flags = (array)$flags;
return $this;
}
}
public function getDefaultFlags() {
- // TODO: Deprecated.
- $config = $this->getEngine()->getConfigurationManager();
- return $config->getConfigFromAnySource('lint.flake8.options', array());
+ return $this->getDeprecatedConfiguration('lint.flake8.options', array());
}
public function getDefaultBinary() {
- $config = $this->getEngine()->getConfigurationManager();
- $prefix = $config->getConfigFromAnySource('lint.flake8.prefix');
- $bin = $config->getConfigFromAnySource('lint.flake8.bin', 'flake8');
+ $prefix = $this->getDeprecatedConfiguration('lint.flake8.prefix');
+ $bin = $this->getDeprecatedConfiguration('lint.flake8.bin', 'flake8');
- if ($prefix || ($bin != 'flake8')) {
+ if ($prefix) {
return $prefix.'/'.$bin;
+ } else {
+ return $bin;
}
-
- return 'flake8';
}
public function getVersion() {
}
public function getDefaultBinary() {
- $config = $this->getEngine()->getConfigurationManager();
- $prefix = $config->getConfigFromAnySource('lint.jshint.prefix');
- $bin = $config->getConfigFromAnySource('lint.jshint.bin', 'jshint');
+ $prefix = $this->getDeprecatedConfiguration('lint.jshint.prefix');
+ $bin = $this->getDeprecatedConfiguration('lint.jshint.bin', 'jshint');
if ($prefix) {
return $prefix.'/'.$bin;
}
protected function getDefaultFlags() {
- $config_manager = $this->getEngine()->getConfigurationManager();
- $options = $config_manager->getConfigFromAnySource(
+ $options = $this->getDeprecatedConfiguration(
'lint.jshint.options',
array());
- $config = $config_manager->getConfigFromAnySource('lint.jshint.config');
+ $config = $this->getDeprecatedConfiguration('lint.jshint.config');
if ($config) {
$options[] = '--config='.$config;
}
return $code;
}
+
+ /**
+ * Retrieve an old lint configuration value from `.arcconfig` or a similar
+ * source.
+ *
+ * Modern linters should use @{method:getConfig} to read configuration from
+ * `.arclint`.
+ *
+ * @param string Configuration key to retrieve.
+ * @param wild Default value to return if key is not present in config.
+ * @return wild Configured value, or default if no configuration exists.
+ */
+ protected function getDeprecatedConfiguration($key, $default = null) {
+
+ // If we're being called in a context without an engine (probably from
+ // `arc linters`), just return the default value.
+ if (!$this->engine) {
+ return $default;
+ }
+
+ $config = $this->getEngine()->getConfigurationManager();
+
+ // Construct a sentinel object so we can tell if we're reading config
+ // or not.
+ $sentinel = (object)array();
+ $result = $config->getConfigFromAnySource($key, $sentinel);
+
+ // If we read config, warn the user that this mechanism is deprecated and
+ // discouraged.
+ if ($result !== $sentinel) {
+ $console = PhutilConsole::getConsole();
+ $console->writeErr(
+ "**%s**: %s\n",
+ pht('Deprecation Warning'),
+ pht(
+ 'Configuration option "%s" is deprecated. Generally, linters should '.
+ 'now be configured using an `.arclint` file. See "Arcanist User '.
+ 'Guide: Lint" in the documentation for more information.',
+ $key));
+ return $result;
+ }
+
+ return $default;
+ }
+
}
}
public function getDefaultFlags() {
- // TODO: Warn that all of this is deprecated.
- $config = $this->getEngine()->getConfigurationManager();
- return $config->getConfigFromAnySource(
- 'lint.pep8.options',
- $this->getConfig('options', array()));
+ return $this->getDeprecatedConfiguration('lint.pep8.options', array());
}
public function shouldUseInterpreter() {
return 'pep8';
}
- $config = $this->getEngine()->getConfigurationManager();
- $old_prefix = $config->getConfigFromAnySource('lint.pep8.prefix');
- $old_bin = $config->getConfigFromAnySource('lint.pep8.bin');
-
+ $old_prefix = $this->getDeprecatedConfiguration('lint.pep8.prefix');
+ $old_bin = $this->getDeprecatedConfiguration('lint.pep8.bin');
if ($old_prefix || $old_bin) {
- // TODO: Deprecation warning.
$old_bin = nonempty($old_bin, 'pep8');
return $old_prefix.'/'.$old_bin;
}
}
public function getDefaultFlags() {
- // TODO: Deprecation warnings.
-
- $config = $this->getEngine()->getConfigurationManager();
-
- $options = $config->getConfigFromAnySource('lint.phpcs.options', array());
-
- $standard = $config->getConfigFromAnySource('lint.phpcs.standard');
+ $options = $this->getDeprecatedConfiguration('lint.phpcs.options', array());
+ $standard = $this->getDeprecatedConfiguration('lint.phpcs.standard');
if (!empty($standard)) {
if (is_array($options)) {
$options[] = '--standard='.$standard;
}
public function getDefaultBinary() {
- // TODO: Deprecation warnings.
- $config = $this->getEngine()->getConfigurationManager();
- return $config->getConfigFromAnySource('lint.phpcs.bin', 'phpcs');
+ return $this->getDeprecatedConfiguration('lint.phpcs.bin', 'phpcs');
}
public function getVersion() {
}
public function getDefaultBinary() {
- $config = $this->getEngine()->getConfigurationManager();
- $prefix = $config->getConfigFromAnySource('lint.pyflakes.prefix');
- $bin = $config->getConfigFromAnySource('lint.pyflakes.bin', 'pyflakes');
+ $prefix = $this->getDeprecatedConfiguration('lint.pyflakes.prefix');
+ $bin = $this->getDeprecatedConfiguration('lint.pyflakes.bin', 'pyflakes');
if ($prefix) {
return $prefix.'/'.$bin;
}
public function getDefaultBinary() {
- // TODO: Deprecation warning.
- $config = $this->getEngine()->getConfigurationManager();
- $prefix = $config->getConfigFromAnySource('lint.ruby.prefix');
+ $prefix = $this->getDeprecatedConfiguration('lint.ruby.prefix');
if ($prefix !== null) {
$ruby_bin = $prefix.'ruby';
}
/**
* Uses `sbt compile` to detect various warnings/errors in Scala code.
- *
- * @group linter
*/
final class ArcanistScalaSBTLinter extends ArcanistLinter {
private function getSBTPath() {
$sbt_bin = "sbt";
- // Use the SBT prefix specified in the config file
- $config = $this->getEngine()->getConfigurationManager();
- $prefix = $config->getConfigFromAnySource('lint.scala_sbt.prefix');
+ $prefix = $this->getDeprecatedConfiguration('lint.scala_sbt.prefix');
if ($prefix !== null) {
$sbt_bin = $prefix . $sbt_bin;
}
- if (!Filesystem::pathExists($sbt_bin)) {
-
- list($err) = exec_manual('which %s', $sbt_bin);
- if ($err) {
- throw new ArcanistUsageException(
- "SBT does not appear to be installed on this system. Install it or ".
- "add 'lint.scala_sbt.prefix' in your .arcconfig to point to ".
- "the directory where it resides.");
- }
- }
-
return $sbt_bin;
}