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 {
6363 }
6464
6565 <<__Memoize >>
66- public function getLintRule (): LintRule {
66+ public function getLintRule (): HHClientLintRule {
6767 return new HHClientLintRule ($this -> error [' code' ]);
6868 }
6969
Original file line number Diff line number Diff line change @@ -59,13 +59,35 @@ final class HHClientLinter implements Linter {
5959 ),
6060 );
6161 $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+ });
7092 }
7193}
Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ final class HHClientLinterTest extends TestCase {
2424 public function getCleanExamples (): vec <(string )> {
2525 return vec [
2626 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+ ),
2737 ];
2838 }
2939
You can’t perform that action at this time.
0 commit comments