Skip to content

Commit

Permalink
Closes #2459: Fix Code Smells
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrdi committed Jan 23, 2024
1 parent 03683ce commit a9b7a23
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 32 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/continuous-integration.yml
Expand Up @@ -44,6 +44,8 @@ jobs:
with:
distribution: adopt
java-version: ${{ env.JAVA_VERSION }}
- name: Print Java version
run: java -version
- name: Cache maven dependencies
id: cache
uses: actions/cache@v4
Expand All @@ -54,7 +56,9 @@ jobs:
- name: Change versions to match tag
run: ci/change_version.sh -m .
- name: Compile & build
run: ./mvnw -B install -DskipTests -Dasciidoctor.skip -Djacoco.skip
run: ./mvnw clean -B -e -X install -DskipTests -Dasciidoctor.skip -Djacoco.skip
- name: Print Compilation Command
run: mvn clean compile -X
- name: Populate cache
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down
Expand Up @@ -13,7 +13,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.sql.DataSource;
import org.apache.ibatis.jdbc.RuntimeSqlException;
Expand Down Expand Up @@ -78,9 +77,7 @@ public void dropDb() {
private List<String> parseScripts(Stream<String> scripts) {
try (Connection connection = dataSource.getConnection()) {
DB db = DB.getDB(connection);
return scripts
.map(script -> SqlReplacer.getScriptAsSql(db, now, script))
.collect(Collectors.toList());
return scripts.map(script -> SqlReplacer.getScriptAsSql(db, now, script)).toList();
} catch (SQLException e) {
throw new RuntimeSqlException("Connection to database failed.", e);
}
Expand Down
4 changes: 2 additions & 2 deletions common/taskana-common-logging/pom.xml
Expand Up @@ -53,9 +53,9 @@
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${version.aspectj-maven-plugin}</version>
<version>1.13.1</version>
<configuration>
<aspectLibraries combine.self="override"/>
</configuration>
Expand Down
Expand Up @@ -10,7 +10,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.security.auth.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -61,7 +60,7 @@ public List<String> getGroupIds() {
.map(Principal::getName)
.filter(Objects::nonNull)
.map(this::convertAccessId)
.collect(Collectors.toList());
.toList();
}
LOGGER.trace("No groupIds found in subject!");
return Collections.emptyList();
Expand Down
Expand Up @@ -111,7 +111,7 @@ public <T> T interceptTestFactoryMethod(
newChildrenForDynamicContainer = Collections.singleton((DynamicNode) factoryResult);
} else if (factoryResult instanceof Stream) {
Stream<DynamicNode> nodes = (Stream<DynamicNode>) factoryResult;
newChildrenForDynamicContainer = nodes.collect(Collectors.toList());
newChildrenForDynamicContainer = nodes.toList();
} else if (factoryResult instanceof Iterable) {
newChildrenForDynamicContainer = (Iterable<DynamicNode>) factoryResult;
} else if (factoryResult instanceof Iterator) {
Expand Down Expand Up @@ -142,8 +142,11 @@ public <T> T interceptTestFactoryMethod(
Store store = getMethodLevelStore(extensionContext);
return (T)
Stream.of(annotation.value())
.peek(a -> store.put(ACCESS_IDS_STORE_KEY, a))
.map(wrapTestsInDynamicContainer);
.map(
a -> {
store.put(ACCESS_IDS_STORE_KEY, a);
return wrapTestsInDynamicContainer.apply(a);
});
}

return extractAccessIdAndPerformInvocation(invocation, invocationContext.getExecutable());
Expand Down Expand Up @@ -207,8 +210,11 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
AnnotationSupport.findRepeatableAnnotations(context.getElement(), WithAccessId.class);
Store store = getMethodLevelStore(context);
return accessIds.stream()
.peek(a -> store.put(ACCESS_IDS_STORE_KEY, a))
.map(JaasExtensionInvocationContext::new);
.map(
a -> {
store.put(ACCESS_IDS_STORE_KEY, a);
return new JaasExtensionInvocationContext(a);
});
}

// endregion
Expand Down Expand Up @@ -259,7 +265,7 @@ private static List<Principal> getPrincipals(WithAccessId withAccessId) {
return Stream.concat(
Stream.of(withAccessId.user()).map(UserPrincipal::new),
Arrays.stream(withAccessId.groups()).map(GroupPrincipal::new))
.collect(Collectors.toList());
.toList();
}
return Collections.emptyList();
}
Expand Down
Expand Up @@ -64,9 +64,9 @@ public boolean run() throws SQLException {
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(outWriter.toString());
}
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
return false;
}
Expand Down
Expand Up @@ -8,7 +8,6 @@
import java.util.Optional;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.internal.util.ReflectionUtil;

Expand Down Expand Up @@ -43,6 +42,6 @@ protected static List<String> splitStringAndTrimElements(String str, String sepa
return Arrays.stream(str.split(Pattern.quote(separator)))
.filter(not(String::isEmpty))
.map(String::trim)
.collect(Collectors.toList());
.toList();
}
}
Expand Up @@ -199,7 +199,8 @@ public int hashCode() {

@Override
public boolean equals(Object o) {
return (o instanceof ComparableVersion) && items.equals(((ComparableVersion) o).items);
return (o instanceof ComparableVersion comparableVersion)
&& items.equals(comparableVersion.items);
}

@Override
Expand Down Expand Up @@ -436,6 +437,7 @@ private static class StringItem implements Item {
Arrays.asList("alpha", "beta", "milestone", "rc", "snapshot", "", "sp");

private static final Properties ALIASES = new Properties();

/**
* A comparable value for the empty-string qualifier. This one is used to determine if a given
* qualifier makes the version older than one without a qualifier, or more recent.
Expand Down
3 changes: 1 addition & 2 deletions mvnw
Expand Up @@ -32,7 +32,7 @@
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------

rm -rf ~/.m2/repository/org/aspectj
if [ -z "$MAVEN_SKIP_RC" ] ; then

if [ -f /usr/local/etc/mavenrc ] ; then
Expand Down Expand Up @@ -68,7 +68,6 @@ case "$(uname)" in
fi
;;
esac

if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=$(java-config --jre-home)
Expand Down
8 changes: 3 additions & 5 deletions pom.xml
Expand Up @@ -120,9 +120,7 @@
<sonar.sources>src/main/java</sonar.sources>
<sonar.tests>src/test/java</sonar.tests>
<sonar.exclusions>
org/camunda/bpm/dmn/**/*,
**/example/**/*,
**/*Example*
org/camunda/bpm/dmn/**/*, **/example/**/*, **/*Example*
</sonar.exclusions>
</properties>

Expand Down Expand Up @@ -376,9 +374,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${version.aspectj-maven-plugin}</version>
<version>1.13.1</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
Expand Down
5 changes: 3 additions & 2 deletions routing/dmn-xlsx-converter/pom.xml
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>
<groupId>pro.taskana.camunda.bpm.extension.dmn</groupId>
<artifactId>dmn-xlsx-converter</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>

<parent>
<groupId>pro.taskana</groupId>
Expand Down Expand Up @@ -70,8 +70,9 @@
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.1</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down
4 changes: 2 additions & 2 deletions web/pom.xml
Expand Up @@ -45,9 +45,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${version.aspectj-maven-plugin}</version>
<version>1.13.1</version>
<configuration>
<aspectLibraries combine.self="override"/>
</configuration>
Expand Down

0 comments on commit a9b7a23

Please sign in to comment.