Skip to content

Commit 1b7148e

Browse files
committed
style: reformat grails-core per styling rules
1 parent 1d2c678 commit 1b7148e

File tree

2,142 files changed

+35775
-35121
lines changed

Some content is hidden

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

2,142 files changed

+35775
-35121
lines changed

etc/config/checkstyle/checkstyle.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@
9797
<module name="SuppressWarningsFilter"/>
9898

9999
<!-- See http://checkstyle.sourceforge.net/config_filters.html#SuppressionFilter -->
100-
<!-- <module name="SuppressionFilter">-->
101-
<!-- <property name="file" value="${config_loc}/suppressions.xml"/>-->
102-
<!-- <property name="optional" value="false"/>-->
103-
<!-- </module>-->
100+
<module name="SuppressionFilter">
101+
<property name="file" value="${config_loc}/suppressions.xml"/>
102+
<property name="optional" value="false"/>
103+
</module>
104104

105105
<module name="TreeWalker">
106+
<module name="AvoidStarImport"/>
106107

107108
<!-- Needed for SuppressWarningsFilter -->
108109
<module name="SuppressWarningsHolder"/>
@@ -177,7 +178,9 @@
177178
<!-- Checks for blocks. You know, those {}'s -->
178179
<!-- See http://checkstyle.sf.net/config_blocks.html -->
179180
<module name="AvoidNestedBlocks"/>
180-
<module name="EmptyBlock"/>
181+
<module name="EmptyBlock">
182+
<property name="option" value="text"/>
183+
</module>
181184
<module name="LeftCurly"/>
182185
<module name="NeedBraces"/>
183186
<module name="RightCurly"/>
@@ -228,6 +231,8 @@
228231
<module name="TodoComment">
229232
<property name="severity" value="warning"/>
230233
</module>
234+
235+
<module name="SuppressionCommentFilter"/>
231236
</module>
232237

233238
</module>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ https://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
<!DOCTYPE suppressions PUBLIC
21+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
22+
"http://checkstyle.sourceforge.net/dtds/suppressions_1_1.dtd">
23+
<suppressions>
24+
<suppress checks="FileLength"
25+
files="GrailsDomainBinder.java|AbstractHibernateCriteriaBuilder.java|StreamCharBuffer.java"/>
26+
<!-- Ignore until we decide what to do with these files -->
27+
<!-- maybe replace with https://github.com/openjson/openjson -->
28+
<suppress files=".*[\\/]grails-web-common[\\/]src[\\/]main[\\/]groovy[\\/]org[\\/]grails[\\/]web[\\/]json[\\/].*" checks=".*"/>
29+
<suppress files=".*[\\/]grails-wrapper[\\/]src[\\/]main[\\/]java[\\/]grails[\\/]init[\\/]GrailsVersion.*" checks=".*"/>
30+
<suppress files=".*[\\/]grails-wrapper[\\/]src[\\/]main[\\/]java[\\/]grails[\\/]init[\\/]GrailsWrapperHome.*" checks=".*"/>
31+
</suppressions>

gradle/style-enforcement-config.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ apply plugin: 'io.spring.nohttp' // enforce https everywhere
2424
spotless {
2525
java {
2626
licenseHeaderFile(rootProject.file("etc/config/spotless/license.java"))
27-
target('src/main/java/**/*.java')
27+
target('src/main/java/**/*.java', 'src/main/groovy/**.java', 'grails-app/**.java')
2828
}
2929
groovy {
3030
licenseHeaderFile(rootProject.file("etc/config/spotless/license.java"))
31-
target('src/main/groovy/**.groovy', 'src/main/groovy/**.java')
31+
target('src/main/groovy/**.groovy', 'grails-app/**.groovy')
3232
}
3333
format 'javaMisc', {
3434
target('src/main/**/package-info.java', 'src/main/**/module-info.java')
@@ -37,7 +37,8 @@ spotless {
3737
}
3838

3939
checkstyle {
40-
configFile = project.rootProject.file('etc/config/checkstyle/checkstyle.xml')
40+
configFile = project.rootProject.layout.projectDirectory.file('etc/config/checkstyle/checkstyle.xml').asFile
41+
configDirectory = project.rootProject.layout.projectDirectory.dir('etc/config/checkstyle').asFile
4142

4243
// Per submodule
4344
maxErrors = 1

grails-async/core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ apply {
5050
from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
5151
from rootProject.layout.projectDirectory.file('gradle/publish-config.gradle')
5252
from rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
53+
from rootProject.layout.projectDirectory.file('gradle/style-enforcement-config.gradle')
5354
}

grails-async/core/src/main/groovy/grails/async/DelegateAsync.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
*/
1919
package grails.async
2020

21+
import org.codehaus.groovy.transform.GroovyASTTransformationClass
22+
2123
import java.lang.annotation.Documented
2224
import java.lang.annotation.ElementType
2325
import java.lang.annotation.Retention
2426
import java.lang.annotation.RetentionPolicy
2527
import java.lang.annotation.Target
2628

27-
import org.codehaus.groovy.transform.GroovyASTTransformationClass
28-
2929
/**
3030
* An AST transformation that takes each method in the given class and adds a delegate method that returns a {@link grails.async.Promise} and executes the method asynchronously.
3131
* For example given the following class:
@@ -39,7 +39,7 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass
3939
* If the annotation is applied to a new class:
4040
*
4141
* <pre><code>
42-
* @DelegateAsync(BookApi)
42+
* @DelegateAsync (BookApi)
4343
* class AsyncBookApi {}
4444
* </code></pre>
4545
*
@@ -65,5 +65,6 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass
6565
@Target([ElementType.TYPE, ElementType.FIELD])
6666
@GroovyASTTransformationClass("org.grails.async.transform.internal.DelegateAsyncTransformation")
6767
@interface DelegateAsync {
68+
6869
Class value() default DelegateAsync
6970
}

grails-async/core/src/main/groovy/grails/async/PromiseFactory.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ interface PromiseFactory {
5050
/**
5151
* Creates a promise with a value pre-bound to it
5252
* @param value The value
53-
* @param <T> The type of the value
53+
* @param <T> The type of the value
5454
* @return A Promise
5555
*/
5656
<T> Promise<T> createBoundPromise(T value)
5757

5858
/**
5959
* Creates an unfulfilled promise that returns the given type
6060
* @param returnType The return type
61-
* @param <T> The type of the class
61+
* @param <T> The type of the class
6262
* @return The unfulfilled promise
6363
*/
6464
<T> Promise<T> createPromise(Class<T> returnType)
@@ -76,23 +76,23 @@ interface PromiseFactory {
7676
* @param map The map
7777
* @return A promise
7878
*/
79-
<K,V> Promise<Map<K,V>> createPromise(Map<K, V> map)
79+
<K, V> Promise<Map<K, V>> createPromise(Map<K, V> map)
8080

8181
/**
8282
* Creates a promise from the given map where the values of the map are either closures or Promise instances
8383
*
8484
* @param map The map
8585
* @return A promise
8686
*/
87-
<K,V> Promise<Map<K,V>> createPromise(Map<K, V> map, List<PromiseDecorator> decorators)
87+
<K, V> Promise<Map<K, V>> createPromise(Map<K, V> map, List<PromiseDecorator> decorators)
8888

8989
/**
9090
* Creates a promise from one or more other promises
9191
*
9292
* @param promises The promises
9393
* @return The promise
9494
*/
95-
<T> Promise<List<T>> createPromise(Promise<T>...promises)
95+
<T> Promise<List<T>> createPromise(Promise<T>... promises)
9696

9797
/**
9898
* Creates a promise from one or many closures
@@ -132,7 +132,7 @@ interface PromiseFactory {
132132
* @param promises The promises
133133
* @return The list of bound values
134134
*/
135-
<T> List<T> waitAll(Promise<T>...promises)
135+
<T> List<T> waitAll(Promise<T>... promises)
136136
/**
137137
* Synchronously waits for all promises to complete returning a list of values
138138
*

grails-async/core/src/main/groovy/grails/async/PromiseList.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class PromiseList<T> implements Promise<List<T>> {
138138

139139
@Override
140140
boolean isDone() {
141-
return promises.every {promise -> promise.isDone() }
141+
return promises.every { promise -> promise.isDone() }
142142
}
143143

144144
@Override

grails-async/core/src/main/groovy/grails/async/PromiseMap.groovy

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ import java.util.concurrent.TimeUnit
3232
*/
3333
@AutoFinal
3434
@CompileStatic
35-
class PromiseMap<K,V> implements Promise<Map<K,V>> {
35+
class PromiseMap<K, V> implements Promise<Map<K, V>> {
3636

3737
protected LinkedHashMap<K, Promise<V>> promises = [:]
3838
protected LinkedHashMap<Promise<V>, K> promisesKeys = [:]
3939

4040
PromiseMap() {}
4141

42-
PromiseMap(Map<K,V> values) {
42+
PromiseMap(Map<K, V> values) {
4343
accept(values)
4444
}
4545

@@ -55,11 +55,11 @@ class PromiseMap<K,V> implements Promise<Map<K,V>> {
5555

5656
@Override
5757
boolean isDone() {
58-
return promisesKeys.keySet().every {it.isDone() }
58+
return promisesKeys.keySet().every { it.isDone() }
5959
}
6060

6161
@Override
62-
Promise<Map<K,V>> accept(Map<K,V> values) {
62+
Promise<Map<K, V>> accept(Map<K, V> values) {
6363
values.each { K key, Object value ->
6464
if (value instanceof Promise) {
6565
put(key, value as Promise<V>)
@@ -210,10 +210,10 @@ class PromiseMap<K,V> implements Promise<Map<K,V>> {
210210
*
211211
* @return A map where the values are obtained from the promises
212212
*/
213-
Map<K,V> get() throws Throwable {
213+
Map<K, V> get() throws Throwable {
214214
def promises = promises.values()
215-
Map<K,V> resultMap = [:]
216-
for(Promise<V> promise : promises) {
215+
Map<K, V> resultMap = [:]
216+
for (Promise<V> promise : promises) {
217217
V value = promise.get()
218218
resultMap.put(promisesKeys.get(promise), value)
219219
}
@@ -224,28 +224,28 @@ class PromiseMap<K,V> implements Promise<Map<K,V>> {
224224
* Synchronously return the populated map with all values obtained from promises used
225225
* inside the populated map
226226
*
227-
* @param timeout The timeout period
227+
* @param timeout The timeout period
228228
* @param units The timeout units
229229
* @return A map where the values are obtained from the promises
230230
*/
231-
Map<K,V> get(long timeout, TimeUnit units) throws Throwable {
231+
Map<K, V> get(long timeout, TimeUnit units) throws Throwable {
232232
List<Promise<V>> promises = new ArrayList<Promise<V>>(promises.values())
233233
Promises.waitAll(promises, timeout, units)
234-
Map<K,V> resultMap = [:]
235-
for(Promise<V> promise : promises) {
234+
Map<K, V> resultMap = [:]
235+
for (Promise<V> promise : promises) {
236236
V value = promise.get()
237237
resultMap.put(promisesKeys.get(promise), value)
238238
}
239239
return resultMap
240240
}
241241

242242
@Override
243-
Promise<Map<K,V>> onComplete(Closure<Map<K,V>> callable) {
243+
Promise<Map<K, V>> onComplete(Closure<Map<K, V>> callable) {
244244
List<Promise<V>> promises = new ArrayList<Promise<V>>(promises.values())
245245
Promises.onComplete(promises) { List<V> values ->
246-
Map<K,V> resultMap = [:]
246+
Map<K, V> resultMap = [:]
247247
int i = 0
248-
for(V value in values) {
248+
for (V value in values) {
249249
Promise<V> promise = promises[i]
250250
K key = promisesKeys.get(promise)
251251
resultMap.put(key, value)
@@ -258,13 +258,13 @@ class PromiseMap<K,V> implements Promise<Map<K,V>> {
258258
}
259259

260260
@Override
261-
Promise<Map<K,V>> onError(Closure<Map<K,V>> callable) {
261+
Promise<Map<K, V>> onError(Closure<Map<K, V>> callable) {
262262
Promises.onError(new ArrayList<Promise<V>>(promises.values()), callable)
263263
return this
264264
}
265265

266266
@Override
267-
Promise<Map<K, V>> then(Closure<Map<K,V>> callable) {
267+
Promise<Map<K, V>> then(Closure<Map<K, V>> callable) {
268268
return onComplete(callable)
269269
}
270270

0 commit comments

Comments
 (0)