Java Code Examples for com.google.javascript.jscomp.CheckLevel#WARNING

The following examples show how to use com.google.javascript.jscomp.CheckLevel#WARNING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClutzErrorManager.java    From clutz with MIT License 6 votes vote down vote up
@Override
public void report(CheckLevel level, JSError error) {
  // Ignore warnings in non-debug mode.
  if (!debug && level == CheckLevel.WARNING) return;

  if (reportClutzMissingTypes
      && error.getDescription().contains("Bad type annotation. Unknown type")) {
    // Prepend an error that hints at missing externs/dependencies.
    reportClutzMissingTypes = false;
    // Leave out the location on purpose, the specific places of missing types are reported from
    // the original message; without a location this error sorts first, so that it is seen first.
    this.report(CheckLevel.ERROR, JSError.make(DeclarationGenerator.CLUTZ_MISSING_TYPES));
    // Fall through, still report the actual error below.
  }
  super.report(level, error);
}
 
Example 2
Source File: CheckRequiresForConstructorsTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public void testRequiresAreCaughtBeforeProcessed() {
  String js = "var foo = {}; var bar = new foo.bar.goo();";
  SourceFile input = SourceFile.fromCode("foo.js", js);
  Compiler compiler = new Compiler();
  CompilerOptions opts = new CompilerOptions();
  opts.checkRequires = CheckLevel.WARNING;
  opts.closurePass = true;

  Result result = compiler.compile(ImmutableList.<SourceFile>of(),
      ImmutableList.of(input), opts);
  JSError[] warnings = result.warnings;
  assertNotNull(warnings);
  assertTrue(warnings.length > 0);

  String expectation = "'foo.bar.goo' used but not goog.require'd";

  for (JSError warning : warnings) {
    if (expectation.equals(warning.description)) {
      return;
    }
  }

  fail("Could not find the following warning:" + expectation);
}
 
Example 3
Source File: CheckDebuggerStatementTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void testCheckDebuggerStatement() {
  checkLevel = CheckLevel.WARNING;

  testSame("debugger;", CheckDebuggerStatement.DEBUGGER_STATEMENT_PRESENT);
  testSame("function foo() { debugger; }",
      CheckDebuggerStatement.DEBUGGER_STATEMENT_PRESENT);
}
 
Example 4
Source File: BasicErrorManager.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void report(CheckLevel level, JSError error) {
  if (messages.add(new ErrorWithLevel(error, level))) {
    if (level == CheckLevel.ERROR) {
      errorCount++;
    } else if (level == CheckLevel.WARNING) {
      warningCount++;
    }
  }
}
 
Example 5
Source File: WhitelistWarningsGuard.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CheckLevel level(JSError error) {
  if (containWarning(formatWarning(error))) {
    // If the message matches the guard we use WARNING, so that it
    // - Shows up on stderr, and
    // - Gets caught by the WhitelistBuilder downstream in the pipeline
    return CheckLevel.WARNING;
  }

  return null;
}
 
Example 6
Source File: GentsErrorManager.java    From clutz with MIT License 5 votes vote down vote up
@Override
public void report(CheckLevel level, JSError error) {
  // Ignore warnings in non-debug mode.
  if (!debug && level == CheckLevel.WARNING) {
    return;
  }
  super.report(level, error);
}
 
Example 7
Source File: Closure_69_TypeCheck_s.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 8
Source File: CheckDebuggerStatementTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void testCheckDebuggerKeywordMayAppearInComments() {
  checkLevel = CheckLevel.WARNING;

  test("// I like the debugger; it is helpful.", "");
}
 
Example 9
Source File: CheckSideEffectsTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected CompilerPass getProcessor(Compiler compiler) {
  return new CheckSideEffects(compiler, CheckLevel.WARNING, true);
}
 
Example 10
Source File: Closure_66_TypeCheck_t.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 11
Source File: Nopol2017_0029_s.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 12
Source File: Nopol2017_0051_s.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 13
Source File: Closure_96_TypeCheck_t.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 14
Source File: Closure_96_TypeCheck_s.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 15
Source File: Closure_2_TypeCheck_s.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 16
Source File: CheckProvidesTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected CompilerPass getProcessor(Compiler compiler) {
  return new CheckProvides(compiler, CheckLevel.WARNING);
}
 
Example 17
Source File: TypeCheck.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 18
Source File: CheckRequiresForConstructorsTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected CompilerPass getProcessor(Compiler compiler) {
  return new CheckRequiresForConstructors(compiler, CheckLevel.WARNING);
}
 
Example 19
Source File: Nopol2017_0029_t.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}
 
Example 20
Source File: Nopol2017_0051_t.java    From coming with MIT License 4 votes vote down vote up
TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry) {
  this(compiler, reverseInterpreter, typeRegistry, null, null,
       CheckLevel.WARNING, CheckLevel.OFF);
}