Skip to content

Commit

Permalink
Fixing squid: S1155 Collection.isEmpty() should be used to test for e…
Browse files Browse the repository at this point in the history
…mptiness
devFozgul committed Jun 28, 2016

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
1 parent 6543431 commit 59c0e6b
Showing 9 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -602,7 +602,7 @@ public void removeLast() {
public void moveTo(double x, double y) {
if (this.types != null && !this.types.isEmpty()
&& this.types.get(this.types.size() - 1) == PathElementType.MOVE_TO) {
assert this.coords != null && this.coords.size() >= 1;
assert this.coords != null && !this.coords.isEmpty();
final int idx = this.coords.size() - 1;
this.coords.set(idx, getGeomFactory().newPoint(x, y));
} else {
@@ -617,7 +617,7 @@ public void moveTo(Point2D<?, ?> position) {
assert position != null : AssertMessages.notNullParameter();
if (this.types != null && !this.types.isEmpty()
&& this.types.get(this.types.size() - 1) == PathElementType.MOVE_TO) {
assert this.coords != null && this.coords.size() >= 1;
assert this.coords != null && !this.coords.isEmpty();
final int idx = this.coords.size() - 1;
this.coords.set(idx, getGeomFactory().convertToPoint(position));
} else {
@@ -736,7 +736,7 @@ public void setLastPoint(double x, double y) {

@Override
public void setLastPoint(Point2D<?, ?> point) {
if (this.coords != null && this.coords.size() >= 1) {
if (this.coords != null && !this.coords.isEmpty()) {
final int idx = this.coords.size() - 1;
this.coords.get(idx).set(point.getX(), point.getY());
} else {
Original file line number Diff line number Diff line change
@@ -616,7 +616,7 @@ public void removeLast() {
public void moveTo(int x, int y) {
if (this.types != null && !this.types.isEmpty()
&& this.types.get(this.types.size() - 1) == PathElementType.MOVE_TO) {
assert this.coords != null && this.coords.size() >= 1;
assert this.coords != null && !this.coords.isEmpty();
final int idx = this.coords.size() - 1;
this.coords.set(idx, getGeomFactory().newPoint(x, y));
} else {
@@ -631,7 +631,7 @@ public void moveTo(Point2D<?, ?> position) {
assert position != null : AssertMessages.notNullParameter();
if (this.types != null && !this.types.isEmpty()
&& this.types.get(this.types.size() - 1) == PathElementType.MOVE_TO) {
assert this.coords != null && this.coords.size() >= 1;
assert this.coords != null && !this.coords.isEmpty();
final int idx = this.coords.size() - 1;
this.coords.set(idx, getGeomFactory().convertToPoint(position));
} else {
@@ -738,7 +738,7 @@ public int getCoordAt(int index) {

@Override
public void setLastPoint(int x, int y) {
if (this.coords != null && this.coords.size() >= 1) {
if (this.coords != null && !this.coords.isEmpty()) {
final int idx = this.coords.size() - 1;
final Point2ifx point = this.coords.get(idx);
point.setX(x);
@@ -750,7 +750,7 @@ public void setLastPoint(int x, int y) {

@Override
public void setLastPoint(Point2D<?, ?> point) {
if (this.coords != null && this.coords.size() >= 1) {
if (this.coords != null && !this.coords.isEmpty()) {
final int idx = this.coords.size() - 1;
this.coords.get(idx).set(point.ix(), point.iy());
} else {
Original file line number Diff line number Diff line change
@@ -615,7 +615,7 @@ public void removeLast() {
public void moveTo(double x, double y, double z) {
if (this.types != null && !this.types.isEmpty()
&& this.types.get(this.types.size() - 1) == PathElementType.MOVE_TO) {
assert this.coords != null && this.coords.size() >= 1;
assert this.coords != null && !this.coords.isEmpty();
final int idx = this.coords.size() - 1;
this.coords.set(idx, getGeomFactory().newPoint(x, y, z));
} else {
@@ -630,7 +630,7 @@ public void moveTo(Point3D<?, ?> position) {
assert position != null : AssertMessages.notNullParameter();
if (this.types != null && !this.types.isEmpty()
&& this.types.get(this.types.size() - 1) == PathElementType.MOVE_TO) {
assert this.coords != null && this.coords.size() >= 1;
assert this.coords != null && !this.coords.isEmpty();
final int idx = this.coords.size() - 1;
this.coords.set(idx, getGeomFactory().convertToPoint(position));
} else {
Original file line number Diff line number Diff line change
@@ -636,7 +636,7 @@ public void removeLast() {
public void moveTo(int x, int y, int z) {
if (this.types != null && !this.types.isEmpty()
&& this.types.get(this.types.size() - 1) == PathElementType.MOVE_TO) {
assert this.coords != null && this.coords.size() >= 1;
assert this.coords != null && !this.coords.isEmpty();
final int idx = this.coords.size() - 1;
this.coords.set(idx, getGeomFactory().newPoint(x, y, z));
} else {
@@ -651,7 +651,7 @@ public void moveTo(Point3D<?, ?> position) {
assert position != null : AssertMessages.notNullParameter();
if (this.types != null && !this.types.isEmpty()
&& this.types.get(this.types.size() - 1) == PathElementType.MOVE_TO) {
assert this.coords != null && this.coords.size() >= 1;
assert this.coords != null && !this.coords.isEmpty();
final int idx = this.coords.size() - 1;
this.coords.set(idx, getGeomFactory().convertToPoint(position));
} else {
@@ -760,7 +760,7 @@ public int getCoordAt(int index) {

@Override
public void setLastPoint(int x, int y, int z) {
if (this.coords != null && this.coords.size() >= 1) {
if (this.coords != null && !this.coords.isEmpty()) {
final int idx = this.coords.size() - 1;
final Point3ifx point = this.coords.get(idx);
point.setX(x);
Original file line number Diff line number Diff line change
@@ -563,7 +563,7 @@ protected void delayedInit(List<? extends Shape2afp<?, ?, IE, ?, ?, ?>> list) {
this.isPolyline = list.size() == 1
&& this.shapeIterator != null
&& this.shapeIterator.isPolyline();
this.isCurved = list.size() > 0
this.isCurved = !list.isEmpty()
&& this.shapeIterator != null
&& this.shapeIterator.isCurved();
}
Original file line number Diff line number Diff line change
@@ -408,7 +408,7 @@ protected void delayedInit(List<? extends Shape2ai<?, ?, IE, ?, ?, ?>> list) {
this.isPolyline = list.size() == 1
&& this.shapeIterator != null
&& this.shapeIterator.isPolyline();
this.isCurved = list.size() > 0
this.isCurved = !list.isEmpty()
&& this.shapeIterator != null
&& this.shapeIterator.isCurved();
}
Original file line number Diff line number Diff line change
@@ -388,7 +388,7 @@ protected void delayedInit(List<? extends Shape3afp<?, ?, IE, ?, ?, ?>> list) {
this.isPolyline = list.size() == 1
&& this.shapeIterator != null
&& this.shapeIterator.isPolyline();
this.isCurved = list.size() > 0
this.isCurved = !list.isEmpty()
&& this.shapeIterator != null
&& this.shapeIterator.isCurved();
}
Original file line number Diff line number Diff line change
@@ -328,7 +328,7 @@ protected void delayedInit(List<? extends Shape3ai<?, ?, IE, ?, ?, ?>> list) {
this.isPolyline = list.size() == 1
&& this.shapeIterator != null
&& this.shapeIterator.isPolyline();
this.isCurved = list.size() > 0
this.isCurved = !list.isEmpty()
&& this.shapeIterator != null
&& this.shapeIterator.isCurved();
}
Original file line number Diff line number Diff line change
@@ -271,7 +271,7 @@ protected final List<D> getInternalDataStructureForUserData() {
@Override
@Pure
public D getUserData() {
if ((this.data == null) || (this.data.size() == 0)) {
if ((this.data == null) || (this.data.isEmpty())) {
return null;
}
return this.data.get(0);
@@ -294,7 +294,7 @@ public D getUserDataAt(int index) throws IndexOutOfBoundsException {

@Override
public boolean addUserData(Collection<? extends D> data) {
if ((data == null) || (data.size() == 0)) {
if ((data == null) || (data.isEmpty())) {
return false;
}

@@ -315,7 +315,7 @@ public boolean addUserData(Collection<? extends D> data) {

@Override
public final boolean addUserData(int index, Collection<? extends D> data) {
if ((data == null) || (data.size() == 0)) {
if ((data == null) || (data.isEmpty())) {
return false;
}

@@ -346,11 +346,11 @@ public final void addUserData(int index, D data) {

@Override
public boolean removeUserData(Collection<D> data) {
if ((data == null) || (data.size() == 0) || (this.data == null)) {
if ((data == null) || (data.isEmpty()) || (this.data == null)) {
return false;
}
if (this.data.removeAll(data)) {
if (this.data.size() == 0) {
if (this.data.isEmpty()) {
this.data = null;
}
firePropertyDataChanged(data, null);
@@ -366,7 +366,7 @@ public final D removeUserData(int index) {
}
final D removedElement = this.data.remove(index);
if (removedElement != null) {
if (this.data.size() == 0) {
if (this.data.isEmpty()) {
this.data = null;
}
firePropertyDataChanged(Collections.singleton(removedElement), null);
@@ -396,7 +396,7 @@ public boolean setUserData(Collection<D> data) {

final List<D> oldData = this.data;

if ((data == null) || (data.size() == 0)) {
if ((data == null) || (data.isEmpty())) {
this.data = null;
} else {
this.data = new ArrayList<>(data);

0 comments on commit 59c0e6b

Please sign in to comment.