Remove redundant null checks used with "instanceof"

SonarLint reports:

Null checks should not be used with "instanceof" (squid:S4201)

There's no need to null test in conjunction with an instanceof test.
null is not an instanceof anything, so a null check is redundant.

Change-Id: I29506aebfe337c8c300b46179e43b3057d9ae370
This commit is contained in:
David Pursehouse
2020-02-19 17:49:06 +09:00
parent b715bb82a4
commit d6eb1c29a8
4 changed files with 4 additions and 6 deletions

View File

@@ -572,7 +572,7 @@ public class ProjectBranchesScreen extends PaginatedProjectScreen {
boolean on = false;
for (int row = 1; row < table.getRowCount(); row++) {
Widget w = table.getWidget(row, 1);
if (w != null && w instanceof CheckBox) {
if (w instanceof CheckBox) {
CheckBox sel = (CheckBox) w;
if (sel.getValue()) {
on = true;

View File

@@ -470,7 +470,7 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
boolean on = false;
for (int row = 1; row < table.getRowCount(); row++) {
Widget w = table.getWidget(row, 1);
if (w != null && w instanceof CheckBox) {
if (w instanceof CheckBox) {
CheckBox sel = (CheckBox) w;
if (sel.getValue()) {
on = true;

View File

@@ -163,7 +163,7 @@ public class PluginLoader extends DialogBox {
Exception e = plugin.failure();
String msg;
if (e != null && e instanceof CodeDownloadException) {
if (e instanceof CodeDownloadException) {
msg = Gerrit.M.cannotDownloadPlugin(plugin.url());
} else {
msg = Gerrit.M.pluginFailed(plugin.name());

View File

@@ -37,9 +37,7 @@ public class AndChangeSource extends AndSource<ChangeData> implements ChangeData
@Override
public boolean hasChange() {
return source != null
&& source instanceof ChangeDataSource
&& ((ChangeDataSource) source).hasChange();
return source instanceof ChangeDataSource && ((ChangeDataSource) source).hasChange();
}
@Override