Commit 79ee6a46 authored by Daniel Le Berre's avatar Daniel Le Berre
Browse files

Fixes a few sonarqube violations.

parent f3c86d8b
...@@ -49,8 +49,8 @@ import org.sat4j.specs.VarMapper; ...@@ -49,8 +49,8 @@ import org.sat4j.specs.VarMapper;
* @author leberre * @author leberre
* @since 2.1 * @since 2.1
*/ */
public abstract class BinaryClause implements Propagatable, Constr, public abstract class BinaryClause
Serializable { implements Propagatable, Constr, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -108,7 +108,8 @@ public abstract class BinaryClause implements Propagatable, Constr, ...@@ -108,7 +108,8 @@ public abstract class BinaryClause implements Propagatable, Constr,
* @see Constr#simplify(Solver) * @see Constr#simplify(Solver)
*/ */
public boolean simplify() { public boolean simplify() {
if (this.voc.isSatisfied(this.head) || this.voc.isSatisfied(this.tail)) { if (this.voc.isSatisfied(this.head)
|| this.voc.isSatisfied(this.tail)) {
return true; return true;
} }
return false; return false;
...@@ -220,6 +221,9 @@ public abstract class BinaryClause implements Propagatable, Constr, ...@@ -220,6 +221,9 @@ public abstract class BinaryClause implements Propagatable, Constr,
if (obj == null) { if (obj == null) {
return false; return false;
} }
if (this.getClass() != obj.getClass()) {
return false;
}
try { try {
BinaryClause wcl = (BinaryClause) obj; BinaryClause wcl = (BinaryClause) obj;
if (wcl.head != this.head || wcl.tail != this.tail) { if (wcl.head != this.head || wcl.tail != this.tail) {
...@@ -233,7 +237,7 @@ public abstract class BinaryClause implements Propagatable, Constr, ...@@ -233,7 +237,7 @@ public abstract class BinaryClause implements Propagatable, Constr,
@Override @Override
public int hashCode() { public int hashCode() {
long sum = this.head + this.tail; long sum = (long) this.head + this.tail;
return (int) sum / 2; return (int) sum / 2;
} }
......
...@@ -128,7 +128,8 @@ public abstract class HTClause implements Propagatable, Constr, Serializable { ...@@ -128,7 +128,8 @@ public abstract class HTClause implements Propagatable, Constr, Serializable {
* @see Constr#simplify(Solver) * @see Constr#simplify(Solver)
*/ */
public boolean simplify() { public boolean simplify() {
if (this.voc.isSatisfied(this.head) || this.voc.isSatisfied(this.tail)) { if (this.voc.isSatisfied(this.head)
|| this.voc.isSatisfied(this.tail)) {
return true; return true;
} }
for (int middleLit : this.middleLits) { for (int middleLit : this.middleLits) {
...@@ -273,6 +274,8 @@ public abstract class HTClause implements Propagatable, Constr, Serializable { ...@@ -273,6 +274,8 @@ public abstract class HTClause implements Propagatable, Constr, Serializable {
if (obj == null) { if (obj == null) {
return false; return false;
} }
if (this.getClass() != obj.getClass())
return false;
try { try {
HTClause wcl = (HTClause) obj; HTClause wcl = (HTClause) obj;
if (wcl.head != this.head || wcl.tail != this.tail) { if (wcl.head != this.head || wcl.tail != this.tail) {
...@@ -302,7 +305,7 @@ public abstract class HTClause implements Propagatable, Constr, Serializable { ...@@ -302,7 +305,7 @@ public abstract class HTClause implements Propagatable, Constr, Serializable {
@Override @Override
public int hashCode() { public int hashCode() {
long sum = this.head + this.tail; long sum = (long) this.head + this.tail;
for (int p : this.middleLits) { for (int p : this.middleLits) {
sum += p; sum += p;
} }
......
...@@ -245,6 +245,9 @@ public abstract class WLClause implements Propagatable, Constr, Serializable { ...@@ -245,6 +245,9 @@ public abstract class WLClause implements Propagatable, Constr, Serializable {
if (obj == null) { if (obj == null) {
return false; return false;
} }
if (this.getClass() != obj.getClass()) {
return false;
}
try { try {
WLClause wcl = (WLClause) obj; WLClause wcl = (WLClause) obj;
if (this.lits.length != wcl.lits.length) { if (this.lits.length != wcl.lits.length) {
......
...@@ -51,10 +51,10 @@ public class SizeComparator implements Comparator<Constr>, Serializable { ...@@ -51,10 +51,10 @@ public class SizeComparator implements Comparator<Constr>, Serializable {
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/ */
public int compare(Constr c1, Constr c2) { public int compare(Constr c1, Constr c2) {
long delta = c1.size() - c2.size(); int delta = c1.size() - c2.size();
if (delta == 0) { if (delta == 0) {
return (int) Math.round(c2.getActivity() - c1.getActivity()); return (int) Math.round(c2.getActivity() - c1.getActivity());
} }
return (int) delta; return delta;
} }
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment