Skip to content

Commit

Permalink
Handle missing "offense" values (#63)
Browse files Browse the repository at this point in the history
We've encountered a number of cases where the eslint result doesn't
include values for all of these expected keys. Harden the code for these
cases using idx(). The internal Arcanist interface allows these values
to be `null`, which is idx()'s default value.
  • Loading branch information
jparise authored Feb 16, 2021
1 parent 63a85ab commit f0efe0a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ESLintLinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ protected function parseLinterOutput($path, $err, $stdout, $stderr) {

$message = new ArcanistLintMessage();
$message->setPath($file['filePath']);
$message->setSeverity($this->mapSeverity($offense['severity']));
$message->setSeverity($this->mapSeverity(idx($offense, 'severity', '0')));
$message->setName(nonempty(idx($offense, 'ruleId'), 'unknown'));
$message->setDescription($offense['message']);
$message->setLine($offense['line']);
$message->setChar($offense['column']);
$message->setDescription(idx($offense, 'message'));
$message->setLine(idx($offense, 'line'));
$message->setChar(idx($offense, 'column'));
$message->setCode($this->getLinterName());
$messages[] = $message;
}
Expand Down

0 comments on commit f0efe0a

Please sign in to comment.