48
48
import com .google .errorprone .bugpatterns .EqualsIncompatibleType ;
49
49
import com .google .errorprone .bugpatterns .LongLiteralLowerCaseSuffix ;
50
50
import com .google .errorprone .bugpatterns .PackageLocation ;
51
+ import com .google .errorprone .bugpatterns .ReferenceEquality ;
51
52
import com .google .errorprone .bugpatterns .StaticQualifiedUsingExpression ;
52
- import com .google .errorprone .bugpatterns .StringEquality ;
53
53
import com .google .errorprone .bugpatterns .nullness .UnnecessaryCheckNotNull ;
54
54
import com .sun .source .util .JavacTask ;
55
55
import com .sun .tools .javac .api .JavacTool ;
@@ -331,10 +331,10 @@ public void applyOverridesEnableAllChecks() {
331
331
332
332
@ Test
333
333
public void applyOverridesDisableErrors () {
334
- // BadShiftAmount (error), ArrayEquals (unsuppressible error), StringEquality (warning)
334
+ // BadShiftAmount (error), ArrayEquals (unsuppressible error), ReferenceEquality (warning)
335
335
ScannerSupplier ss =
336
336
ScannerSupplier .fromBugCheckerClasses (
337
- BadShiftAmount .class , UnsuppressibleArrayEquals .class , StringEquality .class );
337
+ BadShiftAmount .class , UnsuppressibleArrayEquals .class , ReferenceEquality .class );
338
338
339
339
ErrorProneOptions epOptions =
340
340
ErrorProneOptions .processArgs (ImmutableList .of ("-XepAllErrorsAsWarnings" ));
@@ -344,31 +344,31 @@ public void applyOverridesDisableErrors() {
344
344
ImmutableMap .of (
345
345
"ArrayEquals" , SeverityLevel .ERROR , // Unsuppressible, not demoted
346
346
"BadShiftAmount" , SeverityLevel .WARNING , // Demoted from error to warning
347
- "StringEquality " , SeverityLevel .WARNING )); // Already warning, unaffected
347
+ "ReferenceEquality " , SeverityLevel .WARNING )); // Already warning, unaffected
348
348
349
349
// Flags after AllErrorsAsWarnings flag should override it.
350
350
epOptions =
351
351
ErrorProneOptions .processArgs (
352
- ImmutableList .of ("-XepAllErrorsAsWarnings" , "-Xep:StringEquality :ERROR" ));
352
+ ImmutableList .of ("-XepAllErrorsAsWarnings" , "-Xep:ReferenceEquality :ERROR" ));
353
353
354
354
assertScanner (ss .applyOverrides (epOptions ))
355
355
.hasSeverities (
356
356
ImmutableMap .of (
357
357
"ArrayEquals" , SeverityLevel .ERROR ,
358
358
"BadShiftAmount" , SeverityLevel .WARNING ,
359
- "StringEquality " , SeverityLevel .ERROR ));
359
+ "ReferenceEquality " , SeverityLevel .ERROR ));
360
360
361
361
// AllErrorsAsWarnings flag should override all error-level severity flags that come before it.
362
362
epOptions =
363
363
ErrorProneOptions .processArgs (
364
- ImmutableList .of ("-Xep:StringEquality :ERROR" , "-XepAllErrorsAsWarnings" ));
364
+ ImmutableList .of ("-Xep:ReferenceEquality :ERROR" , "-XepAllErrorsAsWarnings" ));
365
365
366
366
assertScanner (ss .applyOverrides (epOptions ))
367
367
.hasSeverities (
368
368
ImmutableMap .of (
369
369
"ArrayEquals" , SeverityLevel .ERROR ,
370
370
"BadShiftAmount" , SeverityLevel .WARNING ,
371
- "StringEquality " , SeverityLevel .WARNING ));
371
+ "ReferenceEquality " , SeverityLevel .WARNING ));
372
372
373
373
// AllErrorsAsWarnings only overrides error-level severity flags.
374
374
// That is, checks disabled before the flag are left disabled, not promoted to warnings.
@@ -380,9 +380,9 @@ public void applyOverridesDisableErrors() {
380
380
.hasSeverities (
381
381
ImmutableMap .of (
382
382
"ArrayEquals" , SeverityLevel .ERROR ,
383
- "StringEquality " , SeverityLevel .WARNING ));
383
+ "ReferenceEquality " , SeverityLevel .WARNING ));
384
384
assertScanner (ss .applyOverrides (epOptions ))
385
- .hasEnabledChecks (UnsuppressibleArrayEquals .class , StringEquality .class );
385
+ .hasEnabledChecks (UnsuppressibleArrayEquals .class , ReferenceEquality .class );
386
386
}
387
387
388
388
@ Test
@@ -465,18 +465,20 @@ public void applyOverridesSucceedsWhenDisablingUnknownCheckAndIgnoreUnknownCheck
465
465
public void applyOverridesSetsSeverity () {
466
466
ScannerSupplier ss =
467
467
ScannerSupplier .fromBugCheckerClasses (
468
- BadShiftAmount .class , ChainingConstructorIgnoresParameter .class , StringEquality .class );
468
+ BadShiftAmount .class ,
469
+ ChainingConstructorIgnoresParameter .class ,
470
+ ReferenceEquality .class );
469
471
ErrorProneOptions epOptions =
470
472
ErrorProneOptions .processArgs (
471
473
ImmutableList .of (
472
- "-Xep:ChainingConstructorIgnoresParameter:WARN" , "-Xep:StringEquality :ERROR" ));
474
+ "-Xep:ChainingConstructorIgnoresParameter:WARN" , "-Xep:ReferenceEquality :ERROR" ));
473
475
ScannerSupplier overriddenScannerSupplier = ss .applyOverrides (epOptions );
474
476
475
477
ImmutableMap <String , SeverityLevel > expected =
476
478
ImmutableMap .of (
477
479
"BadShiftAmount" , SeverityLevel .ERROR ,
478
480
"ChainingConstructorIgnoresParameter" , SeverityLevel .WARNING ,
479
- "StringEquality " , SeverityLevel .ERROR );
481
+ "ReferenceEquality " , SeverityLevel .ERROR );
480
482
481
483
assertScanner (overriddenScannerSupplier ).hasSeverities (expected );
482
484
}
@@ -507,35 +509,37 @@ public void allChecksAsWarningsWorks() {
507
509
ScannerSupplier .fromBugCheckerClasses (
508
510
BadShiftAmount .class ,
509
511
ChainingConstructorIgnoresParameter .class ,
510
- StringEquality .class )
512
+ ReferenceEquality .class )
511
513
.filter (Predicates .alwaysFalse ());
512
514
assertScanner (ss ).hasEnabledChecks (); // Everything's off
513
515
514
516
ErrorProneOptions epOptions =
515
517
ErrorProneOptions .processArgs (
516
- ImmutableList .of ("-Xep:StringEquality :OFF" , "-XepAllDisabledChecksAsWarnings" ));
518
+ ImmutableList .of ("-Xep:ReferenceEquality :OFF" , "-XepAllDisabledChecksAsWarnings" ));
517
519
518
520
ScannerSupplier withOverrides = ss .applyOverrides (epOptions );
519
521
assertScanner (withOverrides )
520
522
.hasEnabledChecks (
521
- BadShiftAmount .class , ChainingConstructorIgnoresParameter .class , StringEquality .class );
523
+ BadShiftAmount .class ,
524
+ ChainingConstructorIgnoresParameter .class ,
525
+ ReferenceEquality .class );
522
526
523
527
ImmutableMap <String , SeverityLevel > expectedSeverities =
524
528
ImmutableMap .of (
525
529
"BadShiftAmount" ,
526
530
SeverityLevel .WARNING ,
527
531
"ChainingConstructorIgnoresParameter" ,
528
532
SeverityLevel .WARNING ,
529
- "StringEquality " ,
533
+ "ReferenceEquality " ,
530
534
SeverityLevel .WARNING );
531
535
assertScanner (withOverrides ).hasSeverities (expectedSeverities );
532
536
533
537
epOptions =
534
538
ErrorProneOptions .processArgs (
535
539
ImmutableList .of (
536
- "-Xep:StringEquality :OFF" ,
540
+ "-Xep:ReferenceEquality :OFF" ,
537
541
"-XepAllDisabledChecksAsWarnings" ,
538
- "-Xep:StringEquality :OFF" ));
542
+ "-Xep:ReferenceEquality :OFF" ));
539
543
540
544
withOverrides = ss .applyOverrides (epOptions );
541
545
assertScanner (withOverrides )
0 commit comments