Skip to content

Commit 8df7070

Browse files
authored
Merge pull request #153 from entur/prettier
Introduce Prettier for code formattingh
2 parents 8a4b6f5 + bf43033 commit 8df7070

File tree

50 files changed

+3381
-2519
lines changed

Some content is hidden

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

50 files changed

+3381
-2519
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
${{ runner.os }}-maven-
2626
${{ runner.os }}-
2727
- name: Run maven build
28-
run: mvn install
28+
run: mvn install -PprettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
${{ runner.os }}-
4141
4242
- name: Run maven build
43-
run: mvn verify -s .github/workflows/settings.xml
43+
run: mvn verify -s .github/workflows/settings.xml -PprettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm
4444
- name: Sonar Scan
4545
env:
4646
SONAR_TOKEN: ${{ secrets.ENTUR_SONAR_PASSWORD }}
@@ -66,4 +66,4 @@ jobs:
6666
with:
6767
push_to_repo: true
6868
snapshot: false
69-
next_version: ''
69+
next_version: ''

gbfs-validator-java-api/src/main/java/org/entur/gbfs/validator/api/handler/LoaderConfiguration.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
@Configuration
2828
public class LoaderConfiguration {
2929

30-
@Bean
31-
public Loader loader(LoaderProperties properties) {
32-
return new Loader(
33-
properties.getHttp().getMaxTotalConnections(),
34-
properties.getHttp().getMaxConnectionsPerRoute(),
35-
properties.getHttp().getConnectTimeoutSeconds(),
36-
properties.getHttp().getResponseTimeoutSeconds(),
37-
properties.getThreadPool().getSize(),
38-
properties.getHttp().getHeaders()
39-
);
40-
}
30+
@Bean
31+
public Loader loader(LoaderProperties properties) {
32+
return new Loader(
33+
properties.getHttp().getMaxTotalConnections(),
34+
properties.getHttp().getMaxConnectionsPerRoute(),
35+
properties.getHttp().getConnectTimeoutSeconds(),
36+
properties.getHttp().getResponseTimeoutSeconds(),
37+
properties.getThreadPool().getSize(),
38+
properties.getHttp().getHeaders()
39+
);
40+
}
4141
}

gbfs-validator-java-api/src/main/java/org/entur/gbfs/validator/api/handler/LoaderProperties.java

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,92 +20,93 @@
2020

2121
package org.entur.gbfs.validator.api.handler;
2222

23-
import org.springframework.boot.context.properties.ConfigurationProperties;
24-
import org.springframework.stereotype.Component;
25-
2623
import java.util.HashMap;
2724
import java.util.Map;
25+
import org.springframework.boot.context.properties.ConfigurationProperties;
26+
import org.springframework.stereotype.Component;
2827

2928
@Component
3029
@ConfigurationProperties(prefix = "loader")
3130
public class LoaderProperties {
3231

33-
private Http http = new Http();
34-
private ThreadPool threadPool = new ThreadPool();
32+
private Http http = new Http();
33+
private ThreadPool threadPool = new ThreadPool();
3534

36-
public Http getHttp() {
37-
return http;
38-
}
35+
public Http getHttp() {
36+
return http;
37+
}
3938

40-
public void setHttp(Http http) {
41-
this.http = http;
42-
}
39+
public void setHttp(Http http) {
40+
this.http = http;
41+
}
4342

44-
public ThreadPool getThreadPool() {
45-
return threadPool;
46-
}
43+
public ThreadPool getThreadPool() {
44+
return threadPool;
45+
}
4746

48-
public void setThreadPool(ThreadPool threadPool) {
49-
this.threadPool = threadPool;
50-
}
47+
public void setThreadPool(ThreadPool threadPool) {
48+
this.threadPool = threadPool;
49+
}
5150

52-
public static class Http {
53-
private int maxTotalConnections = 50;
54-
private int maxConnectionsPerRoute = 20;
55-
private int connectTimeoutSeconds = 5;
56-
private int responseTimeoutSeconds = 5;
57-
private Map<String, String> headers = new HashMap<>();
51+
public static class Http {
5852

59-
public int getMaxTotalConnections() {
60-
return maxTotalConnections;
61-
}
53+
private int maxTotalConnections = 50;
54+
private int maxConnectionsPerRoute = 20;
55+
private int connectTimeoutSeconds = 5;
56+
private int responseTimeoutSeconds = 5;
57+
private Map<String, String> headers = new HashMap<>();
6258

63-
public void setMaxTotalConnections(int maxTotalConnections) {
64-
this.maxTotalConnections = maxTotalConnections;
65-
}
59+
public int getMaxTotalConnections() {
60+
return maxTotalConnections;
61+
}
6662

67-
public int getMaxConnectionsPerRoute() {
68-
return maxConnectionsPerRoute;
69-
}
63+
public void setMaxTotalConnections(int maxTotalConnections) {
64+
this.maxTotalConnections = maxTotalConnections;
65+
}
7066

71-
public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute) {
72-
this.maxConnectionsPerRoute = maxConnectionsPerRoute;
73-
}
67+
public int getMaxConnectionsPerRoute() {
68+
return maxConnectionsPerRoute;
69+
}
7470

75-
public int getConnectTimeoutSeconds() {
76-
return connectTimeoutSeconds;
77-
}
71+
public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute) {
72+
this.maxConnectionsPerRoute = maxConnectionsPerRoute;
73+
}
7874

79-
public void setConnectTimeoutSeconds(int connectTimeoutSeconds) {
80-
this.connectTimeoutSeconds = connectTimeoutSeconds;
81-
}
75+
public int getConnectTimeoutSeconds() {
76+
return connectTimeoutSeconds;
77+
}
78+
79+
public void setConnectTimeoutSeconds(int connectTimeoutSeconds) {
80+
this.connectTimeoutSeconds = connectTimeoutSeconds;
81+
}
8282

83-
public int getResponseTimeoutSeconds() {
84-
return responseTimeoutSeconds;
85-
}
83+
public int getResponseTimeoutSeconds() {
84+
return responseTimeoutSeconds;
85+
}
8686

87-
public void setResponseTimeoutSeconds(int responseTimeoutSeconds) {
88-
this.responseTimeoutSeconds = responseTimeoutSeconds;
89-
}
87+
public void setResponseTimeoutSeconds(int responseTimeoutSeconds) {
88+
this.responseTimeoutSeconds = responseTimeoutSeconds;
89+
}
9090

91-
public Map<String, String> getHeaders() {
92-
return headers;
93-
}
91+
public Map<String, String> getHeaders() {
92+
return headers;
93+
}
9494

95-
public void setHeaders(Map<String, String> headers) {
96-
this.headers = headers;
97-
}
95+
public void setHeaders(Map<String, String> headers) {
96+
this.headers = headers;
9897
}
98+
}
9999

100-
public static class ThreadPool {
101-
private int size = 20;
100+
public static class ThreadPool {
102101

103-
public int getSize() {
104-
return size;
105-
}
102+
private int size = 20;
103+
104+
public int getSize() {
105+
return size;
106+
}
106107

107-
public void setSize(int size) {
108-
this.size = size;
109-
}
108+
public void setSize(int size) {
109+
this.size = size;
110110
}
111+
}
111112
}

gbfs-validator-java-api/src/main/java/org/entur/gbfs/validator/api/handler/SecurityConfig.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
package org.entur.gbfs.validator.api.handler;
2222

23+
import java.util.Arrays;
24+
import java.util.List;
2325
import org.springframework.context.annotation.Bean;
2426
import org.springframework.context.annotation.Configuration;
2527
import org.springframework.security.authentication.AuthenticationManager;
@@ -31,9 +33,6 @@
3133
import org.springframework.web.cors.CorsConfigurationSource;
3234
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
3335

34-
import java.util.Arrays;
35-
import java.util.List;
36-
3736
/**
3837
* Security configuration for the GBFS Validator API.
3938
* Handles CORS configuration to allow cross-origin requests.
@@ -42,33 +41,34 @@
4241
@EnableWebSecurity
4342
public class SecurityConfig {
4443

45-
@Bean
46-
public SecurityFilterChain filterChain(
47-
HttpSecurity http
48-
) throws Exception {
49-
return http
50-
.csrf(csrf -> csrf.disable())
51-
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
52-
.build();
53-
}
44+
@Bean
45+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
46+
return http
47+
.csrf(csrf -> csrf.disable())
48+
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
49+
.build();
50+
}
5451

55-
private CorsConfigurationSource corsConfigurationSource() {
56-
CorsConfiguration configuration = new CorsConfiguration();
57-
configuration.addAllowedOriginPattern("*");
58-
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
59-
configuration.setAllowedHeaders(List.of("*"));
60-
configuration.setExposedHeaders(List.of("*"));
61-
configuration.setAllowCredentials(false);
62-
configuration.setMaxAge(3600L); // Cache preflight response for 1 hour
63-
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
64-
source.registerCorsConfiguration("/**", configuration);
65-
return source;
66-
}
52+
private CorsConfigurationSource corsConfigurationSource() {
53+
CorsConfiguration configuration = new CorsConfiguration();
54+
configuration.addAllowedOriginPattern("*");
55+
configuration.setAllowedMethods(
56+
Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS")
57+
);
58+
configuration.setAllowedHeaders(List.of("*"));
59+
configuration.setExposedHeaders(List.of("*"));
60+
configuration.setAllowCredentials(false);
61+
configuration.setMaxAge(3600L); // Cache preflight response for 1 hour
62+
UrlBasedCorsConfigurationSource source =
63+
new UrlBasedCorsConfigurationSource();
64+
source.registerCorsConfiguration("/**", configuration);
65+
return source;
66+
}
6767

68-
@Bean
69-
public AuthenticationManager noopAuthenticationManager() {
70-
return authentication -> {
71-
throw new AuthenticationServiceException("Authentication is disabled");
72-
};
73-
}
68+
@Bean
69+
public AuthenticationManager noopAuthenticationManager() {
70+
return authentication -> {
71+
throw new AuthenticationServiceException("Authentication is disabled");
72+
};
73+
}
7474
}

0 commit comments

Comments
 (0)