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

Commit 14a11d4

Browse files
committed
Move LineLinter::isLinterSuppressed to SuppressibleTrait::isSuppressedForLine
1 parent df9a825 commit 14a11d4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Linters/LineLinter.hack

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class LineLinter<+Terror as LineLintError> extends SingleRuleLinter {
3737
}
3838

3939
// We got an error. Let's check the previous line to see if it is marked as ignorable
40-
if ($ln - 1 >= 0 && $this->isLinterSuppressed($ln)) {
40+
if ($ln - 1 >= 0 && $this->isSuppressedForLine($this->getFile(), $ln)) {
4141
continue;
4242
}
4343

@@ -47,17 +47,6 @@ abstract class LineLinter<+Terror as LineLintError> extends SingleRuleLinter {
4747
return $errs;
4848
}
4949

50-
/** Check if this linter has been disabled by a comment on the previous line.
51-
*/
52-
private function isLinterSuppressed(int $base1_line_number): bool {
53-
$line_marker = $this->getFile()->lintMarkersForLineBasedSuppression();
54-
return (
55-
$line_marker[$this->getFixmeMarker()][$base1_line_number] ??
56-
$line_marker[$this->getIgnoreSingleErrorMarker()][$base1_line_number] ??
57-
null
58-
) is nonnull;
59-
}
60-
6150
/** Parse a single line of code and attempts to find lint errors */
6251
abstract public function getLintErrorsForLine(
6352
string $line,

src/Linters/SuppressibleTrait.hack

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,15 @@ trait SuppressibleTrait {
6060
);
6161
}
6262

63+
/** Check if this linter has been disabled by a comment on the previous line.
64+
*/
65+
public final function isSuppressedForLine(File $file, int $previous_line_number): bool {
66+
$line_marker = $file->lintMarkersForLineBasedSuppression();
67+
return (
68+
$line_marker[$this->getFixmeMarker()][$previous_line_number] ??
69+
$line_marker[$this->getIgnoreSingleErrorMarker()][$previous_line_number] ??
70+
null
71+
) is nonnull;
72+
}
73+
6374
}

0 commit comments

Comments
 (0)