Skip to content

Commit

Permalink
Merge pull request #11995 from qmonmert/varinstead3
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 26, 2025
2 parents 39fb5f3 + 93463bb commit 0d1eb7f
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class CucumberRestTemplate {
}

private HttpHeaders jsonHeaders() {
HttpHeaders headers = new HttpHeaders();
var headers = new HttpHeaders();
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public final class CucumberRestTestContext {

private void retry() {
try {
ClientHttpResponse clientHttpResponse = execution.execute(request, body);
var clientHttpResponse = execution.execute(request, body);
CucumberRestTestContext.addResponse(request, clientHttpResponse, execution, body);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ElementAssertions {
<Data> void containing(List<Map<String, Data>> responses) {
assertThat(responses).as("Can't check object against null responses").isNotNull();
for (int line = 0; line < responses.size(); line++) {
for (var line = 0; line < responses.size(); line++) {
for (Map.Entry<String, Data> entry : responses.get(line).entrySet()) {
String path = jsonPath + "[" + line + "]." + CucumberJson.toCamelCase(entry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class AuthenticationSteps {
private List<ClientHttpRequestInterceptor> interceptorsWithAuthentication(String user) {
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(rest.getRestTemplate().getInterceptors());
User userToAuthenticate = users.get(user);
var userToAuthenticate = users.get(user);
assertThat(userToAuthenticate).as(unknownUserMessage(user)).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AuthenticationSteps {
private List<ClientHttpRequestInterceptor> interceptorsWithAuthentication(String user) {
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(rest.getRestTemplate().getInterceptors());
User userToAuthenticate = users.get(user);
var userToAuthenticate = users.get(user);
assertThat(userToAuthenticate).as(unknownUserMessage(user)).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class AsyncSpringLiquibaseTest {
@Test
void shouldWarnWhenLiquibaseExecutionIsSlow() throws LiquibaseException {
liquibaseProperties.setEnabled(true);
Duration slownessThreshold = Duration.ofMillis(50);
var slownessThreshold = Duration.ofMillis(50);
TestAsyncSpringLiquibase asyncSpringLiquibase = spy(
new TestAsyncSpringLiquibase(executor, environment, liquibaseProperties, slownessThreshold)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class AuthenticatedUserTest {

private static UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken() {
Collection<GrantedAuthority> authorities = adminAuthorities();
User user = new User("admin", "admin", authorities);
var user = new User("admin", "admin", authorities);
return new UsernamePasswordAuthenticationToken(user, "admin", authorities);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CustomClaimConverter implements Converter<Map<String, Object>, Map<String,
}

private ObjectNode loadUser(ClientRegistration registration, RestTemplate restTemplate, SubAttributes subAttributes) {
HttpHeaders headers = new HttpHeaders();
var headers = new HttpHeaders();
headers.set(HttpHeaders.AUTHORIZATION, buildBearer(getToken(subAttributes.attributes)));
ResponseEntity<ObjectNode> userInfo = restTemplate.exchange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class AuthenticatedUserTest {

private static UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken() {
Collection<GrantedAuthority> authorities = adminAuthorities();
User user = new User("admin", "admin", authorities);
var user = new User("admin", "admin", authorities);
return new UsernamePasswordAuthenticationToken(user, "admin", authorities);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class HeaderUtil {
String message = "error." + errorKey;
log.error("Entity processing failed, {}", message);
HttpHeaders headers = new HttpHeaders();
var headers = new HttpHeaders();
headers.add("X-" + applicationName + "-error", message);
headers.add("X-" + applicationName + "-params", entityName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private boolean forUri(String uri) {

private void retry() {
try {
ClientHttpResponse clientHttpResponse = execution.execute(request, body);
var clientHttpResponse = execution.execute(request, body);

addResponse(request, clientHttpResponse, execution, body);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void withMoreThanElementsCount(int count) {
<Data> void containing(List<Map<String, Data>> responses) {
assertThat(responses).as("Can't check object against null responses").isNotNull();

for (int line = 0; line < responses.size(); line++) {
for (var line = 0; line < responses.size(); line++) {
for (Map.Entry<String, Data> entry : responses.get(line).entrySet()) {
String path = jsonPath + "[" + line + "]." + CucumberJson.toCamelCase(entry.getKey());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private void post(String uri, String content) {
}

private HttpHeaders jsonHeaders() {
HttpHeaders headers = new HttpHeaders();
var headers = new HttpHeaders();

headers.setAccept(List.of(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void downloadCreatedProject() {
}

private HttpHeaders octetsHeaders() {
HttpHeaders headers = new HttpHeaders();
var headers = new HttpHeaders();

headers.setAccept(List.of(MediaType.APPLICATION_OCTET_STREAM));
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
Expand All @@ -51,7 +51,7 @@ public void getCreatedProjectInformation() {
}

private HttpHeaders jsonHeaders() {
HttpHeaders headers = new HttpHeaders();
var headers = new HttpHeaders();

headers.setAccept(List.of(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON);
Expand Down

0 comments on commit 0d1eb7f

Please sign in to comment.