Skip to content

Commit 368be3a

Browse files
sobychackoilayaperumalg
authored andcommitted
Fixing miscellaneous checkstyle errors
Enabling checkstyle by default in the project build Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
1 parent 31feb43 commit 368be3a

File tree

218 files changed

+1274
-1073
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+1274
-1073
lines changed

advisors/spring-ai-advisors-vector-store/src/main/java/org/springframework/ai/chat/client/advisor/vectorstore/QuestionAnswerAdvisor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
import java.util.Map;
2222
import java.util.stream.Collectors;
2323

24+
import reactor.core.scheduler.Scheduler;
25+
import reactor.core.scheduler.Schedulers;
26+
2427
import org.springframework.ai.chat.client.ChatClientRequest;
2528
import org.springframework.ai.chat.client.ChatClientResponse;
2629
import org.springframework.ai.chat.client.advisor.api.AdvisorChain;
2730
import org.springframework.ai.chat.client.advisor.api.BaseAdvisor;
2831
import org.springframework.ai.chat.messages.UserMessage;
29-
import reactor.core.scheduler.Scheduler;
30-
import reactor.core.scheduler.Schedulers;
31-
3232
import org.springframework.ai.chat.model.ChatResponse;
3333
import org.springframework.ai.chat.prompt.PromptTemplate;
3434
import org.springframework.ai.document.Document;

advisors/spring-ai-advisors-vector-store/src/main/java/org/springframework/ai/chat/client/advisor/vectorstore/VectorStoreChatMemoryAdvisor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24-
import org.springframework.util.Assert;
2524
import reactor.core.scheduler.Scheduler;
2625

2726
import org.springframework.ai.chat.client.ChatClientRequest;
@@ -38,6 +37,7 @@
3837
import org.springframework.ai.chat.prompt.PromptTemplate;
3938
import org.springframework.ai.document.Document;
4039
import org.springframework.ai.vectorstore.VectorStore;
40+
import org.springframework.util.Assert;
4141

4242
/**
4343
* Memory is retrieved from a VectorStore added into the prompt's system text.
@@ -50,7 +50,7 @@
5050
* @author Mark Pollack
5151
* @since 1.0.0
5252
*/
53-
public class VectorStoreChatMemoryAdvisor implements BaseChatMemoryAdvisor {
53+
public final class VectorStoreChatMemoryAdvisor implements BaseChatMemoryAdvisor {
5454

5555
public static final String TOP_K = "chat_memory_vector_store_top_k";
5656

@@ -104,7 +104,7 @@ public static Builder builder(VectorStore chatMemory) {
104104

105105
@Override
106106
public int getOrder() {
107-
return order;
107+
return this.order;
108108
}
109109

110110
@Override

advisors/spring-ai-advisors-vector-store/src/test/java/org/springframework/ai/chat/client/advisor/vectorstore/VectorStoreChatMemoryAdvisorTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
/*
2+
* Copyright 2025-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.ai.chat.client.advisor.vectorstore;
218

319
import org.junit.jupiter.api.Test;
420
import org.mockito.Mockito;
21+
522
import org.springframework.ai.vectorstore.VectorStore;
623

724
import static org.assertj.core.api.Assertions.assertThatThrownBy;

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpClientCommonProperties.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -109,33 +109,6 @@ public enum ClientType {
109109
*/
110110
private Toolcallback toolcallback = new Toolcallback();
111111

112-
/**
113-
* Represents a callback configuration for tools.
114-
* <p>
115-
* This record is used to encapsulate the configuration for enabling or disabling tool
116-
* callbacks in the MCP client.
117-
*
118-
* @param enabled A boolean flag indicating whether the tool callback is enabled. If
119-
* true, the tool callback is active; otherwise, it is disabled.
120-
*/
121-
public static class Toolcallback {
122-
123-
/**
124-
* A boolean flag indicating whether the tool callback is enabled. If true, the
125-
* tool callback is active; otherwise, it is disabled.
126-
*/
127-
private boolean enabled = true;
128-
129-
public void setEnabled(boolean enabled) {
130-
this.enabled = enabled;
131-
}
132-
133-
public boolean isEnabled() {
134-
return this.enabled;
135-
}
136-
137-
}
138-
139112
public boolean isEnabled() {
140113
return this.enabled;
141114
}
@@ -193,11 +166,38 @@ public void setRootChangeNotification(boolean rootChangeNotification) {
193166
}
194167

195168
public Toolcallback getToolcallback() {
196-
return toolcallback;
169+
return this.toolcallback;
197170
}
198171

199172
public void setToolcallback(Toolcallback toolcallback) {
200173
this.toolcallback = toolcallback;
201174
}
202175

176+
/**
177+
* Represents a callback configuration for tools.
178+
* <p>
179+
* This record is used to encapsulate the configuration for enabling or disabling tool
180+
* callbacks in the MCP client.
181+
*
182+
* @param enabled A boolean flag indicating whether the tool callback is enabled. If
183+
* true, the tool callback is active; otherwise, it is disabled.
184+
*/
185+
public static class Toolcallback {
186+
187+
/**
188+
* A boolean flag indicating whether the tool callback is enabled. If true, the
189+
* tool callback is active; otherwise, it is disabled.
190+
*/
191+
private boolean enabled = true;
192+
193+
public void setEnabled(boolean enabled) {
194+
this.enabled = enabled;
195+
}
196+
197+
public boolean isEnabled() {
198+
return this.enabled;
199+
}
200+
201+
}
202+
203203
}

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpClientCommonPropertiesTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
package org.springframework.ai.mcp.client.autoconfigure.properties;
1818

19+
import java.time.Duration;
20+
1921
import org.junit.jupiter.api.Test;
22+
2023
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2124
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2225
import org.springframework.context.annotation.Configuration;
2326

24-
import java.time.Duration;
25-
2627
import static org.assertj.core.api.Assertions.assertThat;
2728

2829
/**

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpSseClientPropertiesTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
package org.springframework.ai.mcp.client.autoconfigure.properties;
1818

19+
import java.util.Map;
20+
1921
import org.junit.jupiter.api.Test;
22+
2023
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2124
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2225
import org.springframework.context.annotation.Configuration;
2326

24-
import java.util.Map;
25-
2627
import static org.assertj.core.api.Assertions.assertThat;
2728

2829
/**

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpServerAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,4 @@ public McpAsyncServer mcpAsyncServer(McpServerTransportProvider transportProvide
351351
return serverBuilder.build();
352352
}
353353

354-
}
354+
}

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfigurationTests.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.ai.mcp.server.autoconfigure;
1716

18-
import static org.assertj.core.api.Assertions.assertThat;
17+
package org.springframework.ai.mcp.server.autoconfigure;
1918

19+
import com.fasterxml.jackson.databind.ObjectMapper;
20+
import io.modelcontextprotocol.server.transport.WebFluxSseServerTransportProvider;
2021
import org.junit.jupiter.api.Test;
22+
2123
import org.springframework.boot.autoconfigure.AutoConfigurations;
2224
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
2325
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2426
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2527
import org.springframework.context.annotation.Configuration;
2628
import org.springframework.web.reactive.function.server.RouterFunction;
2729

28-
import com.fasterxml.jackson.databind.ObjectMapper;
29-
import io.modelcontextprotocol.server.transport.WebFluxSseServerTransportProvider;
30+
import static org.assertj.core.api.Assertions.assertThat;
3031

3132
class McpWebFluxServerAutoConfigurationTests {
3233

@@ -36,7 +37,7 @@ class McpWebFluxServerAutoConfigurationTests {
3637

3738
@Test
3839
void shouldConfigureWebFluxTransportWithCustomObjectMapper() {
39-
this.contextRunner.run((context) -> {
40+
this.contextRunner.run(context -> {
4041
assertThat(context).hasSingleBean(WebFluxSseServerTransportProvider.class);
4142
assertThat(context).hasSingleBean(RouterFunction.class);
4243
assertThat(context).hasSingleBean(McpServerProperties.class);
@@ -48,13 +49,15 @@ void shouldConfigureWebFluxTransportWithCustomObjectMapper() {
4849
.isEnabled(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)).isFalse();
4950

5051
// Test with a JSON payload containing unknown fields
52+
// CHECKSTYLE:OFF
5153
String jsonWithUnknownField = """
5254
{
5355
"tools": ["tool1", "tool2"],
5456
"name": "test",
5557
"unknownField": "value"
5658
}
5759
""";
60+
// CHECKSTYLE:ON
5861

5962
// This should not throw an exception
6063
TestMessage message = objectMapper.readValue(jsonWithUnknownField, TestMessage.class);
@@ -75,7 +78,7 @@ static class TestMessage {
7578
private String name;
7679

7780
public String getName() {
78-
return name;
81+
return this.name;
7982
}
8083

8184
public void setName(String name) {

auto-configurations/models/chat/client/spring-ai-autoconfigure-model-chat-client/src/main/java/org/springframework/ai/model/chat/client/autoconfigure/ChatClientAutoConfiguration.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.micrometer.tracing.Tracer;
2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
23+
2324
import org.springframework.ai.chat.client.ChatClient;
2425
import org.springframework.ai.chat.client.ChatClientCustomizer;
2526
import org.springframework.ai.chat.client.observation.ChatClientObservationContext;
@@ -30,7 +31,11 @@
3031
import org.springframework.beans.factory.ObjectProvider;
3132
import org.springframework.boot.autoconfigure.AutoConfiguration;
3233
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
33-
import org.springframework.boot.autoconfigure.condition.*;
34+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
35+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
36+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
37+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
38+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3439
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3540
import org.springframework.context.annotation.Bean;
3641
import org.springframework.context.annotation.Configuration;

auto-configurations/models/chat/client/spring-ai-autoconfigure-model-chat-client/src/test/java/org/springframework/ai/model/chat/client/autoconfigure/ChatClientObservationAutoConfigurationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.micrometer.tracing.Tracer;
2020
import org.junit.jupiter.api.Test;
2121
import org.junit.jupiter.api.extension.ExtendWith;
22+
2223
import org.springframework.ai.chat.client.observation.ChatClientObservationContext;
2324
import org.springframework.ai.chat.client.observation.ChatClientPromptContentObservationHandler;
2425
import org.springframework.ai.observation.TracingAwareLoggingObservationHandler;

0 commit comments

Comments
 (0)