Package com.google.javascript.jscomp
Class WhitelistWarningsGuard
java.lang.Object
com.google.javascript.jscomp.WarningsGuard
com.google.javascript.jscomp.WhitelistWarningsGuard
- All Implemented Interfaces:
Serializable
An extension of
WarningsGuard that provides functionality to maintain
a list of warnings (white-list). It is subclasses' responsibility to decide
what to do with the white-list by implementing the level function.
Warnings are defined by the name of the JS file and the first line of
warnings description.- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.google.javascript.jscomp.WarningsGuard
WarningsGuard.Priority -
Constructor Summary
ConstructorsConstructorDescriptionWhitelistWarningsGuard(Set<String> whitelist) This class depends on an input set that contains the white-list. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancontainWarning(String formattedWarning) Determines whether a given warning is included in the white-list.static StringformatWarning(JSError error) static StringformatWarning(JSError error, boolean withMetaData) static WhitelistWarningsGuardCreates a warnings guard from a file.static StringgetFirstLine(String warning) intThe priority in which warnings guards are applied.Returns a new check level for a given error.loadWhitelistedJsWarnings(com.google.common.io.InputSupplier<? extends Reader> supplier) Loads legacy warnings list from the file.Loads legacy warnings list from the file.Methods inherited from class com.google.javascript.jscomp.WarningsGuard
disables, enables
-
Constructor Details
-
WhitelistWarningsGuard
This class depends on an input set that contains the white-list. The format of each white-list string is: <file-name>:<line-number>? <warning-description> # <optional-comment>- Parameters:
whitelist- The set of JS-warnings that are white-listed. This is expected to have similar format asformatWarning(JSError).
-
-
Method Details
-
level
Description copied from class:WarningsGuardReturns a new check level for a given error. OFF - suppress it, ERROR - report as error. null means that this guard does not know what to do with the error. Null is extremely helpful when you have a chain of guards. If current guard returns null, then the next in the chain should process it.- Specified by:
levelin classWarningsGuard- Parameters:
error- a reported error.- Returns:
- what level given error should have.
-
containWarning
Determines whether a given warning is included in the white-list.- Parameters:
formattedWarning- the warning formatted byformatWarning- Returns:
- whether the given warning is white-listed or not.
-
getPriority
public int getPriority()Description copied from class:WarningsGuardThe priority in which warnings guards are applied. Lower means the guard will be applied sooner. Expressed on a scale of 1 to 100.- Overrides:
getPriorityin classWarningsGuard
-
fromFile
Creates a warnings guard from a file. -
loadWhitelistedJsWarnings
Loads legacy warnings list from the file.- Returns:
- The lines of the file.
-
loadWhitelistedJsWarnings
protected static Set<String> loadWhitelistedJsWarnings(com.google.common.io.InputSupplier<? extends Reader> supplier) Loads legacy warnings list from the file.- Returns:
- The lines of the file.
-
formatWarning
-
formatWarning
- Parameters:
withMetaData- If true, include metadata that's useful to humans This metadata won't be used for matching the warning.
-
getFirstLine
-