Skip to content

Commit

Permalink
Merge pull request #11990 from qmonmert/varinstead2
Browse files Browse the repository at this point in the history
Sonar: Local-Variable Type Inference should be used
  • Loading branch information
murdos authored Feb 25, 2025
2 parents 1a694a8 + e2b2133 commit 677059a
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static String replaceParameters(String message, Map<String, ?> arguments)
}

private String format(String message) {
StringBuilder result = new StringBuilder(message);
var result = new StringBuilder(message);

int lastMustaches = result.indexOf(OPEN);
while (lastMustaches != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AssertionErrorsConfiguration {

@Bean("assertionErrorMessageSource")
MessageSource assertionErrorMessageSource() {
ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
var source = new ReloadableResourceBundleMessageSource();

source.setBasename("classpath:/messages/assertions-errors/assertion-errors-messages");
source.setDefaultEncoding("UTF-8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GeneratorErrorsConfiguration {

@Bean("generatorErrorMessageSource")
MessageSource generatorErrorMessageSource() {
ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
var source = new ReloadableResourceBundleMessageSource();

source.setBasename("classpath:/messages/errors/generator-errors-messages");
source.setDefaultEncoding("UTF-8");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package {{packageName}}.wire.liquibase.infrastructure.secondary;

import java.sql.Connection;
import java.sql.SQLException;
import java.time.Duration;
import java.util.concurrent.Executor;
Expand Down Expand Up @@ -56,7 +55,7 @@ class AsyncSpringLiquibase extends DataSourceClosingSpringLiquibase {
if (env.acceptsProfiles(Profiles.of("local"))) {
// Prevent Thread Lock with spring-cloud-context GenericScope
// https://github.com/spring-cloud/spring-cloud-commons/commit/aaa7288bae3bb4d6fdbef1041691223238d77b7b#diff-afa0715eafc2b0154475fe672dab70e4R328
try (Connection connection = getDataSource().getConnection()) {
try (var connection = getDataSource().getConnection()) {
executor.execute(() -> {
try {
logger.warn("Starting Liquibase asynchronously, your database might not be ready at startup!");
Expand All @@ -75,7 +74,7 @@ class AsyncSpringLiquibase extends DataSourceClosingSpringLiquibase {
}

protected void initDb() throws LiquibaseException {
StopWatch watch = new StopWatch();
var watch = new StopWatch();
watch.start();
super.afterPropertiesSet();
watch.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class SpringLiquibaseUtilTest {
} catch (URISyntaxException exception) {
{{/yamlSpringConfigurationFormat}}
{{#propertiesSpringConfigurationFormat}}
Properties properties = new Properties();
var properties = new Properties();
properties.load(
SpringLiquibaseUtilTest.class.getClassLoader().getResourceAsStream("config/application-test.properties")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class {{ baseName }}ErrorsConfiguration {
@Bean("applicationErrorMessageSource")
MessageSource applicationErrorMessageSource() {
ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
var source = new ReloadableResourceBundleMessageSource();
source.setBasename("classpath:/messages/errors/{{ baseFileName }}-errors-messages");
source.setDefaultEncoding("UTF-8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class ArgumentsReplacer {
}

private String format(String message) {
StringBuilder result = new StringBuilder(message);
var result = new StringBuilder(message);
int lastMustaches = result.indexOf(OPEN);
while (lastMustaches != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AssertionErrorsConfiguration {
@Bean("assertionErrorMessageSource")
MessageSource assertionErrorMessageSource() {
ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
var source = new ReloadableResourceBundleMessageSource();
source.setBasename("classpath:/messages/assertions-errors/assertion-errors-messages");
source.setDefaultEncoding("UTF-8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class {{ baseName }}ErrorsMessagesTest {

private static Function<Path, Properties> toProperties() {
return file -> {
Properties properties = new Properties();
var properties = new Properties();
try {
properties.load(Files.newInputStream(file));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AssertionErrorMessagesTest {

private static Function<Path, Properties> toProperties() {
return file -> {
Properties properties = new Properties();
var properties = new Properties();
try {
properties.load(Files.newInputStream(file));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void shouldBuildModuleWithYamlSpringConfigurationFormat() {
assertThatModuleWithFiles(module, pomFile(), logbackFile(), testLogbackFile())
.hasFile("src/test/java/tech/jhipster/jhlitest/wire/liquibase/infrastructure/secondary/SpringLiquibaseUtilTest.java")
.containing("YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();")
.notContaining("Properties properties = new Properties();");
.notContaining("var properties = new Properties();");
}

@Test
Expand All @@ -122,7 +122,7 @@ void shouldBuildModuleWithPropertiesSpringConfigurationFormat() {

assertThatModuleWithFiles(module, pomFile(), logbackFile(), testLogbackFile())
.hasFile("src/test/java/tech/jhipster/jhlitest/wire/liquibase/infrastructure/secondary/SpringLiquibaseUtilTest.java")
.containing("Properties properties = new Properties();")
.containing("var properties = new Properties();")
.notContaining("YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static Map<String, Properties> loadMessages() {

private static Function<Path, Properties> toProperties() {
return file -> {
Properties properties = new Properties();
var properties = new Properties();
try {
properties.load(Files.newInputStream(file));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static Map<String, Properties> loadMessages() {

private static Function<Path, Properties> toProperties() {
return file -> {
Properties properties = new Properties();
var properties = new Properties();
try {
properties.load(Files.newInputStream(file));
} catch (IOException e) {
Expand Down

0 comments on commit 677059a

Please sign in to comment.