Class WarningsGuard
- java.lang.Object
-
- com.google.javascript.jscomp.WarningsGuard
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
AllowlistWarningsGuard
,ByPathWarningsGuard
,CheckTypeSummaryWarningsGuard
,ComposeWarningsGuard
,DiagnosticGroupPathSuppressingWarningsGuard
,DiagnosticGroupWarningsGuard
,J2clSuppressWarningsGuard
,ShowByPathWarningsGuard
,StrictWarningsGuard
public abstract class WarningsGuard extends java.lang.Object implements java.io.Serializable
Class that allows to flexibly manage what to do with a reported warning/error.Guard has several choices: - return OFF - suppress the warning/error - return WARNING - return ERROR report it with high severity - return null. Does not know what to do with it. Lets the other guard decide what to do with it.
Although the interface is very simple, it allows you easily customize what warnings you are interested in.
For example there are could be several implementations: StrictGuard - {return ERROR}. All warnings should be treat as errors. SilentGuard - {if (WARNING) return OFF}. Suppress all warnings but still fail if JS has errors. AllowlistGuard (if !allowlistErrors.contains(error) return ERROR) return error if it does not present in the allowlist.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WarningsGuard.Priority
Priority
-
Constructor Summary
Constructors Constructor Description WarningsGuard()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected int
getPriority()
The priority in which warnings guards are applied.abstract CheckLevel
level(JSError error)
Returns a new check level for a given error.Tri
mustRunChecks(DiagnosticGroup group)
Do checks for `group` still need to be run if this guard is installed? TRUE: Enables one or more types in the group, so it must be checked.
-
-
-
Method Detail
-
level
@Nullable public abstract CheckLevel level(JSError error)
Returns a new check level for a given error.`null` means that this guard does not know what to do with the error. `null` can be used it chain multiple guards; if current guard returns null, then the next in the chain should process it.
- Parameters:
error
- a reported error.- Returns:
- what level given error should have.
-
mustRunChecks
public Tri mustRunChecks(DiagnosticGroup group)
Do checks for `group` still need to be run if this guard is installed?- TRUE: Enables one or more types in the group, so it must be checked.
- FALSE: Disables all types in the group, so it need not be checked.
- UNKNOWN: Does not affect or only partially disables the group, so checking is undecided.
- Parameters:
group
- a group to check.
-
getPriority
protected int getPriority()
The priority in which warnings guards are applied. Lower means the guard will be applied sooner. Expressed on a scale of 1 to 100.
-
-