Skip to content

Commit f132bc2

Browse files
[DT-921] Add spotless formatting to code base (#2508)
Co-authored-by: Kevin Marete <[email protected]>
1 parent 5e5797a commit f132bc2

File tree

443 files changed

+16574
-14632
lines changed

Some content is hidden

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

443 files changed

+16574
-14632
lines changed

.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# To configure git to use this file when using `git blame`:
2+
# $ git config blame.ignoreRevsFile .git-blame-ignore-revs
3+
4+
# DT-921: Add spotless to consent service
5+
# https://github.com/DataBiosphere/consent/pull/2508

.github/workflows/maven.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
distribution: 'temurin'
1515
java-version: 25
1616
cache: 'maven'
17+
- name: Spotless Check
18+
run: mvn -q spotless:check --batch-mode
1719
- name: Package
1820
env:
1921
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.defaultLogLevel=warn -Dmaven.test.skip=true -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120

.github/workflows/semgrep.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Semgrep
22
on: [ pull_request ]
33
jobs:
44
semgrep:
5+
if: false # disabled until spotless changes are merged
56
runs-on: ubuntu-latest
67
container:
78
image: returntocorp/semgrep

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
.vscode/
1111
.metals/
1212

13-
## Do not ignore project based code styles
14-
!.idea/codeStyles
15-
1613
## File-based project format
1714
*.ipr
1815
*.iws

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 581 deletions
This file was deleted.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

pom.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<mockito.version>5.20.0</mockito.version>
2727
<sonar.plugin.version>5.2.0.4988</sonar.plugin.version>
2828
<netty.override.version>4.2.7.Final</netty.override.version>
29+
<spotless.version>3.0.0</spotless.version>
2930

3031
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3132
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -98,6 +99,48 @@
9899

99100
<plugins>
100101

102+
<plugin>
103+
<groupId>com.diffplug.spotless</groupId>
104+
<artifactId>spotless-maven-plugin</artifactId>
105+
<version>${spotless.version}</version>
106+
<dependencies>
107+
<dependency>
108+
<groupId>com.diffplug.spotless</groupId>
109+
<artifactId>spotless-maven-plugin</artifactId>
110+
<version>${spotless.version}</version>
111+
</dependency>
112+
</dependencies>
113+
<configuration>
114+
<java>
115+
<googleJavaFormat/>
116+
</java>
117+
</configuration>
118+
<executions>
119+
<execution>
120+
<id>spotless-check</id>
121+
<goals>
122+
<goal>check</goal>
123+
</goals>
124+
<phase>verify</phase>
125+
<configuration>
126+
<!-- In CI workflows, run verify. -->
127+
<skip>${env.CI != true}</skip>
128+
</configuration>
129+
</execution>
130+
<execution>
131+
<id>spotless-apply</id>
132+
<goals>
133+
<goal>apply</goal>
134+
</goals>
135+
<phase>process-sources</phase>
136+
<configuration>
137+
<!-- In local workflows, run apply. -->
138+
<skip>${env.CI}</skip>
139+
</configuration>
140+
</execution>
141+
</executions>
142+
</plugin>
143+
101144
<plugin>
102145
<groupId>org.owasp</groupId>
103146
<artifactId>dependency-check-maven</artifactId>

src/main/java/org/broadinstitute/consent/http/ConsentApplication.java

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@
8888

8989
/**
9090
* Top-level entry point to the entire application.
91-
* <p>
92-
* See the Dropwizard docs here:
93-
* <a href="https://dropwizard.github.io">https://dropwizard.github.io</a>
91+
*
92+
* <p>See the Dropwizard docs here: <a
93+
* href="https://dropwizard.github.io">https://dropwizard.github.io</a>
9494
*/
9595
public class ConsentApplication extends Application<ConsentConfiguration> {
9696

@@ -106,19 +106,21 @@ public static void main(String[] args) throws Exception {
106106
try {
107107
String dsn = System.getProperties().getProperty("sentry.dsn");
108108
if (StringUtils.isNotBlank(dsn)) {
109-
Sentry.init(config -> {
110-
config.setDsn(dsn);
111-
config.setDiagnosticLevel(SentryLevel.ERROR);
112-
config.setServerName("Consent");
113-
config.addContextTag("Consent");
114-
config.addInAppInclude("org.broadinstitute");
115-
});
109+
Sentry.init(
110+
config -> {
111+
config.setDsn(dsn);
112+
config.setDiagnosticLevel(SentryLevel.ERROR);
113+
config.setServerName("Consent");
114+
config.addContextTag("Consent");
115+
config.addInAppInclude("org.broadinstitute");
116+
});
116117
Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit());
117118
} else {
118119
LOGGER.error("Unable to bootstrap sentry logging.");
119120
}
120121
} catch (Exception e) {
121-
LOGGER.error(MessageFormat.format("Exception loading sentry properties: {0}", e.getMessage()));
122+
LOGGER.error(
123+
MessageFormat.format("Exception loading sentry properties: {0}", e.getMessage()));
122124
}
123125
new ConsentApplication().run(args);
124126
LOGGER.info("Consent Application Started");
@@ -187,18 +189,24 @@ public void run(ConsentConfiguration config, Environment env) {
187189

188190
// Authentication filters
189191
final OAuthAuthenticator authenticator = injector.getProvider(OAuthAuthenticator.class).get();
190-
final DuosUserAuthenticator duosUserAuthenticator = injector.getProvider(DuosUserAuthenticator.class).get();
191-
final AuthorizationHelper authorizationHelper = injector.getProvider(AuthorizationHelper.class).get();
192+
final DuosUserAuthenticator duosUserAuthenticator =
193+
injector.getProvider(DuosUserAuthenticator.class).get();
194+
final AuthorizationHelper authorizationHelper =
195+
injector.getProvider(AuthorizationHelper.class).get();
192196
// Requests annotated with @Auth AuthUser will be authenticated through this filter
193-
final AuthFilter<String, AuthUser> primaryAuthFilter = new OAuthCustomAuthFilter<>(authenticator, authorizationHelper);
194-
// Requests annotated with @Auth DuosUser will be authenticated through this filter and are guaranteed to have a populated User object
195-
final AuthFilter<String, DuosUser> duosAuthUserFilter = new OAuthCustomAuthFilter<>(duosUserAuthenticator, authorizationHelper);
196-
final PolymorphicAuthDynamicFeature<AuthUser> feature = new PolymorphicAuthDynamicFeature<>(
197-
Map.of(
198-
AuthUser.class, primaryAuthFilter,
199-
DuosUser.class, duosAuthUserFilter));
200-
final AbstractBinder binder = new PolymorphicAuthValueFactoryProvider.Binder<>(
201-
Set.of(AuthUser.class, DuosUser.class));
197+
final AuthFilter<String, AuthUser> primaryAuthFilter =
198+
new OAuthCustomAuthFilter<>(authenticator, authorizationHelper);
199+
// Requests annotated with @Auth DuosUser will be authenticated through this filter and are
200+
// guaranteed to have a populated User object
201+
final AuthFilter<String, DuosUser> duosAuthUserFilter =
202+
new OAuthCustomAuthFilter<>(duosUserAuthenticator, authorizationHelper);
203+
final PolymorphicAuthDynamicFeature<AuthUser> feature =
204+
new PolymorphicAuthDynamicFeature<>(
205+
Map.of(
206+
AuthUser.class, primaryAuthFilter,
207+
DuosUser.class, duosAuthUserFilter));
208+
final AbstractBinder binder =
209+
new PolymorphicAuthValueFactoryProvider.Binder<>(Set.of(AuthUser.class, DuosUser.class));
202210
env.jersey().register(feature);
203211
env.jersey().register(binder);
204212

@@ -224,15 +232,16 @@ private void initializeLiquibase(ConsentConfiguration config)
224232
values.set("ui", new LoggerUIService());
225233
} catch (IllegalAccessException | NoSuchFieldException ignored) {
226234
}
227-
Connection connection = DriverManager.getConnection(
228-
config.getDataSourceFactory().getUrl(),
229-
config.getDataSourceFactory().getUser(),
230-
config.getDataSourceFactory().getPassword()
231-
);
232-
Database database = DatabaseFactory.getInstance()
233-
.findCorrectDatabaseImplementation(new JdbcConnection(connection));
234-
Liquibase liquibase = new Liquibase(liquibaseFile(), new ClassLoaderResourceAccessor(),
235-
database);
235+
Connection connection =
236+
DriverManager.getConnection(
237+
config.getDataSourceFactory().getUrl(),
238+
config.getDataSourceFactory().getUser(),
239+
config.getDataSourceFactory().getPassword());
240+
Database database =
241+
DatabaseFactory.getInstance()
242+
.findCorrectDatabaseImplementation(new JdbcConnection(connection));
243+
Liquibase liquibase =
244+
new Liquibase(liquibaseFile(), new ClassLoaderResourceAccessor(), database);
236245
liquibase.update(new Contexts(), new LabelExpression());
237246
}
238247

@@ -246,5 +255,4 @@ private String liquibaseFile() {
246255
}
247256
return changeLogFile;
248257
}
249-
250258
}

0 commit comments

Comments
 (0)