Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Reimplement LineLinter::isLinterSuppressed with the help of File::lin…
Browse files Browse the repository at this point in the history
…tMarkers
  • Loading branch information
Atry authored Nov 9, 2021
1 parent fda0898 commit 0d09d00
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Linters/LineLinter.hack
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class LineLinter<+Terror as LineLintError> extends SingleRuleLinter {
}

// We got an error. Let's check the previous line to see if it is marked as ignorable
if ($ln - 1 >= 0 && $this->isLinterSuppressed($lines[$ln - 1])) {
if ($ln - 1 >= 0 && $this->isLinterSuppressed($ln)) {
continue;
}

Expand All @@ -49,9 +49,13 @@ abstract class LineLinter<+Terror as LineLintError> extends SingleRuleLinter {

/** Check if this linter has been disabled by a comment on the previous line.
*/
protected function isLinterSuppressed(string $previous_line): bool {
return Str\contains($previous_line, $this->getFixmeMarker()) ||
Str\contains($previous_line, $this->getIgnoreSingleErrorMarker());
private function isLinterSuppressed(int $base1_line_number): bool {
$line_marker = $this->getFile()->lintMarkers();
return (
$line_marker[$this->getFixmeMarker()][$base1_line_number] ??
$line_marker[$this->getIgnoreSingleErrorMarker()][$base1_line_number] ??
null
) is nonnull;
}

/** Parse a single line of code and attempts to find lint errors */
Expand Down

0 comments on commit 0d09d00

Please sign in to comment.