Skip to content

Commit 2fae614

Browse files
authored
Sync with underscore.
1 parent 1afc4be commit 2fae614

25 files changed

+1130
-935
lines changed

azure-pipelines.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
# Maven
2-
# Build your Java project and run tests with Apache Maven.
3-
# Add steps that analyze code, save build artifacts, deploy, and more:
4-
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
5-
6-
trigger:
7-
- master
1+
# Starter pipeline
2+
# Start with a minimal pipeline that you can customize to build and deploy your code.
3+
# Add steps that build, run tests, deploy, and more:
4+
# https://aka.ms/yaml
85

96
pool:
10-
vmImage: 'Ubuntu-16.04'
7+
vmImage: 'Ubuntu 18.04'
118

129
steps:
1310
- task: Maven@3
@@ -17,6 +14,7 @@ steps:
1714
javaHomeOption: 'JDKVersion'
1815
jdkVersionOption: '1.11'
1916
jdkArchitectureOption: 'x64'
20-
publishJUnitResults: false
21-
testResultsFiles: '**/surefire-reports/TEST-*.xml'
22-
goals: 'package'
17+
publishJUnitResults: true
18+
testResultsFiles: '**/TEST-*.xml'
19+
goals: 'test'
20+

pom-central.xml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@
4949
<encoding>UTF-8</encoding>
5050
</configuration>
5151
</plugin>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-surefire-plugin</artifactId>
55+
<version>3.0.0-M5</version>
56+
<dependencies>
57+
<dependency>
58+
<groupId>org.junit.jupiter</groupId>
59+
<artifactId>junit-jupiter-engine</artifactId>
60+
<version>[5.8.2,)</version>
61+
</dependency>
62+
</dependencies>
63+
</plugin>
5264
<plugin>
5365
<groupId>org.apache.maven.plugins</groupId>
5466
<artifactId>maven-jar-plugin</artifactId>
@@ -108,9 +120,9 @@
108120
</build>
109121
<dependencies>
110122
<dependency>
111-
<groupId>junit</groupId>
112-
<artifactId>junit</artifactId>
113-
<version>[4.13.2,)</version>
123+
<groupId>org.junit.jupiter</groupId>
124+
<artifactId>junit-jupiter-api</artifactId>
125+
<version>[5.8.2,)</version>
114126
<scope>test</scope>
115127
</dependency>
116128
<dependency>

pom-pack.xml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@
5050
<encoding>UTF-8</encoding>
5151
</configuration>
5252
</plugin>
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-surefire-plugin</artifactId>
56+
<version>3.0.0-M5</version>
57+
<dependencies>
58+
<dependency>
59+
<groupId>org.junit.jupiter</groupId>
60+
<artifactId>junit-jupiter-engine</artifactId>
61+
<version>[5.8.2,)</version>
62+
</dependency>
63+
</dependencies>
64+
</plugin>
5365
<plugin>
5466
<groupId>org.apache.maven.plugins</groupId>
5567
<artifactId>maven-jar-plugin</artifactId>
@@ -91,6 +103,7 @@
91103
<option>-keep public class com.github.underscore.lodash.Base32 { *; }</option>
92104
<option>-keep public class com.github.underscore.lodash.Json { *; }</option>
93105
<option>-keep public class com.github.underscore.lodash.U { *; }</option>
106+
<option>-keep public class com.github.underscore.lodash.U$Fetch { *; }</option>
94107
<option>-keep public class com.github.underscore.lodash.Xml { *; }</option>
95108
<option>-keep public class com.github.underscore.lodash.*$Chain { *; }</option>
96109
<option>-keep public class com.github.underscore.lodash.*$ParseException { *; }</option>
@@ -233,9 +246,9 @@
233246
</build>
234247
<dependencies>
235248
<dependency>
236-
<groupId>junit</groupId>
237-
<artifactId>junit</artifactId>
238-
<version>[4.13.2,)</version>
249+
<groupId>org.junit.jupiter</groupId>
250+
<artifactId>junit-jupiter-api</artifactId>
251+
<version>[5.8.2,)</version>
239252
<scope>test</scope>
240253
</dependency>
241254
<dependency>

pom.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@
5252
</compilerArgs>
5353
</configuration>
5454
</plugin>
55+
<plugin>
56+
<groupId>org.apache.maven.plugins</groupId>
57+
<artifactId>maven-surefire-plugin</artifactId>
58+
<version>3.0.0-M5</version>
59+
<dependencies>
60+
<dependency>
61+
<groupId>org.junit.jupiter</groupId>
62+
<artifactId>junit-jupiter-engine</artifactId>
63+
<version>[5.8.2,)</version>
64+
</dependency>
65+
</dependencies>
66+
</plugin>
5567
<plugin>
5668
<groupId>org.apache.maven.plugins</groupId>
5769
<artifactId>maven-jar-plugin</artifactId>
@@ -112,6 +124,7 @@
112124
<excludes>
113125
<exclude>**/U$BaseHttpSslSocketFactory*.class</exclude>
114126
<exclude>**/Xml$Document.class</exclude>
127+
<exclude>**/U$Fetch.class</exclude>
115128
</excludes>
116129
</configuration>
117130
</plugin>
@@ -137,6 +150,7 @@
137150
<excludes>
138151
<exclude>**/U$BaseHttpSslSocketFactory*.class</exclude>
139152
<exclude>**/Xml$Document.class</exclude>
153+
<exclude>**/U$Fetch.class</exclude>
140154
</excludes>
141155
</configuration>
142156
</plugin>
@@ -195,9 +209,9 @@
195209
</reporting>
196210
<dependencies>
197211
<dependency>
198-
<groupId>junit</groupId>
199-
<artifactId>junit</artifactId>
200-
<version>[4.13.2,)</version>
212+
<groupId>org.junit.jupiter</groupId>
213+
<artifactId>junit-jupiter-api</artifactId>
214+
<version>[5.8.2,)</version>
201215
<scope>test</scope>
202216
</dependency>
203217
<dependency>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public boolean isPresent() {
6262
return !absent;
6363
}
6464

65-
@SuppressWarnings("unchecked")
6665
public Optional<T> filter(Predicate<? super T> predicate) {
6766
Underscore.checkNotNull(predicate);
6867
if (isPresent()) {

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
*
6161
* @author Valentyn Kolesnikov
6262
*/
63+
@SuppressWarnings("java:S3740")
6364
public class Underscore<T> {
6465
private static final Map<String, Function<String, String>> FUNCTIONS = newLinkedHashMap();
6566
private static final Map<String, String> TEMPLATE_SETTINGS = new HashMap<>();
@@ -139,6 +140,7 @@ public boolean test(final E elem) {
139140
return false;
140141
}
141142
} catch (Exception ignored) {
143+
// ignored
142144
}
143145
}
144146
}
@@ -266,7 +268,9 @@ public T next() {
266268
}
267269

268270
@Override
269-
public void remove() {}
271+
public void remove() {
272+
// ignored
273+
}
270274
};
271275
}
272276
}
@@ -774,18 +778,23 @@ public static <E> List<E> invoke(
774778
.getClass()
775779
.getMethod(methodName, argTypes.toArray(new Class[0]));
776780
for (E arg : iterable) {
777-
try {
778-
result.add((E) method.invoke(arg, args.toArray(new Object[0])));
779-
} catch (Exception e) {
780-
throw new IllegalArgumentException(e);
781-
}
781+
doInvoke(args, result, method, arg);
782782
}
783783
} catch (NoSuchMethodException e) {
784784
throw new IllegalArgumentException(e);
785785
}
786786
return result;
787787
}
788788

789+
@SuppressWarnings("unchecked")
790+
private static <E> void doInvoke(List<Object> args, List<E> result, Method method, E arg) {
791+
try {
792+
result.add((E) method.invoke(arg, args.toArray(new Object[0])));
793+
} catch (Exception e) {
794+
throw new IllegalArgumentException(e);
795+
}
796+
}
797+
789798
public List<T> invoke(final String methodName, final List<Object> args) {
790799
return invoke(iterable, methodName, args);
791800
}
@@ -1165,7 +1174,6 @@ public static <E> int size(final E... array) {
11651174
return array.length;
11661175
}
11671176

1168-
@SuppressWarnings("unchecked")
11691177
public static <E> List<List<E>> partition(final Iterable<E> iterable, final Predicate<E> pred) {
11701178
final List<E> retVal1 = newArrayList();
11711179
final List<E> retVal2 = newArrayList();
@@ -2880,7 +2888,7 @@ public Chain<T> compact(final T falsyValue) {
28802888

28812889
@SuppressWarnings("unchecked")
28822890
public Chain flatten() {
2883-
return new Chain(Underscore.flatten(list));
2891+
return new Chain<>(Underscore.flatten(list));
28842892
}
28852893

28862894
public <F> Chain<F> map(final Function<? super T, F> func) {
@@ -3246,7 +3254,7 @@ public String toString() {
32463254
/*
32473255
* Documented, #mixin
32483256
*/
3249-
public static void mixin(final String funcName, final Function<String, String> func) {
3257+
public static void mixin(final String funcName, final UnaryOperator<String> func) {
32503258
FUNCTIONS.put(funcName, func);
32513259
}
32523260

0 commit comments

Comments
 (0)