<commit_before><?php

final class ArcanistScalastyleLinter extends ArcanistExternalLinter {

  private $jarPath = null;
  private $configPath = null;

  public function getInfoURI() {
    return 'http://www.scalastyle.org/';
  }

  public function getInfoDescription() {
    return 'Scalastyle linter for Scala code';
  }

  public function getLinterName() {
    return 'scalastyle';
  }

  public function getLinterConfigurationName() {
    return 'scalastyle';
  }

  public function getDefaultBinary() {
    return 'java';
  }

  public function getInstallInstructions() {
    return 'See http://www.scalastyle.org/command-line.html';
  }

  public function shouldExpectCommandErrors() {
    return true;
  }

  protected function getMandatoryFlags() {
    if ($this->jarPath === null) {
      throw new ArcanistUsageException(
        pht('Scalastyle JAR path must be configured.'));
    }
    if ($this->configPath === null) {
      throw new ArcanistUsageException(
        pht('Scalastyle config XML path must be configured.'));
    }

    return array(
      '-jar', $this->jarPath,
      '--config', $this->configPath,
      '--quiet', 'true');
  }

  protected function getDefaultFlags() {
    return array();
  }

  protected function parseLinterOutput($path, $err, $stdout, $stderr) {

    $messages = array();

    $output = trim($stdout);
    if (strlen($output) === 0) {
      return $messages;
    }

    $lines = explode(PHP_EOL, $output);

    foreach ($lines as $line) {
      $lintMessage = id(new ArcanistLintMessage())
        ->setPath($path)<commit_msg>Update scalastyle linter<commit_after><?php

final class ArcanistScalastyleLinter extends ArcanistExternalLinter {

  private $jarPath = null;
  private $configPath = null;

  public function getInfoURI() {
    return 'http://www.scalastyle.org/';
  }

  public function getInfoDescription() {
    return 'Scalastyle linter for Scala code';
  }

  public function getLinterName() {
    return 'scalastyle';
  }

  public function getLinterConfigurationName() {
    return 'scalastyle';
  }

  public function getDefaultBinary() {
    if (Filesystem::binaryExists('scalastyle')) {
      return 'scalastyle';
    } else {
      return 'java';
    }
  }

  public function shouldUseInterpreter() {
    return ($this->getDefaultBinary() !== 'scalastyle');
  }

  public function getDefaultInterpreter() {
    return 'java';
  }

  public function getInstallInstructions() {
    return 'See http://www.scalastyle.org/command-line.html or run "brew install scalastyle" on OS X';
  }

  public function shouldExpectCommandErrors() {
    return true;
  }

  protected function getMandatoryFlags() {
    if ($this->configPath === null) {
      throw new ArcanistUsageException(
        pht('Scalastyle config XML path must be configured.'));
    }

    return array(
      '--config', $this->configPath,
      '--quiet', 'true');
  }

  protected function getDefaultFlags() {
    return array();
  }

  protected function parseLinterOutput($path, $err, $stdout, $stderr) {

    $messages = array();

    $output = trim($stdout);
    if (strlen($output) === 0) {
      return $messages;
    }

    $lines = explode(PHP_EOL, $output);

    foreach ($lines as $line) {
      $lintMessage = id(new ArcanistLintMessage())
        ->setPath($path)
{'fraction_non_alphanumeric': 0.12722877002115443, 'fraction_numerical': 0.0006044122091266244, 'mean_word_length': 3.2219387755102042, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1075067', 'n_tokens_mistral': 1022, 'n_tokens_neox': 989, 'n_words': 249}