Skip to content

Commit

Permalink
Roll back of "Add lint check that warns when adding @Suppress".
Browse files Browse the repository at this point in the history
Reason: internal breakage.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213656073
  • Loading branch information
EatingW authored and tjgq committed Sep 21, 2018
1 parent 5e8e517 commit 948f9e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 48 deletions.
23 changes: 5 additions & 18 deletions src/com/google/javascript/jscomp/lint/CheckJSDocStyle.java
Expand Up @@ -75,12 +75,6 @@ public final class CheckJSDocStyle extends AbstractPostOrderCallback implements
DiagnosticType.disabled("JSC_OPTIONAL_PARAM_NOT_MARKED_OPTIONAL",
"Parameter {0} is optional so its type must end with =");

public static final DiagnosticType WARN_EXCESSIVE_AT_SUPPRESS =
DiagnosticType.disabled(
"JSC_WARN_EXCESSIVE_AT_SUPPRESS",
"Prefer to address the underlying issue"
+ " rather than using @suppress annotations when possible.");

public static final DiagnosticType WRONG_NUMBER_OF_PARAMS =
DiagnosticType.disabled("JSC_WRONG_NUMBER_OF_PARAMS", "Wrong number of @param annotations");

Expand Down Expand Up @@ -108,7 +102,6 @@ public final class CheckJSDocStyle extends AbstractPostOrderCallback implements
MUST_BE_PRIVATE,
MUST_HAVE_TRAILING_UNDERSCORE,
OPTIONAL_PARAM_NOT_MARKED_OPTIONAL,
WARN_EXCESSIVE_AT_SUPPRESS,
WRONG_NUMBER_OF_PARAMS,
INCORRECT_PARAM_NAME,
EXTERNS_FILES_SHOULD_BE_ANNOTATED,
Expand Down Expand Up @@ -142,10 +135,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
case LET:
case CONST:
case STRING_KEY:
break;
case SCRIPT:
JSDocInfo jsDoc = n.getJSDocInfo();
warnIfAtCodeOrAtSuppressPresent(t, n, jsDoc);
break;
case MEMBER_FUNCTION_DEF:
case GETTER_DEF:
Expand All @@ -161,28 +151,25 @@ public void visit(NodeTraversal t, Node n, Node parent) {
}
}

private void warnIfAtCodeOrAtSuppressPresent(NodeTraversal t, Node n, @Nullable JSDocInfo jsDoc) {
private void checkForAtSignCodePresence(NodeTraversal t, Node n, @Nullable JSDocInfo jsDoc) {
if (jsDoc == null) {
return;
}
if (jsDoc.isAtSignCodePresent()) {
t.report(n, PREFER_BACKTICKS_TO_AT_SIGN_CODE);
}
if (!jsDoc.getSuppressions().isEmpty()) {
t.report(n, WARN_EXCESSIVE_AT_SUPPRESS);
}
}

private void visitNonFunction(NodeTraversal t, Node n) {
JSDocInfo jsDoc = n.getJSDocInfo();

warnIfAtCodeOrAtSuppressPresent(t, n, jsDoc);
checkForAtSignCodePresence(t, n, jsDoc);
}

private void checkStyleForPrivateProperties(NodeTraversal t, Node n) {
JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(n);

warnIfAtCodeOrAtSuppressPresent(t, n, jsDoc);
checkForAtSignCodePresence(t, n, jsDoc);

String name;
if (n.isMemberFunctionDef() || n.isGetterDef() || n.isSetterDef()) {
Expand Down Expand Up @@ -214,7 +201,7 @@ private void checkStyleForPrivateProperties(NodeTraversal t, Node n) {
private void visitFunction(NodeTraversal t, Node function, Node parent) {
JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(function);

warnIfAtCodeOrAtSuppressPresent(t, function, jsDoc);
checkForAtSignCodePresence(t, function, jsDoc);

if (jsDoc == null && !hasAnyInlineJsDoc(function)) {
checkMissingJsDoc(t, function);
Expand All @@ -239,7 +226,7 @@ private void visitFunction(NodeTraversal t, Node function, Node parent) {
private void visitClass(NodeTraversal t, Node cls) {
JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(cls);

warnIfAtCodeOrAtSuppressPresent(t, cls, jsDoc);
checkForAtSignCodePresence(t, cls, jsDoc);

if (jsDoc == null) {
return;
Expand Down
Expand Up @@ -21,10 +21,8 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import com.google.common.truth.Correspondence;
import com.google.javascript.jscomp.CheckLevel;
import com.google.javascript.jscomp.CommandLineRunner;
import com.google.javascript.jscomp.CompilerOptions;
import com.google.javascript.jscomp.DiagnosticGroups;
import com.google.javascript.refactoring.ApplySuggestedFixes;
import com.google.javascript.refactoring.RefactoringDriver;
import com.google.javascript.refactoring.RefasterJsScanner;
Expand Down Expand Up @@ -71,13 +69,9 @@ public static void assertFileRefactoring(
}
final ImmutableList<String> expectedCode = expectedCodeBuilder.build();

CompilerOptions options = RefactoringDriver.getCompilerOptions();
// turn off lint checks for the tests
options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.OFF);
RefactoringDriver.Builder driverBuilder =
new RefactoringDriver.Builder()
.addExterns(CommandLineRunner.getBuiltinExterns(CompilerOptions.Environment.BROWSER))
.withCompilerOptions(options);
.addExterns(CommandLineRunner.getBuiltinExterns(CompilerOptions.Environment.BROWSER));

for (String additionalSource : additionalSourceFiles) {
driverBuilder.addInputsFromFile(testDataPathPrefix + File.separator + additionalSource);
Expand Down
23 changes: 0 additions & 23 deletions test/com/google/javascript/jscomp/lint/CheckJSDocStyleTest.java
Expand Up @@ -27,7 +27,6 @@
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.MUST_HAVE_TRAILING_UNDERSCORE;
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.OPTIONAL_PARAM_NOT_MARKED_OPTIONAL;
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.PREFER_BACKTICKS_TO_AT_SIGN_CODE;
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.WARN_EXCESSIVE_AT_SUPPRESS;
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.WRONG_NUMBER_OF_PARAMS;

import com.google.javascript.jscomp.CheckLevel;
Expand Down Expand Up @@ -1077,26 +1076,4 @@ public void testAtSignCodeDetectedWhenPresent() {
"/** blah blah {@code blah blah} blah blah */ function f() {}",
PREFER_BACKTICKS_TO_AT_SIGN_CODE);
}

public void testAtCodeInFileOverview() {
testWarning(
"/** @fileoverview {@code code} */ /** @const */ var example;",
PREFER_BACKTICKS_TO_AT_SIGN_CODE);
}

public void testAtSuppressDetectedForFunction() {
testWarning("/** @suppress {underscore} */ function f() {}", WARN_EXCESSIVE_AT_SUPPRESS);
}

public void testAtSuppressDetectedWithinFunction() {
testWarning(
"/** blah */ function f() { /** @suppress {underscore} @private */ obj.private = f; }",
WARN_EXCESSIVE_AT_SUPPRESS);
}

public void testAtSuppressInFileOverview() {
testWarning(
"/** @fileoverview @suppress {visibility} */ /** @const */ var example;",
WARN_EXCESSIVE_AT_SUPPRESS);
}
}

0 comments on commit 948f9e2

Please sign in to comment.