From bf32cef64943fae26d45d83e2be48d20507a716b Mon Sep 17 00:00:00 2001 From: Nate Danner Date: Wed, 24 Apr 2024 23:07:13 +0000 Subject: [PATCH] refactor: Common static analysis issues Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.CommonStaticAnalysis?organizationId=TmV0ZmxpeCArIFNwcmluZw%3D%3D Co-authored-by: Moderne --- .../repository/support/LdapRepositoryFactoryBean.java | 2 +- .../data/ldap/repository/LdapRepositoryUnitTests.java | 3 ++- .../LdapRepositoryConfigurationExtensionUnitTests.java | 10 +++++----- .../data/ldap/repository/support/QPerson.java | 2 +- .../support/QuerydslFilterGeneratorTests.java | 6 +++--- .../QuerydslLdapPredicateExecutorUnitTests.java | 3 ++- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/springframework/data/ldap/repository/support/LdapRepositoryFactoryBean.java b/src/main/java/org/springframework/data/ldap/repository/support/LdapRepositoryFactoryBean.java index 8a3a91df..309e9b25 100644 --- a/src/main/java/org/springframework/data/ldap/repository/support/LdapRepositoryFactoryBean.java +++ b/src/main/java/org/springframework/data/ldap/repository/support/LdapRepositoryFactoryBean.java @@ -40,7 +40,7 @@ public class LdapRepositoryFactoryBean, S> extends RepositoryFactoryBeanSupport { private @Nullable LdapOperations ldapOperations; - private boolean mappingContextConfigured = false; + private boolean mappingContextConfigured; private @Nullable MappingContext, ? extends PersistentProperty> mappingContext; /** diff --git a/src/test/java/org/springframework/data/ldap/repository/LdapRepositoryUnitTests.java b/src/test/java/org/springframework/data/ldap/repository/LdapRepositoryUnitTests.java index ce24c29a..eeac05b3 100644 --- a/src/test/java/org/springframework/data/ldap/repository/LdapRepositoryUnitTests.java +++ b/src/test/java/org/springframework/data/ldap/repository/LdapRepositoryUnitTests.java @@ -47,7 +47,8 @@ class LdapRepositoryUnitTests { @Mock LdapOperations ldapOperations; - UnitTestPerson walter, hank; + UnitTestPerson walter; + UnitTestPerson hank; PersonRepository repository; diff --git a/src/test/java/org/springframework/data/ldap/repository/config/LdapRepositoryConfigurationExtensionUnitTests.java b/src/test/java/org/springframework/data/ldap/repository/config/LdapRepositoryConfigurationExtensionUnitTests.java index 51e84f21..7c812eff 100644 --- a/src/test/java/org/springframework/data/ldap/repository/config/LdapRepositoryConfigurationExtensionUnitTests.java +++ b/src/test/java/org/springframework/data/ldap/repository/config/LdapRepositoryConfigurationExtensionUnitTests.java @@ -41,12 +41,12 @@ */ class LdapRepositoryConfigurationExtensionUnitTests { - private StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class, true); - private ResourceLoader loader = new PathMatchingResourcePatternResolver(); - private Environment environment = new StandardEnvironment(); - private BeanDefinitionRegistry registry = new DefaultListableBeanFactory(); + private final StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class, true); + private final ResourceLoader loader = new PathMatchingResourcePatternResolver(); + private final Environment environment = new StandardEnvironment(); + private final BeanDefinitionRegistry registry = new DefaultListableBeanFactory(); - private RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(metadata, + private final RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(metadata, EnableLdapRepositories.class, loader, environment, registry); @Test // DATALDAP-60 diff --git a/src/test/java/org/springframework/data/ldap/repository/support/QPerson.java b/src/test/java/org/springframework/data/ldap/repository/support/QPerson.java index 626b3e01..04b7f2e7 100644 --- a/src/test/java/org/springframework/data/ldap/repository/support/QPerson.java +++ b/src/test/java/org/springframework/data/ldap/repository/support/QPerson.java @@ -35,7 +35,7 @@ public class QPerson extends EntityPathBase { public final StringPath fullName = createString("fullName"); - public final ListPath description = this. createList("description", + public final ListPath description = this. createList("description", String.class, StringPath.class, PathInits.DIRECT2); public final StringPath lastName = createString("lastName"); diff --git a/src/test/java/org/springframework/data/ldap/repository/support/QuerydslFilterGeneratorTests.java b/src/test/java/org/springframework/data/ldap/repository/support/QuerydslFilterGeneratorTests.java index 98600489..f712bde5 100644 --- a/src/test/java/org/springframework/data/ldap/repository/support/QuerydslFilterGeneratorTests.java +++ b/src/test/java/org/springframework/data/ldap/repository/support/QuerydslFilterGeneratorTests.java @@ -30,9 +30,9 @@ */ class QuerydslFilterGeneratorTests { - private ObjectDirectoryMapper odm = new DefaultObjectDirectoryMapper(); - private LdapSerializer tested = new LdapSerializer(odm, UnitTestPerson.class); - private QPerson person = QPerson.person; + private final ObjectDirectoryMapper odm = new DefaultObjectDirectoryMapper(); + private final LdapSerializer tested = new LdapSerializer(odm, UnitTestPerson.class); + private final QPerson person = QPerson.person; @Test void testEqualsFilter() { diff --git a/src/test/java/org/springframework/data/ldap/repository/support/QuerydslLdapPredicateExecutorUnitTests.java b/src/test/java/org/springframework/data/ldap/repository/support/QuerydslLdapPredicateExecutorUnitTests.java index 72f52406..7bf7ccf6 100644 --- a/src/test/java/org/springframework/data/ldap/repository/support/QuerydslLdapPredicateExecutorUnitTests.java +++ b/src/test/java/org/springframework/data/ldap/repository/support/QuerydslLdapPredicateExecutorUnitTests.java @@ -53,7 +53,8 @@ class QuerydslLdapPredicateExecutorUnitTests { @Mock LdapOperations ldapOperations; - UnitTestPerson walter, hank; + UnitTestPerson walter; + UnitTestPerson hank; QuerydslLdapPredicateExecutor repository;