Skip to content

Commit

Permalink
Fix EQ_GETCLASS_AND_CLASS_CONSTANT SpotBugs violations (jenkinsci#6125
Browse files Browse the repository at this point in the history
)
  • Loading branch information
basil authored Dec 29, 2021
1 parent bb797a5 commit 94b5a21
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import java.util.Objects;
import net.sf.json.JSONObject;
Expand Down Expand Up @@ -103,6 +104,7 @@ public int hashCode() {
}

@Override
@SuppressFBWarnings(value = "EQ_GETCLASS_AND_CLASS_CONSTANT", justification = "ParameterDefinitionTest tests that subclasses are not equal to their parent classes, so the behavior appears to be intentional")
public boolean equals(Object obj) {
if (BooleanParameterDefinition.class != getClass())
return super.equals(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.Util;
import hudson.util.FormValidation;
Expand Down Expand Up @@ -181,6 +182,7 @@ public int hashCode() {
}

@Override
@SuppressFBWarnings(value = "EQ_GETCLASS_AND_CLASS_CONSTANT", justification = "ParameterDefinitionTest tests that subclasses are not equal to their parent classes, so the behavior appears to be intentional")
public boolean equals(Object obj) {
if (ChoiceParameterDefinition.class != getClass())
return super.equals(obj);
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/FileParameterDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.cli.CLICommand;
import java.io.File;
Expand Down Expand Up @@ -140,6 +141,7 @@ public int hashCode() {
}

@Override
@SuppressFBWarnings(value = "EQ_GETCLASS_AND_CLASS_CONSTANT", justification = "ParameterDefinitionTest tests that subclasses are not equal to their parent classes, so the behavior appears to be intentional")
public boolean equals(Object obj) {
if (FileParameterDefinition.class != getClass())
return super.equals(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.util.Secret;
import java.util.Objects;
Expand Down Expand Up @@ -116,6 +117,7 @@ public int hashCode() {
}

@Override
@SuppressFBWarnings(value = "EQ_GETCLASS_AND_CLASS_CONSTANT", justification = "ParameterDefinitionTest tests that subclasses are not equal to their parent classes, so the behavior appears to be intentional")
public boolean equals(Object obj) {
if (PasswordParameterDefinition.class != getClass())
return super.equals(obj);
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/RunParameterDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.util.EnumConverter;
import hudson.util.RunList;
Expand Down Expand Up @@ -219,6 +220,7 @@ public int hashCode() {
}

@Override
@SuppressFBWarnings(value = "EQ_GETCLASS_AND_CLASS_CONSTANT", justification = "ParameterDefinitionTest tests that subclasses are not equal to their parent classes, so the behavior appears to be intentional")
public boolean equals(Object obj) {
if (RunParameterDefinition.class != getClass())
return super.equals(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.Util;
import java.util.Objects;
Expand Down Expand Up @@ -172,6 +173,7 @@ public int hashCode() {
}

@Override
@SuppressFBWarnings(value = "EQ_GETCLASS_AND_CLASS_CONSTANT", justification = "ParameterDefinitionTest tests that subclasses are not equal to their parent classes, so the behavior appears to be intentional")
public boolean equals(Object obj) {
if (StringParameterDefinition.class != getClass())
return super.equals(obj);
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/TextParameterDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import java.util.Objects;
import net.sf.json.JSONObject;
Expand Down Expand Up @@ -85,6 +86,7 @@ public int hashCode() {
}

@Override
@SuppressFBWarnings(value = "EQ_GETCLASS_AND_CLASS_CONSTANT", justification = "ParameterDefinitionTest tests that subclasses are not equal to their parent classes, so the behavior appears to be intentional")
public boolean equals(Object obj) {
if (TextParameterDefinition.class != getClass())
return super.equals(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public Socket createSocket(String host, int port) throws IOException {
*/
@Override
public boolean equals(Object obj) {
return obj != null && obj.getClass().equals(NoClientBindProtocolSocketFactory.class);
return obj != null && obj.getClass().equals(getClass());
}

/**
Expand Down
13 changes: 0 additions & 13 deletions src/spotbugs/spotbugs-excludes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,6 @@
<Class name="hudson.slaves.NodeList"/>
</Or>
</And>
<And>
<Bug pattern="EQ_GETCLASS_AND_CLASS_CONSTANT"/>
<Or>
<Class name="hudson.model.BooleanParameterDefinition"/>
<Class name="hudson.model.ChoiceParameterDefinition"/>
<Class name="hudson.model.FileParameterDefinition"/>
<Class name="hudson.model.PasswordParameterDefinition"/>
<Class name="hudson.model.RunParameterDefinition"/>
<Class name="hudson.model.StringParameterDefinition"/>
<Class name="hudson.model.TextParameterDefinition"/>
<Class name="hudson.util.NoClientBindProtocolSocketFactory"/>
</Or>
</And>
<And>
<Bug pattern="FILE_UPLOAD_FILENAME"/>
<Or>
Expand Down

0 comments on commit 94b5a21

Please sign in to comment.