Skip to content

Commit c28bf85

Browse files
authored
Fixed Idea warnings
1 parent 45dead0 commit c28bf85

File tree

8 files changed

+50
-42
lines changed

8 files changed

+50
-42
lines changed

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Supported Versions
44

55
| Version | Supported |
6-
| ------- | ------------------ |
6+
|---------|--------------------|
77
| >= 1.70 | :white_check_mark: |
88
| < 1.70 | :x: |
99

pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,13 @@
162162
</excludes>
163163
</configuration>
164164
</plugin>
165+
<!--suppress MavenModelInspection -->
165166
<plugin>
166167
<groupId>org.apache.maven.plugins</groupId>
167168
<artifactId>maven-surefire-report-plugin</artifactId>
168169
<version>3.3.1</version>
169170
</plugin>
171+
<!--suppress MavenModelInspection -->
170172
<plugin>
171173
<groupId>org.apache.maven.plugins</groupId>
172174
<artifactId>maven-jxr-plugin</artifactId>
@@ -181,6 +183,7 @@
181183
<includeTestSourceDirectory>true</includeTestSourceDirectory>
182184
</configuration>
183185
</plugin>
186+
<!--suppress MavenModelInspection -->
184187
<plugin>
185188
<groupId>org.apache.maven.plugins</groupId>
186189
<artifactId>maven-pmd-plugin</artifactId>
@@ -203,11 +206,13 @@
203206
</rulesets>
204207
</configuration>
205208
</plugin>
209+
<!--suppress MavenModelInspection -->
206210
<plugin>
207211
<groupId>com.github.spotbugs</groupId>
208212
<artifactId>spotbugs-maven-plugin</artifactId>
209213
<version>4.8.6.2</version>
210214
</plugin>
215+
<!--suppress MavenModelInspection -->
211216
<plugin>
212217
<groupId>org.codehaus.mojo</groupId>
213218
<artifactId>taglist-maven-plugin</artifactId>

src/main/java/com/github/underscore/Json.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -695,22 +695,21 @@ private Number readNumber() {
695695
return result;
696696
}
697697

698-
private boolean readFraction() {
698+
private void readFraction() {
699699
if (!readChar('.')) {
700-
return false;
700+
return;
701701
}
702702
if (!readDigit()) {
703703
throw expected(DIGIT);
704704
}
705705
while (readDigit()) {
706706
// ignored
707707
}
708-
return true;
709708
}
710709

711-
private boolean readExponent() {
710+
private void readExponent() {
712711
if (!readChar('e') && !readChar('E')) {
713-
return false;
712+
return;
714713
}
715714
if (!readChar('+')) {
716715
readChar('-');
@@ -721,7 +720,6 @@ private boolean readExponent() {
721720
while (readDigit()) {
722721
// ignored
723722
}
724-
return true;
725723
}
726724

727725
private boolean readChar(char ch) {

src/main/java/com/github/underscore/Underscore.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1920,11 +1920,11 @@ public static List<Character> range(char start, char stop, int step) {
19201920
return list;
19211921
}
19221922
if (start < stop) {
1923-
for (char value = start; value < stop; value += step) {
1923+
for (char value = start; value < stop; value += (char) step) {
19241924
list.add(value);
19251925
}
19261926
} else {
1927-
for (char value = start; value > stop; value += step) {
1927+
for (char value = start; value > stop; value += (char) step) {
19281928
list.add(value);
19291929
}
19301930
}

src/test/java/com/github/underscore/CollectionsTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
*
5454
* @author Valentyn Kolesnikov
5555
*/
56+
@SuppressWarnings("java:S1186")
5657
class CollectionsTest {
5758

5859
/*
@@ -1718,7 +1719,9 @@ public Integer next() {
17181719
return array[index++];
17191720
}
17201721

1721-
public void remove() {}
1722+
@Override
1723+
public void remove() {
1724+
}
17221725
};
17231726
assertEquals(6, Underscore.size(iterable));
17241727
assertEquals(5, Underscore.size(new Integer[] {5, 4, 3, 2, 1}));

src/test/java/com/github/underscore/LodashTest.java

+30-24
Original file line numberDiff line numberDiff line change
@@ -616,20 +616,24 @@ void fetchGet() {
616616
"https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json");
617617
result.json();
618618
result.jsonMap();
619-
// assertEquals("{\"gameId\":483159,\"knight\":{\"name\":"
620-
// + "\"Sir. Russell Jones of
621-
// Alberta\",\"attack\":2,\"armor\":7,\"agility\":3,\"endurance\":8}}",
622-
// result.text());
623-
// assertEquals("Sir. Russell Jones of Alberta",
624-
// (String) Underscore.get((Map<String, Object>) result.json(), "knight.name"));
619+
assertEquals("{\n"
620+
+ " \"fruit\": \"Apple\",\n"
621+
+ " \"size\": \"Large\",\n"
622+
+ " \"color\": \"Red\"\n"
623+
+ "}",
624+
result.text());
625+
assertEquals("Apple",
626+
U.get((Map<String, Object>) result.json(), "fruit"));
625627
U.Chain<?> resultChain =
626628
U.chain(
627629
"https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json")
628630
.fetch();
629-
// assertEquals("{\"gameId\":483159,\"knight\":{\"name\":"
630-
// + "\"Sir. Russell Jones of
631-
// Alberta\",\"attack\":2,\"armor\":7,\"agility\":3,\"endurance\":8}}",
632-
// resultChain.item());
631+
assertEquals("{\n"
632+
+ " \"fruit\": \"Apple\",\n"
633+
+ " \"size\": \"Large\",\n"
634+
+ " \"color\": \"Red\"\n"
635+
+ "}",
636+
resultChain.item());
633637
U.chain(
634638
"https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json")
635639
.fetch();
@@ -662,10 +666,12 @@ void fetchGetWithTimeouts() {
662666
"https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json",
663667
30000,
664668
30000);
665-
// assertEquals("{\"gameId\":483159,\"knight\":{\"name\":"
666-
// + "\"Sir. Russell Jones of
667-
// Alberta\",\"attack\":2,\"armor\":7,\"agility\":3,\"endurance\":8}}",
668-
// result.text());
669+
assertEquals("{\n"
670+
+ " \"fruit\": \"Apple\",\n"
671+
+ " \"size\": \"Large\",\n"
672+
+ " \"color\": \"Red\"\n"
673+
+ "}",
674+
result.text());
669675
}
670676

671677
@Test
@@ -725,9 +731,7 @@ void fetchPut() {
725731
+ " \"fireBreath\": 10"
726732
+ " }"
727733
+ "}");
728-
// assertEquals("{\"status\":\"Victory\",\"message\":\"Dragon was successful in a
729-
// glorious battle\"}",
730-
// result.text());
734+
assertEquals(403, result.getStatus());
731735
U.FetchResponse result2 =
732736
U.fetch(
733737
"https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json",
@@ -743,10 +747,8 @@ void fetchPut() {
743747
null,
744748
null,
745749
null);
746-
// assertEquals("{\"status\":\"Defeat\",\"message\":"
747-
// + "\"No dragon showed up, knight dealt his deeds as he pleased.\"}",
748-
// result2.text());
749-
U.Chain resultChain =
750+
assertEquals(403, result2.getStatus());
751+
U.Chain<String> resultChain =
750752
U.chain(
751753
"http://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json")
752754
.fetch(
@@ -759,9 +761,13 @@ void fetchPut() {
759761
+ " \"fireBreath\": 10"
760762
+ " }"
761763
+ "}");
762-
// assertEquals("{\"status\":\"Victory\",\"message\":\"Dragon was successful in a
763-
// glorious battle\"}",
764-
// resultChain.item());
764+
assertEquals("<html>\n"
765+
+ "<head><title>301 Moved Permanently</title></head>\n"
766+
+ "<body>\n"
767+
+ "<center><h1>301 Moved Permanently</h1></center>\n"
768+
+ "<hr><center>cloudflare</center>\n"
769+
+ "</body>\n"
770+
+ "</html>\n", resultChain.item().replace("\r\n", "\n"));
765771
}
766772

767773
@Test

src/test/java/com/github/underscore/StringTest.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -3569,16 +3569,12 @@ void fromXmlStackoverflowObject() throws IOException {
35693569
}
35703570

35713571
private String repeat(String s, int times) {
3572-
StringBuilder stringBuilder = new StringBuilder(s.length() * times);
3573-
for (int i = 0; i < times; i++) {
3574-
stringBuilder.append(s);
3575-
}
3576-
return stringBuilder.toString();
3572+
return s.repeat(Math.max(0, times));
35773573
}
35783574

35793575
@SuppressWarnings("unchecked")
35803576
@Test
3581-
void testParseDeeplyNestedArrays() throws IOException {
3577+
void testParseDeeplyNestedArrays() {
35823578
int times = 1000;
35833579
// [[[ ... ]]]
35843580
String json = repeat("[", times) + repeat("]", times);
@@ -3598,7 +3594,7 @@ void testParseDeeplyNestedArrays() throws IOException {
35983594

35993595
@SuppressWarnings("unchecked")
36003596
@Test
3601-
void testParseDeeplyNestedObjects() throws IOException {
3597+
void testParseDeeplyNestedObjects() {
36023598
int times = 1000;
36033599
// {"a":{"a": ... {"a":null} ... }}
36043600
String json = repeat("{\"a\":", times) + "null" + repeat("}", times);

src/test/java/com/github/underscore/UnderscoreTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ void testPropertiesToMapWithEmptyProperties() {
792792
Map<String, Object> map = U.propertiesToMap(properties);
793793
assertEquals(0, map.size());
794794
Map<String, Object> map2 = U.propertiesToMap(null);
795-
assertEquals(0, map.size());
795+
assertEquals(0, map2.size());
796796
}
797797

798798
@Test

0 commit comments

Comments
 (0)