Skip to content

Commit

Permalink
Remove deprecation warnings from the accessControls group.
Browse files Browse the repository at this point in the history
Having them there causes them to show up on the command line if --jscomp_warning=accessControls is passed, even if --jscomp_warning=deprecated is not passed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154896865
  • Loading branch information
tbreisacher authored and brad4d committed May 3, 2017
1 parent 3112349 commit ec4b5c5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/com/google/javascript/jscomp/DiagnosticGroups.java
Expand Up @@ -184,9 +184,9 @@ public DiagnosticGroup forName(String name) {
CheckAccessControls.VISIBILITY_MISMATCH, CheckAccessControls.VISIBILITY_MISMATCH,
CheckAccessControls.CONVENTION_MISMATCH); CheckAccessControls.CONVENTION_MISMATCH);


// TODO(tbreisacher): Deprecate this and keep just the "visibility" group.
public static final DiagnosticGroup ACCESS_CONTROLS = public static final DiagnosticGroup ACCESS_CONTROLS =
DiagnosticGroups.registerGroup("accessControls", DiagnosticGroups.registerGroup("accessControls", VISIBILITY);
DEPRECATED, VISIBILITY);


public static final DiagnosticGroup NON_STANDARD_JSDOC = public static final DiagnosticGroup NON_STANDARD_JSDOC =
DiagnosticGroups.registerGroup("nonStandardJsDocs", DiagnosticGroups.registerGroup("nonStandardJsDocs",
Expand Down
Expand Up @@ -74,6 +74,7 @@ protected CompilerPass getProcessor(final Compiler compiler) {
protected CompilerOptions getOptions() { protected CompilerOptions getOptions() {
CompilerOptions options = super.getOptions(); CompilerOptions options = super.getOptions();
options.setWarningLevel(DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.ERROR); options.setWarningLevel(DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.ERROR);
options.setWarningLevel(DiagnosticGroups.DEPRECATED, CheckLevel.ERROR);
options.setWarningLevel(DiagnosticGroups.CONSTANT_PROPERTY, CheckLevel.ERROR); options.setWarningLevel(DiagnosticGroups.CONSTANT_PROPERTY, CheckLevel.ERROR);
// Disable NTI's native const checks so as to suppress duplicate warnings that // Disable NTI's native const checks so as to suppress duplicate warnings that
// prevent us from testing the const checks of CheckAccessControls itself. // prevent us from testing the const checks of CheckAccessControls itself.
Expand Down
91 changes: 45 additions & 46 deletions test/com/google/javascript/jscomp/WarningsGuardTest.java
Expand Up @@ -17,14 +17,14 @@
package com.google.javascript.jscomp; package com.google.javascript.jscomp;


import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.javascript.jscomp.CheckAccessControls.DEPRECATED_NAME;
import static com.google.javascript.jscomp.CheckAccessControls.VISIBILITY_MISMATCH; import static com.google.javascript.jscomp.CheckAccessControls.VISIBILITY_MISMATCH;
import static com.google.javascript.jscomp.CheckLevel.ERROR; import static com.google.javascript.jscomp.CheckLevel.ERROR;
import static com.google.javascript.jscomp.CheckLevel.OFF; import static com.google.javascript.jscomp.CheckLevel.OFF;
import static com.google.javascript.jscomp.CheckLevel.WARNING; import static com.google.javascript.jscomp.CheckLevel.WARNING;
import static com.google.javascript.jscomp.NewTypeInference.MISTYPED_ASSIGN_RHS;
import static com.google.javascript.jscomp.TypeCheck.DETERMINISTIC_TEST;


import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.javascript.jscomp.CheckLevel;
import com.google.javascript.jscomp.ShowByPathWarningsGuard.ShowType; import com.google.javascript.jscomp.ShowByPathWarningsGuard.ShowType;
import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.Token; import com.google.javascript.rhino.Token;
Expand All @@ -42,11 +42,11 @@ public final class WarningsGuardTest extends TestCase {
private static final DiagnosticType BAR_WARNING = private static final DiagnosticType BAR_WARNING =
DiagnosticType.warning("BAR", "Bar description"); DiagnosticType.warning("BAR", "Bar description");


private static final WarningsGuard accessControlsOff = private static final WarningsGuard visibilityOff =
new DiagnosticGroupWarningsGuard( new DiagnosticGroupWarningsGuard(
DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.OFF); DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.OFF);


private static final WarningsGuard accessControlsWarning = private static final WarningsGuard visibilityWarning =
new DiagnosticGroupWarningsGuard( new DiagnosticGroupWarningsGuard(
DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.WARNING); DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.WARNING);


Expand Down Expand Up @@ -216,14 +216,14 @@ public void testComposeGuardOrdering2() {
// Ensure that guards added later always override, when two guards // Ensure that guards added later always override, when two guards
// have the same priority. // have the same priority.
ComposeWarningsGuard guardA = new ComposeWarningsGuard(); ComposeWarningsGuard guardA = new ComposeWarningsGuard();
guardA.addGuard(accessControlsWarning); guardA.addGuard(visibilityWarning);
guardA.addGuard(accessControlsOff); guardA.addGuard(visibilityOff);
guardA.addGuard(accessControlsWarning); guardA.addGuard(visibilityWarning);


ComposeWarningsGuard guardB = new ComposeWarningsGuard(); ComposeWarningsGuard guardB = new ComposeWarningsGuard();
guardB.addGuard(accessControlsOff); guardB.addGuard(visibilityOff);
guardB.addGuard(accessControlsWarning); guardB.addGuard(visibilityWarning);
guardB.addGuard(accessControlsOff); guardB.addGuard(visibilityOff);


assertFalse(guardA.disables(DiagnosticGroups.ACCESS_CONTROLS)); assertFalse(guardA.disables(DiagnosticGroups.ACCESS_CONTROLS));
assertTrue(guardA.enables(DiagnosticGroups.ACCESS_CONTROLS)); assertTrue(guardA.enables(DiagnosticGroups.ACCESS_CONTROLS));
Expand All @@ -245,20 +245,20 @@ public void testComposeGuardOrdering3() {
guardA.addGuard( guardA.addGuard(
new DiagnosticGroupWarningsGuard( new DiagnosticGroupWarningsGuard(
DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.WARNING)); DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.WARNING));
guardA.addGuard(accessControlsOff); guardA.addGuard(visibilityOff);


assertTrue(guardA.disables(DiagnosticGroups.ACCESS_CONTROLS)); assertTrue(guardA.disables(DiagnosticGroups.ACCESS_CONTROLS));
} }


public void testComposeGuardOrdering4() { public void testComposeGuardOrdering4() {
ComposeWarningsGuard guardA = new ComposeWarningsGuard(); ComposeWarningsGuard guardA = new ComposeWarningsGuard();
guardA.addGuard(accessControlsWarning); guardA.addGuard(visibilityWarning);
guardA.addGuard(accessControlsWarning); guardA.addGuard(visibilityWarning);
guardA.addGuard(accessControlsWarning); guardA.addGuard(visibilityWarning);
guardA.addGuard(accessControlsWarning); guardA.addGuard(visibilityWarning);
guardA.addGuard(accessControlsWarning); guardA.addGuard(visibilityWarning);
guardA.addGuard(accessControlsWarning); guardA.addGuard(visibilityWarning);
guardA.addGuard(accessControlsOff); guardA.addGuard(visibilityOff);


assertTrue(guardA.disables(DiagnosticGroups.ACCESS_CONTROLS)); assertTrue(guardA.disables(DiagnosticGroups.ACCESS_CONTROLS));
} }
Expand Down Expand Up @@ -302,49 +302,49 @@ public void testEmergencyComposeGuard3() {


public void testDiagnosticGuard1() { public void testDiagnosticGuard1() {
WarningsGuard guard = new DiagnosticGroupWarningsGuard( WarningsGuard guard = new DiagnosticGroupWarningsGuard(
DiagnosticGroups.ACCESS_CONTROLS, ERROR); DiagnosticGroups.CHECK_TYPES, ERROR);


assertEquals(ERROR, guard.level(makeError("foo", VISIBILITY_MISMATCH))); assertEquals(ERROR, guard.level(makeError("foo", MISTYPED_ASSIGN_RHS)));
assertEquals(ERROR, guard.level(makeError("foo", DEPRECATED_NAME))); assertEquals(ERROR, guard.level(makeError("foo", DETERMINISTIC_TEST)));


assertFalse(guard.disables(DiagnosticGroups.DEPRECATED)); assertFalse(guard.disables(DiagnosticGroups.OLD_CHECK_TYPES));
assertFalse(guard.disables(DiagnosticGroups.VISIBILITY)); assertFalse(guard.disables(DiagnosticGroups.NEW_CHECK_TYPES));
assertFalse(guard.disables(DiagnosticGroups.ACCESS_CONTROLS)); assertFalse(guard.disables(DiagnosticGroups.CHECK_TYPES));


assertEnables(guard, DiagnosticGroups.DEPRECATED); assertEnables(guard, DiagnosticGroups.OLD_CHECK_TYPES);
assertEnables(guard, DiagnosticGroups.VISIBILITY); assertEnables(guard, DiagnosticGroups.NEW_CHECK_TYPES);
assertEnables(guard, DiagnosticGroups.ACCESS_CONTROLS); assertEnables(guard, DiagnosticGroups.CHECK_TYPES);
assertNotEnables(guard, DiagnosticGroups.MESSAGE_DESCRIPTIONS); assertNotEnables(guard, DiagnosticGroups.MESSAGE_DESCRIPTIONS);
} }


public void testDiagnosticGuard2() { public void testDiagnosticGuard2() {
WarningsGuard guard = new DiagnosticGroupWarningsGuard( WarningsGuard guard = new DiagnosticGroupWarningsGuard(
DiagnosticGroups.DEPRECATED, ERROR); DiagnosticGroups.OLD_CHECK_TYPES, ERROR);


assertNull(guard.level(makeError("foo", VISIBILITY_MISMATCH))); assertNull(guard.level(makeError("foo", MISTYPED_ASSIGN_RHS)));
assertEquals(ERROR, guard.level(makeError("foo", DEPRECATED_NAME))); assertEquals(ERROR, guard.level(makeError("foo", DETERMINISTIC_TEST)));


assertFalse(guard.disables(DiagnosticGroups.DEPRECATED)); assertFalse(guard.disables(DiagnosticGroups.OLD_CHECK_TYPES));
assertFalse(guard.disables(DiagnosticGroups.VISIBILITY)); assertFalse(guard.disables(DiagnosticGroups.NEW_CHECK_TYPES));
assertFalse(guard.disables(DiagnosticGroups.ACCESS_CONTROLS)); assertFalse(guard.disables(DiagnosticGroups.CHECK_TYPES));


assertEnables(guard, DiagnosticGroups.DEPRECATED); assertEnables(guard, DiagnosticGroups.OLD_CHECK_TYPES);
assertNotEnables(guard, DiagnosticGroups.VISIBILITY); assertNotEnables(guard, DiagnosticGroups.NEW_CHECK_TYPES);
assertEnables(guard, DiagnosticGroups.ACCESS_CONTROLS); assertEnables(guard, DiagnosticGroups.CHECK_TYPES);
assertNotEnables(guard, DiagnosticGroups.MESSAGE_DESCRIPTIONS); assertNotEnables(guard, DiagnosticGroups.MESSAGE_DESCRIPTIONS);
} }


public void testDiagnosticGuard3() { public void testDiagnosticGuard3() {
WarningsGuard guard = new DiagnosticGroupWarningsGuard( WarningsGuard guard = new DiagnosticGroupWarningsGuard(
DiagnosticGroups.ACCESS_CONTROLS, OFF); DiagnosticGroups.CHECK_TYPES, OFF);


assertTrue(guard.disables(DiagnosticGroups.DEPRECATED)); assertTrue(guard.disables(DiagnosticGroups.OLD_CHECK_TYPES));
assertTrue(guard.disables(DiagnosticGroups.VISIBILITY)); assertTrue(guard.disables(DiagnosticGroups.NEW_CHECK_TYPES));
assertTrue(guard.disables(DiagnosticGroups.ACCESS_CONTROLS)); assertTrue(guard.disables(DiagnosticGroups.CHECK_TYPES));


assertNotEnables(guard, DiagnosticGroups.DEPRECATED); assertNotEnables(guard, DiagnosticGroups.OLD_CHECK_TYPES);
assertNotEnables(guard, DiagnosticGroups.VISIBILITY); assertNotEnables(guard, DiagnosticGroups.NEW_CHECK_TYPES);
assertNotEnables(guard, DiagnosticGroups.ACCESS_CONTROLS); assertNotEnables(guard, DiagnosticGroups.CHECK_TYPES);
assertNotEnables(guard, DiagnosticGroups.MESSAGE_DESCRIPTIONS); assertNotEnables(guard, DiagnosticGroups.MESSAGE_DESCRIPTIONS);
} }


Expand Down Expand Up @@ -449,11 +449,10 @@ public void testSuppressGuard5() {


public void testComposeGuardCycle() { public void testComposeGuardCycle() {
ComposeWarningsGuard guard = new ComposeWarningsGuard( ComposeWarningsGuard guard = new ComposeWarningsGuard(
accessControlsOff, accessControlsWarning); visibilityOff, visibilityWarning);
guard.addGuard(guard); guard.addGuard(guard);
assertEquals( assertEquals(
"DiagnosticGroup<accessControls>(WARNING), " + "DiagnosticGroup<visibility>(WARNING), DiagnosticGroup<visibility>(OFF)",
"DiagnosticGroup<accessControls>(OFF)",
guard.toString()); guard.toString());
} }


Expand Down

0 comments on commit ec4b5c5

Please sign in to comment.