Skip to content

Commit b203333

Browse files
committed
Sonar fix
1 parent bbecb32 commit b203333

File tree

5 files changed

+28
-26
lines changed

5 files changed

+28
-26
lines changed

abstract-document/src/main/java/com/iluwatar/abstractdocument/AbstractDocument.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ private String buildStringRepresentation() {
7575
builder.append(getClass().getName()).append("[");
7676

7777
// Explaining variable for document properties map
78-
Map<String, Object> documentProperties = this.documentProperties;
78+
Map<String, Object> mpdocumentProperties = this.documentProperties;
7979

8080
// Explaining variable for the size of document properties map
81-
int numProperties = documentProperties.size();
81+
int numProperties = mpdocumentProperties.size();
8282

8383
// Explaining variable for tracking the current property index
8484
int currentPropertyIndex = 0;
8585

8686
// Iterate over document properties map
87-
for (Map.Entry<String, Object> entry : documentProperties.entrySet()) {
87+
for (Map.Entry<String, Object> entry : mpdocumentProperties.entrySet()) {
8888
String key = entry.getKey();
8989
Object value = entry.getValue();
9090

abstract-document/src/test/java/com/iluwatar/abstractdocument/AbstractDocumentTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ void shouldRetrieveEmptyStreamForNonExistingChildren() {
7575
@Test
7676
void shouldIncludePropsInToString() {
7777
var props = Map.of(KEY, (Object) VALUE);
78-
var document = new DocumentImplementation(props);
79-
assertTrue(document.toString().contains(KEY));
80-
assertTrue(document.toString().contains(VALUE));
78+
var varDocument = new DocumentImplementation(props);
79+
assertTrue(varDocument.toString().contains(KEY));
80+
assertTrue(varDocument.toString().contains(VALUE));
8181
}
8282

8383
@Test

anti-corruption-layer/src/main/java/com/iluwatar/corruption/system/DataStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
public abstract class DataStore<V> {
3535
private final HashMap<String, V> inner;
3636

37-
public DataStore() {
37+
protected DataStore() {
3838
inner = new HashMap<>();
3939
}
4040

serialized-lob/src/main/java/com/iluwatar/slob/dbservice/DatabaseService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void startupService()
9292
throws SQLException {
9393
try (var connection = dataSource.getConnection();
9494
var statement = connection.createStatement()) {
95-
if (dataTypeDb.equals("BINARY")) {
95+
if (dataTypeDb.equals(BINARY_DATA)) {
9696
statement.execute(CREATE_BINARY_SCHEMA_DDL);
9797
} else {
9898
statement.execute(CREATE_TEXT_SCHEMA_DDL);

type-object/src/main/java/com/iluwatar/typeobject/CandyGame.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,47 +79,49 @@ void printGameStatus() {
7979

8080
List<Cell> adjacentCells(int y, int x) {
8181
var adjacent = new ArrayList<Cell>();
82-
if (y == 0) {
82+
if (y == 0 && cells.length > 0) {
8383
adjacent.add(this.cells[1][x]);
8484
}
85-
if (x == 0) {
85+
if (x == 0 & cells.length > 0) {
8686
adjacent.add(this.cells[y][1]);
8787
}
88-
if (y == cells.length - 1) {
88+
if ((cells.length > 0) && (y == cells.length - 1)) {
8989
adjacent.add(this.cells[cells.length - 2][x]);
9090
}
91-
if (x == cells.length - 1) {
91+
if ((cells.length > 0) && (x == cells.length - 1)) {
9292
adjacent.add(this.cells[y][cells.length - 2]);
9393
}
94-
if (y > 0 && y < cells.length - 1) {
94+
if ((cells.length > 0) && y > 0 && y < cells.length - 1) {
9595
adjacent.add(this.cells[y - 1][x]);
9696
adjacent.add(this.cells[y + 1][x]);
9797
}
98-
if (x > 0 && x < cells.length - 1) {
98+
if ((cells.length > 0) && x > 0 && x < cells.length - 1) {
9999
adjacent.add(this.cells[y][x - 1]);
100100
adjacent.add(this.cells[y][x + 1]);
101101
}
102102
return adjacent;
103103
}
104104

105105
boolean continueRound() {
106-
for (var i = 0; i < this.cells.length; i++) {
107-
if (this.cells[cells.length - 1][i].candy.getType().equals(Type.REWARD_FRUIT)) {
108-
return true;
106+
if(this.cells.length >0) {
107+
for (var i = 0; i < this.cells.length; i++) {
108+
if (this.cells[cells.length - 1][i].candy.getType().equals(Type.REWARD_FRUIT)) {
109+
return true;
110+
}
109111
}
110-
}
111-
for (var i = 0; i < this.cells.length; i++) {
112-
for (var j = 0; j < this.cells.length; j++) {
113-
if (!this.cells[i][j].candy.getType().equals(Type.REWARD_FRUIT)) {
114-
var adj = adjacentCells(i, j);
115-
for (Cell cell : adj) {
116-
if (this.cells[i][j].candy.name.equals(cell.candy.name)) {
117-
return true;
112+
for (var i = 0; i < this.cells.length; i++) {
113+
for (var j = 0; j < this.cells.length; j++) {
114+
if (!this.cells[i][j].candy.getType().equals(Type.REWARD_FRUIT)) {
115+
var adj = adjacentCells(i, j);
116+
for (Cell cell : adj) {
117+
if (this.cells[i][j].candy.name.equals(cell.candy.name)) {
118+
return true;
119+
}
118120
}
119121
}
120122
}
121-
}
122123
}
124+
}
123125
return false;
124126
}
125127

0 commit comments

Comments
 (0)