Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 3ae1db5

Browse files
committed
Fix sonar issues
1 parent 1adce3d commit 3ae1db5

File tree

40 files changed

+122
-125
lines changed

40 files changed

+122
-125
lines changed

example-request-scoped-dataloader/src/main/java/graphql/servlet/examples/dataloader/requestscope/CustomGraphQLContextBuilder.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package graphql.servlet.examples.dataloader.requestscope;
22

3+
import static java.util.concurrent.CompletableFuture.supplyAsync;
4+
35
import graphql.kickstart.execution.context.DefaultGraphQLContext;
46
import graphql.kickstart.execution.context.GraphQLContext;
57
import graphql.kickstart.servlet.context.DefaultGraphQLServletContext;
68
import graphql.kickstart.servlet.context.DefaultGraphQLWebSocketContext;
79
import graphql.kickstart.servlet.context.GraphQLServletContextBuilder;
8-
import java.util.concurrent.CompletableFuture;
910
import javax.servlet.http.HttpServletRequest;
1011
import javax.servlet.http.HttpServletResponse;
1112
import javax.websocket.Session;
@@ -44,10 +45,10 @@ public GraphQLContext build(Session session, HandshakeRequest request) {
4445

4546
private DataLoaderRegistry buildDataLoaderRegistry() {
4647
DataLoaderRegistry dataLoaderRegistry = new DataLoaderRegistry();
47-
dataLoaderRegistry.register("customerDataLoader",
48-
new DataLoader<Integer, String>(customerIds ->
49-
CompletableFuture.supplyAsync(() ->
50-
customerRepository.getUserNamesForIds(customerIds))));
48+
DataLoader<Integer, String> customerLoader = new DataLoader<>(
49+
customerIds -> supplyAsync(() -> customerRepository.getUserNamesForIds(customerIds))
50+
);
51+
dataLoaderRegistry.register("customerDataLoader", customerLoader);
5152
return dataLoaderRegistry;
5253
}
5354
}

example-spring-common/src/main/java/graphql/kickstart/spring/web/boot/sample/ApplicationBootConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@SpringBootApplication
2929
public class ApplicationBootConfiguration {
3030

31-
public static void main(String[] args) throws Exception {
31+
public static void main(String[] args) {
3232
SpringApplication.run(ApplicationBootConfiguration.class, args);
3333
}
3434
}

example-webflux/src/main/java/graphql/kickstart/spring/web/boot/sample/ApplicationWebfluxConfiguration.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
package graphql.kickstart.spring.web.boot.sample;
2121

2222
import graphql.Scalars;
23+
import graphql.schema.DataFetcher;
24+
import graphql.schema.FieldCoordinates;
25+
import graphql.schema.GraphQLCodeRegistry;
2326
import graphql.schema.GraphQLObjectType;
2427
import graphql.schema.GraphQLSchema;
2528
import org.springframework.boot.SpringApplication;
@@ -40,15 +43,18 @@ public static void main(String[] args) {
4043

4144
@Bean
4245
GraphQLSchema schema() {
46+
DataFetcher<String> test = env -> "response";
4347
return GraphQLSchema.newSchema()
4448
.query(GraphQLObjectType.newObject()
4549
.name("query")
4650
.field(field -> field
4751
.name("test")
4852
.type(Scalars.GraphQLString)
49-
.dataFetcher(environment -> "response")
5053
)
5154
.build())
55+
.codeRegistry(GraphQLCodeRegistry.newCodeRegistry()
56+
.dataFetcher(FieldCoordinates.coordinates("query", "test"), test)
57+
.build())
5258
.build();
5359
}
5460
}

example/src/main/java/graphql/kickstart/spring/web/boot/sample/ApplicationBootConfiguration.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
package graphql.kickstart.spring.web.boot.sample;
2121

2222
import graphql.Scalars;
23+
import graphql.schema.DataFetcher;
24+
import graphql.schema.FieldCoordinates;
25+
import graphql.schema.GraphQLCodeRegistry;
2326
import graphql.schema.GraphQLObjectType;
2427
import graphql.schema.GraphQLSchema;
2528
import org.springframework.boot.SpringApplication;
@@ -35,15 +38,18 @@ public static void main(String[] args) {
3538

3639
@Bean
3740
GraphQLSchema schema() {
41+
DataFetcher<String> test = env -> "response";
3842
return GraphQLSchema.newSchema()
3943
.query(GraphQLObjectType.newObject()
4044
.name("query")
4145
.field(field -> field
4246
.name("test")
4347
.type(Scalars.GraphQLString)
44-
.dataFetcher(environment -> "response")
4548
)
4649
.build())
50+
.codeRegistry(GraphQLCodeRegistry.newCodeRegistry()
51+
.dataFetcher(FieldCoordinates.coordinates("query", "test"), test)
52+
.build())
4753
.build();
4854
}
4955
}

graphiql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/graphiql/boot/ServletGraphiQLController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
@Controller
1818
public class ServletGraphiQLController extends GraphiQLController {
1919

20+
@Override
2021
@PostConstruct
2122
public void onceConstructed() throws IOException {
2223
super.onceConstructed();

graphiql-spring-boot-autoconfigure/src/test/java/graphql/kickstart/graphiql/boot/ReactiveGraphiQLControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
@ExtendWith(SpringExtension.class)
1515
@WebFluxTest
16-
public class ReactiveGraphiQLControllerTest {
16+
class ReactiveGraphiQLControllerTest {
1717

1818
@Autowired
1919
private WebTestClient webTestClient;
2020

2121
@Test
22-
public void shouldBeAbleToAccessGraphiQL() {
22+
void shouldBeAbleToAccessGraphiQL() {
2323
webTestClient.get()
2424
.uri("/graphiql")
2525
.exchange()

graphiql-spring-boot-autoconfigure/src/test/java/graphql/kickstart/graphiql/boot/ServletGraphiQLControllerTest.java

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

1717
@ExtendWith(SpringExtension.class)
1818
@WebMvcTest
19-
public class ServletGraphiQLControllerTest {
19+
class ServletGraphiQLControllerTest {
2020

2121
@Autowired
2222
private MockMvc mockMvc;
2323

2424
@Test
25-
public void shouldBeAbleToAccessGraphiQL() throws Exception {
25+
void shouldBeAbleToAccessGraphiQL() throws Exception {
2626
mockMvc.perform(get("/graphiql"))
2727
.andExpect(status().is2xxSuccessful())
2828
.andExpect(content().contentType("text/html; charset=UTF-8"));

graphiql-spring-boot-autoconfigure/src/test/java/graphql/kickstart/graphiql/boot/test/GraphiQLControllerTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,33 @@
1010
import org.springframework.context.annotation.Bean;
1111
import org.springframework.context.annotation.Configuration;
1212
import org.springframework.context.annotation.PropertySource;
13+
import org.springframework.context.support.AbstractApplicationContext;
1314
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
1415
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
1516

1617
/**
1718
* @author Andrew Potter
1819
*/
19-
public class GraphiQLControllerTest extends AbstractAutoConfigurationTest {
20+
class GraphiQLControllerTest extends AbstractAutoConfigurationTest {
2021

2122
public GraphiQLControllerTest() {
2223
super(AnnotationConfigWebApplicationContext.class, GraphiQLAutoConfiguration.class);
2324
}
2425

2526
@Test
26-
public void graphiqlLoads() {
27+
void graphiqlLoads() {
2728
load(EnabledConfiguration.class);
2829

2930
assertThat(this.getContext().getBean(GraphiQLController.class)).isNotNull();
3031
}
3132

3233
@Test
33-
public void graphiqlDoesNotLoad() {
34+
void graphiqlDoesNotLoad() {
3435
load(DisabledConfiguration.class);
3536

37+
AbstractApplicationContext context = getContext();
3638
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
37-
.isThrownBy(() -> this.getContext().getBean(GraphiQLController.class));
39+
.isThrownBy(() -> context.getBean(GraphiQLController.class));
3840
}
3941

4042
@Configuration

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/main/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private void setQueryResolverClass(
133133
) {
134134
final Set<Class<?>> queryResolvers
135135
= getTypesAnnotatedWith(reflections, GraphQLQueryResolver.class);
136-
if (queryResolvers.size() == 0) {
136+
if (queryResolvers.isEmpty()) {
137137
throw new MissingQueryResolverException();
138138
}
139139
if (queryResolvers.size() > 1) {

graphql-kickstart-spring-boot-autoconfigure-graphql-annotations/src/test/java/graphql/kickstart/graphql/annotations/GraphQLAnnotationsBeanTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1414
@ActiveProfiles({"test", "query-test"})
15-
public class GraphQLAnnotationsBeanTest {
15+
class GraphQLAnnotationsBeanTest {
1616

1717
@Autowired
1818
private ApplicationContext applicationContext;

0 commit comments

Comments
 (0)