This repository was archived by the owner on Dec 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +41
-9
lines changed Expand file tree Collapse file tree 3 files changed +41
-9
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ final class HHClientLintError implements LintError {
63
63
}
64
64
65
65
<<__Memoize >>
66
- public function getLintRule (): LintRule {
66
+ public function getLintRule (): HHClientLintRule {
67
67
return new HHClientLintRule ($this -> error [' code' ]);
68
68
}
69
69
Original file line number Diff line number Diff line change @@ -59,13 +59,35 @@ final class HHClientLinter implements Linter {
59
59
),
60
60
);
61
61
$file_lines = Str \split ($this -> getFile()-> getContents(), " \n " );
62
- return Vec \map (
63
- $hh_client_lint_result [' errors' ],
64
- $error ==> new HHClientLintError (
65
- $this -> file ,
66
- $error ,
67
- $this :: blameCode($file_lines , $error ),
68
- ),
69
- );
62
+ return $hh_client_lint_result [' errors' ]
63
+ |> Vec \map (
64
+ $$,
65
+ $error ==> new HHClientLintError (
66
+ $this -> file ,
67
+ $error ,
68
+ $this :: blameCode($file_lines , $error ),
69
+ ),
70
+ )
71
+ |> Vec \filter ($$, $error ==> {
72
+ if ($error -> getLintRule()-> isSuppressedForFile($this -> file )) {
73
+ return false ;
74
+ }
75
+ $range = $error -> getRange();
76
+ if ($range is null ) {
77
+ return true ;
78
+ }
79
+ list (list ($line_number , $_ ), $_ ) = $range ;
80
+ $previous_line_number = $line_number - 1 ;
81
+ if ($this -> isSuppressedForLine($this -> file , $previous_line_number )) {
82
+ return false ;
83
+ }
84
+ if (
85
+ $error -> getLintRule()
86
+ -> isSuppressedForLine($this -> file , $previous_line_number )
87
+ ) {
88
+ return false ;
89
+ }
90
+ return true ;
91
+ });
70
92
}
71
93
}
Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ final class HHClientLinterTest extends TestCase {
24
24
public function getCleanExamples (): vec <(string )> {
25
25
return vec [
26
26
tuple (" <?hh\n class Foo {}" ),
27
+ tuple (
28
+ ' <?hh
29
+ function invalid_null_check(): void {
30
+ $cannot_be_null = 42;
31
+ // HHAST_FIXME[5611]
32
+ if ($cannot_be_null is null) {
33
+ throw new Exception();
34
+ }
35
+ }' ,
36
+ ),
27
37
];
28
38
}
29
39
You can’t perform that action at this time.
0 commit comments