@GwtIncompatible(value="java.io, java.util.regex") public class AllowlistWarningsGuard extends WarningsGuard
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.Modifier and Type | Class and Description |
---|---|
class |
AllowlistWarningsGuard.AllowlistBuilder
Allowlist builder
|
WarningsGuard.Priority
Constructor and Description |
---|
AllowlistWarningsGuard() |
AllowlistWarningsGuard(java.util.Set<java.lang.String> allowlist)
This class depends on an input set that contains the white-list.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
containWarning(java.lang.String formattedWarning)
Determines whether a given warning is included in the white-list.
|
protected java.lang.String |
formatWarning(JSError error)
If subclasses want to modify the formatting, they should override
#formatWarning(JSError, boolean), not this method.
|
protected java.lang.String |
formatWarning(JSError error,
boolean withMetaData) |
static AllowlistWarningsGuard |
fromFile(java.io.File file)
Creates a warnings guard from a file.
|
static java.lang.String |
getFirstLine(java.lang.String warning) |
int |
getPriority()
The priority in which warnings guards are applied.
|
CheckLevel |
level(JSError error)
Returns a new check level for a given error.
|
protected static java.util.Set<java.lang.String> |
loadAllowlistedJsWarnings(com.google.common.io.CharSource supplier)
Loads legacy warnings list from the file.
|
static java.util.Set<java.lang.String> |
loadAllowlistedJsWarnings(java.io.File file)
Loads legacy warnings list from the file.
|
protected java.util.Set<java.lang.String> |
normalizeAllowlist(java.util.Set<java.lang.String> allowlist)
Loads legacy warnings list from the set of strings.
|
disables, enables
public AllowlistWarningsGuard()
public AllowlistWarningsGuard(java.util.Set<java.lang.String> allowlist)
<file-name>:<line-number>? <warning-description>
#
<optional-comment>
allowlist
- The set of JS-warnings that are white-listed. This is expected to have similar
format as formatWarning(JSError)
.protected java.util.Set<java.lang.String> normalizeAllowlist(java.util.Set<java.lang.String> allowlist)
public CheckLevel level(JSError error)
WarningsGuard
level
in class WarningsGuard
error
- a reported error.protected boolean containWarning(java.lang.String formattedWarning)
formattedWarning
- the warning formatted by formattedWarning
public int getPriority()
WarningsGuard
getPriority
in class WarningsGuard
public static AllowlistWarningsGuard fromFile(java.io.File file)
public static java.util.Set<java.lang.String> loadAllowlistedJsWarnings(java.io.File file)
protected static java.util.Set<java.lang.String> loadAllowlistedJsWarnings(com.google.common.io.CharSource supplier)
protected java.lang.String formatWarning(JSError error)
protected java.lang.String formatWarning(JSError error, boolean withMetaData)
withMetaData
- If true, include metadata that's useful to humans
This metadata won't be used for matching the warning.public static java.lang.String getFirstLine(java.lang.String warning)
Copyright © 2009-2020 Google. All Rights Reserved.