-
Notifications
You must be signed in to change notification settings - Fork 42
Add the File::errorCodesToSuppress
method, which scans a source file for all lint markers
#384
Conversation
lintMarkers
method, which scans a source file for all lint markerslintMarkers
method, which scans a source file for all lint markers
840371a
to
8ed09eb
Compare
c8aed9d
to
009b7b1
Compare
src/File.hack
Outdated
* Returns the 1-base line number of lint markers in the file. | ||
*/ | ||
<<__Memoize>> | ||
public function lintMarkers(): dict<string, keyset<self::TLineNumber1Base>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lintMarkersForLineBasedSuppression
Not all linters should respect these, especially AST-based linters (they should require that the suppression be attached to the specific AST node).
That's probably the best for hh-client based linters; given ASTs are cached, it shoudln't be too wasteful. The position can be transformed to a node via HHAST\find_node_at_position() - and the AST identifies which comments correspond to which nodes.
if memoized, this does need sharing between linters, but it's not great for separation of concerns :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if HHVM supports something similar to ES6 WeakMap
to implement a non-intrusive cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not worth to introduce some mechanism of Dependency Injection in this simple library.
We might be able to implement the Cake Pattern here, but Hack trait
s are more restrictive than Scala trait
s.
Probably there is no simple solution for separation of concerns here.
lintMarkers
method, which scans a source file for all lint markerslintMarkersForLineBasedSuppression
method, which scans a source file for all lint markers
9915195
to
3562ba1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for these to be fixed in followups.
Does need green test run though |
300ee11
to
31652f1
Compare
… suppress according to lint markers in the file
lintMarkersForLineBasedSuppression
method, which scans a source file for all lint markersFile::errorCodesToSuppress
method, which scans a source file for all lint markers
This dict returned by
lintMarkers
can be reused by all the linters, reducing repeated string search.