Skip to content

Commit

Permalink
Cleanup redundant null check before instanceof
Browse files Browse the repository at this point in the history
  • Loading branch information
turbanoff authored and kriegaex committed Apr 17, 2022
1 parent 57dd44a commit 816f585
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String fileName() {
}

public boolean equals(Object other) {
if (other == null || !(other instanceof InterimCompilationResult)) {
if (!(other instanceof InterimCompilationResult)) {
return false;
}
InterimCompilationResult ir = (InterimCompilationResult) other;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ boolean isRef(NameReference ref, Binding binding) {

boolean isRef(Expression expr, Binding binding) {
//System.err.println("isRef: " + expr + ", " + binding);
return expr != null
&& expr instanceof NameReference
&& isRef((NameReference) expr, binding);
return expr instanceof NameReference
&& isRef((NameReference)expr, binding);
}

public void endVisit(SingleNameReference ref, BlockScope scope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ boolean isRef(NameReference ref, Binding binding) {
}

boolean isRef(Expression expr, Binding binding) {
return expr != null && expr instanceof NameReference && isRef((NameReference) expr, binding);
return expr instanceof NameReference && isRef((NameReference)expr, binding);
}

public void endVisit(SingleNameReference ref, BlockScope scope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void unusedPrivateType(TypeDeclaration typeDecl) {
// don't output unused type warnings for aspects!
if (typeDecl instanceof AspectDeclaration)
return;
if (typeDecl.enclosingType != null && (typeDecl.enclosingType instanceof AspectDeclaration)) {
if (typeDecl.enclosingType instanceof AspectDeclaration) {
AspectDeclaration ad = (AspectDeclaration) typeDecl.enclosingType;
if (ad.concreteName != null) {
List<Declare> declares = ad.concreteName.declares;
Expand Down Expand Up @@ -609,7 +609,7 @@ public void unusedArgument(LocalDeclaration localDecl) {
Argument arg = (Argument) localDecl;
if (arg.binding != null && arg.binding.declaringScope != null) {
ReferenceContext context = arg.binding.declaringScope.referenceContext();
if (context != null && context instanceof PointcutDeclaration)
if (context instanceof PointcutDeclaration)
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public BinarySourceFile(File dir, File src) {

@Override
public boolean equals(Object obj) {
if (obj != null && (obj instanceof BinarySourceFile)) {
if (obj instanceof BinarySourceFile) {
BinarySourceFile other = (BinarySourceFile) obj;
return (binSrc.equals(other.binSrc));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void exposeType(UnresolvedType typeToExpose) {
String signatureToLookFor = typeToExpose.getSignature();
for (ConcreteTypeMunger cTM : typeMungers) {
ResolvedTypeMunger rTM = cTM.getMunger();
if (rTM != null && rTM instanceof ExposeTypeMunger) {
if (rTM instanceof ExposeTypeMunger) {
String exposedType = ((ExposeTypeMunger) rTM).getExposedTypeSignature();
if (exposedType.equals(signatureToLookFor)) {
return; // dont need to bother
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger {
private TypePattern lazyTestTypePattern;

public boolean equals(Object other) {
if (other == null || !(other instanceof PerObjectInterfaceTypeMunger)) {
if (!(other instanceof PerObjectInterfaceTypeMunger)) {
return false;
}
PerObjectInterfaceTypeMunger o = (PerObjectInterfaceTypeMunger) other;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public String createClassLoaderScope(ClassLoader cl, List<String> aspects) {
StringBuilder hashable = new StringBuilder(256);

// Add the list of loader urls to the hash list
if (cl != null && cl instanceof URLClassLoader) {
if (cl instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) cl).getURLs();
for (URL url : urls) {
hashableStrings.add(url.toString());
Expand Down

0 comments on commit 816f585

Please sign in to comment.