Skip to content

Commit d93c254

Browse files
committed
Sync with underscore-java.
1 parent be1483c commit d93c254

File tree

12 files changed

+84
-66
lines changed

12 files changed

+84
-66
lines changed

pom-pack.xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,25 @@
100100
<option>-keep public class com.github.underscore.Trie { *; }</option>
101101
<option>-keep public class com.github.underscore.Trie$TrieNode { *; }</option>
102102
<option>-keep public class com.github.underscore.Tuple { *; }</option>
103-
<option>-keep public class com.github.underscore.lodash.Base32 { *; }</option>
104-
<option>-keep public class com.github.underscore.lodash.Json { *; }</option>
105-
<option>-keep public class com.github.underscore.lodash.U { *; }</option>
106-
<option>-keep public class com.github.underscore.lodash.U$Fetch { *; }</option>
107-
<option>-keep public class com.github.underscore.lodash.Xml { *; }</option>
108-
<option>-keep public class com.github.underscore.lodash.*$Chain { *; }</option>
109-
<option>-keep public class com.github.underscore.lodash.*$ParseException { *; }</option>
110-
<option>-keep public class com.github.underscore.lodash.*$FetchResponse { *; }</option>
111-
<option>-keep public class com.github.underscore.lodash.*$LRUCache { *; }</option>
112-
<option>-keep public class com.github.underscore.lodash.*$Mode { *; }</option>
113-
<option>-keep public class com.github.underscore.lodash.*$Builder { *; }</option>
114-
<option>-keep public class com.github.underscore.lodash.*$ArrayBuilder { *; }</option>
115-
<option>-keep public class com.github.underscore.lodash.Json$JsonStringBuilder$Step { *; }</option>
116-
<option>-keep public class com.github.underscore.lodash.Xml$XmlStringBuilder$Step { *; }</option>
117-
<option>-keep public class com.github.underscore.lodash.Xml$XmlStringBuilder { *; }</option>
118-
<option>-keep public class com.github.underscore.lodash.Xml$FromType { *; }</option>
103+
<option>-keep public class com.github.underscore.Base32 { *; }</option>
104+
<option>-keep public class com.github.underscore.Json { *; }</option>
105+
<option>-keep public class com.github.underscore.U { *; }</option>
106+
<option>-keep public class com.github.underscore.U$Fetch { *; }</option>
107+
<option>-keep public class com.github.underscore.Xml { *; }</option>
108+
<option>-keep public class com.github.underscore.*$Chain { *; }</option>
109+
<option>-keep public class com.github.underscore.*$ParseException { *; }</option>
110+
<option>-keep public class com.github.underscore.*$FetchResponse { *; }</option>
111+
<option>-keep public class com.github.underscore.*$LRUCache { *; }</option>
112+
<option>-keep public class com.github.underscore.*$Mode { *; }</option>
113+
<option>-keep public class com.github.underscore.*$Builder { *; }</option>
114+
<option>-keep public class com.github.underscore.*$ArrayBuilder { *; }</option>
115+
<option>-keep public class com.github.underscore.Json$JsonStringBuilder$Step { *; }</option>
116+
<option>-keep public class com.github.underscore.Xml$XmlStringBuilder$Step { *; }</option>
117+
<option>-keep public class com.github.underscore.Xml$XmlStringBuilder { *; }</option>
118+
<option>-keep public class com.github.underscore.Xml$FromType { *; }</option>
119119
<option>-keepclassmembers class * { *** newArrayList(); *** newLinkedHashSet(); *** newHashSet(java.lang.Iterable); *** newLinkedHashMap(); }</option>
120120
<option>-dontnote com.github.underscore.*$ClassForName</option>
121-
<option>-dontnote com.github.underscore.lodash.*$OperationType</option>
121+
<option>-dontnote com.github.underscore.*$OperationType</option>
122122
</options>
123123
<libs>
124124
<lib>${java.home.openjdk11}/lib/jrt-fs.jar</lib>

pom-pack17.xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,25 @@
100100
<option>-keep public class com.github.underscore.Trie { *; }</option>
101101
<option>-keep public class com.github.underscore.Trie$TrieNode { *; }</option>
102102
<option>-keep public class com.github.underscore.Tuple { *; }</option>
103-
<option>-keep public class com.github.underscore.lodash.Base32 { *; }</option>
104-
<option>-keep public class com.github.underscore.lodash.Json { *; }</option>
105-
<option>-keep public class com.github.underscore.lodash.U { *; }</option>
106-
<option>-keep public class com.github.underscore.lodash.U$Fetch { *; }</option>
107-
<option>-keep public class com.github.underscore.lodash.Xml { *; }</option>
108-
<option>-keep public class com.github.underscore.lodash.*$Chain { *; }</option>
109-
<option>-keep public class com.github.underscore.lodash.*$ParseException { *; }</option>
110-
<option>-keep public class com.github.underscore.lodash.*$FetchResponse { *; }</option>
111-
<option>-keep public class com.github.underscore.lodash.*$LRUCache { *; }</option>
112-
<option>-keep public class com.github.underscore.lodash.*$Mode { *; }</option>
113-
<option>-keep public class com.github.underscore.lodash.*$Builder { *; }</option>
114-
<option>-keep public class com.github.underscore.lodash.*$ArrayBuilder { *; }</option>
115-
<option>-keep public class com.github.underscore.lodash.Json$JsonStringBuilder$Step { *; }</option>
116-
<option>-keep public class com.github.underscore.lodash.Xml$XmlStringBuilder$Step { *; }</option>
117-
<option>-keep public class com.github.underscore.lodash.Xml$XmlStringBuilder { *; }</option>
118-
<option>-keep public class com.github.underscore.lodash.Xml$FromType { *; }</option>
103+
<option>-keep public class com.github.underscore.Base32 { *; }</option>
104+
<option>-keep public class com.github.underscore.Json { *; }</option>
105+
<option>-keep public class com.github.underscore.U { *; }</option>
106+
<option>-keep public class com.github.underscore.U$Fetch { *; }</option>
107+
<option>-keep public class com.github.underscore.Xml { *; }</option>
108+
<option>-keep public class com.github.underscore.*$Chain { *; }</option>
109+
<option>-keep public class com.github.underscore.*$ParseException { *; }</option>
110+
<option>-keep public class com.github.underscore.*$FetchResponse { *; }</option>
111+
<option>-keep public class com.github.underscore.*$LRUCache { *; }</option>
112+
<option>-keep public class com.github.underscore.*$Mode { *; }</option>
113+
<option>-keep public class com.github.underscore.*$Builder { *; }</option>
114+
<option>-keep public class com.github.underscore.*$ArrayBuilder { *; }</option>
115+
<option>-keep public class com.github.underscore.Json$JsonStringBuilder$Step { *; }</option>
116+
<option>-keep public class com.github.underscore.Xml$XmlStringBuilder$Step { *; }</option>
117+
<option>-keep public class com.github.underscore.Xml$XmlStringBuilder { *; }</option>
118+
<option>-keep public class com.github.underscore.Xml$FromType { *; }</option>
119119
<option>-keepclassmembers class * { *** newArrayList(); *** newLinkedHashSet(); *** newHashSet(java.lang.Iterable); *** newLinkedHashMap(); }</option>
120120
<option>-dontnote com.github.underscore.*$ClassForName</option>
121-
<option>-dontnote com.github.underscore.lodash.*$OperationType</option>
121+
<option>-dontnote com.github.underscore.*$OperationType</option>
122122
</options>
123123
<libs>
124124
<lib>${java.home.openjdk17}/lib/jrt-fs.jar</lib>

src/main/java/com/github/underscore/lodash/Base32.java renamed to src/main/java/com/github/underscore/Base32.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
package com.github.underscore.lodash;
24+
package com.github.underscore;
2525

2626
import java.nio.charset.StandardCharsets;
2727
import java.util.HashMap;

src/main/java/com/github/underscore/lodash/Json.java renamed to src/main/java/com/github/underscore/Json.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
package com.github.underscore.lodash;
24+
package com.github.underscore;
2525

2626
import java.util.Collection;
2727
import java.util.Iterator;
2828
import java.util.List;
2929
import java.util.Map;
3030
import java.util.StringJoiner;
3131

32-
@SuppressWarnings("java:S3740")
32+
@SuppressWarnings({"java:S3740", "java:S3776"})
3333
public final class Json {
3434
private Json() {}
3535

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public boolean equals(final Object o) {
101101
return false;
102102
}
103103

104-
final Optional<?> optional = (Optional) o;
104+
final Optional<?> optional = (Optional<?>) o;
105105

106106
return absent == optional.absent && Objects.equals(arg, optional.arg);
107107
}

src/main/java/com/github/underscore/lodash/U.java renamed to src/main/java/com/github/underscore/U.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
package com.github.underscore.lodash;
24+
package com.github.underscore;
2525

26-
import com.github.underscore.Function3;
27-
import com.github.underscore.Optional;
28-
import com.github.underscore.PredicateIndexed;
29-
import com.github.underscore.Tuple;
30-
import com.github.underscore.Underscore;
3126
import java.io.File;
3227
import java.io.FileInputStream;
3328
import java.io.FileOutputStream;
@@ -59,7 +54,15 @@
5954
import java.util.function.Predicate;
6055
import java.util.zip.GZIPInputStream;
6156

62-
@SuppressWarnings({"java:S1168", "java:S3740", "java:S3776", "java:S5843"})
57+
@SuppressWarnings({
58+
"java:S1168",
59+
"java:S3740",
60+
"java:S3776",
61+
"java:S4423",
62+
"java:S4830",
63+
"java:S5843",
64+
"java:S5998"
65+
})
6366
public class U<T> extends Underscore<T> {
6467
private static final int DEFAULT_TRUNC_LENGTH = 30;
6568
private static final String DEFAULT_TRUNC_OMISSION = "...";
@@ -1590,8 +1593,13 @@ public static boolean startsWith(
15901593
final String localString = baseToString(string);
15911594

15921595
final int length = localString.length();
1593-
final int localPosition =
1594-
position == null ? 0 : Math.min(position < 0 ? 0 : position, length);
1596+
final int localPosition;
1597+
if (position == null) {
1598+
localPosition = 0;
1599+
} else {
1600+
final int from = position < 0 ? 0 : position;
1601+
localPosition = Math.min(from, length);
1602+
}
15951603

15961604
return localString.lastIndexOf(target, localPosition) == localPosition;
15971605
}

src/main/java/com/github/underscore/lodash/Xml.java renamed to src/main/java/com/github/underscore/Xml.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
package com.github.underscore.lodash;
24+
package com.github.underscore;
2525

2626
import static java.nio.charset.StandardCharsets.UTF_8;
2727

@@ -36,7 +36,17 @@
3636
import java.util.function.BiFunction;
3737
import java.util.function.Function;
3838

39-
@SuppressWarnings({"java:S107", "java:S3740", "java:S3776", "java:S4276"})
39+
@SuppressWarnings({
40+
"java:S107",
41+
"java:S3740",
42+
"java:S3776",
43+
"java:S4276",
44+
"java:S5843",
45+
"java:S5852",
46+
"java:S5998",
47+
"java:S6019",
48+
"java:S6035"
49+
})
4050
public final class Xml {
4151
private Xml() {}
4252

@@ -1519,9 +1529,7 @@ private static String unescapeName(final String name) {
15191529
try {
15201530
result.append(Base32.decode(nameToDecode.toString()));
15211531
} catch (Base32.DecodingException ex) {
1522-
result.append("__")
1523-
.append(nameToDecode)
1524-
.append(lastChars);
1532+
result.append("__").append(nameToDecode).append(lastChars);
15251533
}
15261534
i = j;
15271535
underlineCount = 0;
@@ -1740,17 +1748,21 @@ private static org.w3c.dom.Document createDocument() {
17401748
final javax.xml.parsers.DocumentBuilderFactory factory =
17411749
javax.xml.parsers.DocumentBuilderFactory.newInstance();
17421750
factory.setNamespaceAware(true);
1743-
try {
1744-
factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
1745-
} catch (Exception ignored) {
1746-
// ignored
1747-
}
1751+
setupFactory(factory);
17481752
final javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder();
17491753
return builder.newDocument();
17501754
} catch (javax.xml.parsers.ParserConfigurationException ex) {
17511755
return null;
17521756
}
17531757
}
1758+
1759+
private static void setupFactory(javax.xml.parsers.DocumentBuilderFactory factory) {
1760+
try {
1761+
factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
1762+
} catch (Exception ignored) {
1763+
// ignored
1764+
}
1765+
}
17541766
}
17551767

17561768
public static Object fromXmlMakeArrays(final String xml) {

src/test/java/com/github/underscore/lodash/Base32Test.java renamed to src/test/java/com/github/underscore/Base32Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
package com.github.underscore.lodash;
24+
package com.github.underscore;
2525

2626
import static org.junit.jupiter.api.Assertions.assertEquals;
2727
import static org.junit.jupiter.api.Assertions.assertThrows;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ void chainMap() {
627627
"{name1=one, name2=two, 1=2}",
628628
com.github
629629
.underscore
630-
.lodash
631630
.U
632631
.chain(
633632
new LinkedHashMap<String, Object>() {
@@ -643,7 +642,6 @@ void chainMap() {
643642
"{name1=one, name2=two, 1=2}",
644643
com.github
645644
.underscore
646-
.lodash
647645
.U
648646
.of(
649647
new LinkedHashMap<String, Object>() {

src/test/java/com/github/underscore/lodash/LodashTest.java renamed to src/test/java/com/github/underscore/LodashTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
package com.github.underscore.lodash;
24+
package com.github.underscore;
2525

2626
import static java.util.Arrays.asList;
2727
import static java.util.Collections.singletonList;
@@ -51,6 +51,7 @@
5151
*
5252
* @author Valentyn Kolesnikov
5353
*/
54+
@SuppressWarnings("java:S2699")
5455
class LodashTest {
5556

5657
/*

0 commit comments

Comments
 (0)