Skip to content

Commit a378d7c

Browse files
committed
whitespace, STS warnings, cleanup
1 parent 2ae427f commit a378d7c

File tree

31 files changed

+226
-165
lines changed

31 files changed

+226
-165
lines changed

grails-bootstrap/src/main/groovy/grails/build/interactive/completors/EscapingFileNameCompletor.groovy

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
/*
2+
* Copyright 2011 SpringSource.
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+
* http://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+
*/
116
package grails.build.interactive.completors
217

318
import jline.FileNameCompletor
419

5-
import java.util.regex.Pattern
6-
720
/**
821
* JLine Completor that does file path matching like FileNameCompletor,
922
* but in addition it escapes whitespace in completions with the '\'
@@ -15,14 +28,15 @@ import java.util.regex.Pattern
1528
class EscapingFileNameCompletor extends FileNameCompletor {
1629
/**
1730
* <p>Gets FileNameCompletor to create a list of candidates and then
18-
* inserts '\' before any whitespace characters in each of the candidates.
31+
* inserts '\' before any whitespace characters in each of the candidates.
1932
* If a candidate ends in a whitespace character, then that is <em>not</em>
2033
* escaped.</p>
2134
*/
2235
int complete(String buffer, int cursor, List candidates) {
23-
def retval = super.complete(buffer, cursor, candidates)
36+
int retval = super.complete(buffer, cursor, candidates)
2437

25-
for (int i = 0; i < candidates.size(); i++) {
38+
int count = candidates.size()
39+
for (int i = 0; i < count; i++) {
2640
candidates[i] = candidates[i].replaceAll(/(\s)(?!$)/, '\\\\$1')
2741
}
2842

grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/interactive/CandidateListCompletionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* a completion matches a list of candidates
2828
*
2929
* @author Graeme Rocher
30-
* @since 1.4
30+
* @since 2.0
3131
*/
3232
public class CandidateListCompletionHandler implements CompletionHandler {
3333

grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/interactive/InteractiveMode.groovy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ package org.codehaus.groovy.grails.cli.interactive
1818
import grails.build.logging.GrailsConsole
1919
import grails.util.BuildSettings
2020
import grails.util.BuildSettingsHolder
21+
import grails.util.PluginBuildSettings
22+
23+
import java.awt.Desktop
2124

2225
import org.codehaus.groovy.grails.cli.GrailsScriptRunner
2326
import org.codehaus.groovy.grails.cli.ScriptExitException
2427
import org.codehaus.groovy.grails.cli.ScriptNotFoundException
28+
import org.codehaus.groovy.grails.cli.parsing.CommandLine
2529
import org.codehaus.groovy.grails.cli.parsing.ParseException
2630
import org.codehaus.groovy.grails.cli.support.MetaClassRegistryCleaner
27-
import org.codehaus.groovy.grails.cli.parsing.CommandLine
28-
import java.awt.Desktop
2931
import org.codehaus.groovy.grails.cli.support.UaaIntegration
30-
import grails.util.PluginBuildSettings
3132

3233
/**
3334
* Provides the implementation of interactive mode in Grails.
@@ -63,7 +64,7 @@ class InteractiveMode {
6364

6465
// Initialise the command options map supported by the 'open' command.
6566
openOptions = [
66-
'test-report': [
67+
'test-report': [
6768
path: new File(settings.testReportsDir, "html/index.html").absolutePath,
6869
description: "Opens the current test report (if it exists)" ],
6970
'dep-report': [

grails-bootstrap/src/test/groovy/grails/build/interactive/completors/RegexCompletorSpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RegexCompletorSpec extends Specification {
1111

1212
when: "the completor is invoked for a given string"
1313
def retval = completor.complete(source, 0, candidateList)
14-
14+
1515
then: "that string is the sole candidate and the return value is 0"
1616
candidateList.size() == 1
1717
candidateList[0] == source
@@ -29,7 +29,7 @@ class RegexCompletorSpec extends Specification {
2929

3030
when: "the completor is invoked for a given (non-matching) string"
3131
def retval = completor.complete(source, 0, candidateList)
32-
32+
3333
then: "the candidate list is empty and the return value is -1"
3434
candidateList.size() == 0
3535
retval == -1

grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/ClassPropertyFetcher.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@ public boolean isReadableProperty(String name) {
110110
private void init() {
111111
FieldCallback fieldCallback = new ReflectionUtils.FieldCallback() {
112112
public void doWith(Field field) {
113-
if (field.isSynthetic())
113+
if (field.isSynthetic()) {
114114
return;
115+
}
115116
final int modifiers = field.getModifiers();
116-
if (!Modifier.isPublic(modifiers))
117+
if (!Modifier.isPublic(modifiers)) {
117118
return;
119+
}
118120

119121
final String name = field.getName();
120122
if (name.indexOf('$') == -1) {
@@ -133,10 +135,12 @@ public void doWith(Field field) {
133135
MethodCallback methodCallback = new ReflectionUtils.MethodCallback() {
134136
public void doWith(Method method) throws IllegalArgumentException,
135137
IllegalAccessException {
136-
if (method.isSynthetic())
138+
if (method.isSynthetic()) {
137139
return;
138-
if (!Modifier.isPublic(method.getModifiers()))
140+
}
141+
if (!Modifier.isPublic(method.getModifiers())) {
139142
return;
143+
}
140144
if (Modifier.isStatic(method.getModifiers())
141145
&& method.getReturnType() != Void.class) {
142146
if (method.getParameterTypes().length == 0) {
@@ -148,15 +152,14 @@ public void doWith(Method method) throws IllegalArgumentException,
148152
} else if (name.length() > 2
149153
&& name.startsWith("is")
150154
&& Character.isUpperCase(name.charAt(2))
151-
&& (method.getReturnType() == Boolean.class || method
152-
.getReturnType() == boolean.class)) {
155+
&& (method.getReturnType() == Boolean.class ||
156+
method.getReturnType() == boolean.class)) {
153157
name = name.substring(2);
154158
}
155159
PropertyFetcher fetcher = new GetterPropertyFetcher(
156160
method, true);
157161
staticFetchers.put(name, fetcher);
158-
staticFetchers.put(StringUtils.uncapitalize(name),
159-
fetcher);
162+
staticFetchers.put(StringUtils.uncapitalize(name), fetcher);
160163
}
161164
}
162165
}
@@ -191,16 +194,13 @@ public void doWith(Method method) throws IllegalArgumentException,
191194
for (PropertyDescriptor desc : propertyDescriptors) {
192195
Method readMethod = desc.getReadMethod();
193196
if (readMethod != null) {
194-
boolean staticReadMethod = Modifier.isStatic(readMethod
195-
.getModifiers());
197+
boolean staticReadMethod = Modifier.isStatic(readMethod.getModifiers());
196198
if (staticReadMethod) {
197199
staticFetchers.put(desc.getName(),
198-
new GetterPropertyFetcher(readMethod,
199-
staticReadMethod));
200+
new GetterPropertyFetcher(readMethod, staticReadMethod));
200201
} else {
201202
instanceFetchers.put(desc.getName(),
202-
new GetterPropertyFetcher(readMethod,
203-
staticReadMethod));
203+
new GetterPropertyFetcher(readMethod, staticReadMethod));
204204
}
205205
}
206206
}

grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/cfg/GrailsConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Type safe abstraction over Grails configuration
3030
*
3131
* @author Graeme Rocher
32-
* @since 1.4
32+
* @since 2.0
3333
*/
3434
public class GrailsConfig {
3535

grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,10 @@ public GrailsRuntimeConfigurator(GrailsApplication application) {
8989
public GrailsRuntimeConfigurator(GrailsApplication application, ApplicationContext parent) {
9090
this.application = application;
9191
this.parent = parent;
92-
if (parent != null) {
93-
parent.containsBean(DATA_SOURCE_BEAN);
94-
}
9592

9693
try {
97-
pluginManager = parent != null ? parent.getBean(GrailsPluginManager.class) : null;
98-
pluginManager = pluginManager != null ? pluginManager : PluginManagerHolder.getPluginManager();
94+
pluginManager = parent == null ? null : parent.getBean(GrailsPluginManager.class);
95+
pluginManager = pluginManager == null ? PluginManagerHolder.getPluginManager() : pluginManager;
9996
} catch (BeansException e) {
10097
// ignore
10198
}
@@ -301,7 +298,7 @@ else if (LOG.isDebugEnabled()) {
301298
catch (Exception ex) {
302299
LOG.error("[RuntimeConfiguration] Unable to perform post initialization config: " + resourceName, ex);
303300
}
304-
301+
305302
GrailsRuntimeConfigurator.loadSpringGroovyResources(springConfig, app);
306303
}
307304

grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/spring/ReloadAwareAutowireCapableBeanFactory.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void autowireBeanProperties(Object existingBean, int autowireMode,
184184
boolean dependencyCheck) throws BeansException {
185185
if(autowireMode == AUTOWIRE_BY_NAME) {
186186
if(DISABLE_AUTOWIRE_BY_NAME_OPTIMIZATIONS || dependencyCheck || existingBean instanceof Aware) {
187-
super.autowireBeanProperties(existingBean, autowireMode, dependencyCheck);
187+
super.autowireBeanProperties(existingBean, autowireMode, dependencyCheck);
188188
} else {
189189
populateBeanInAutowireByName(existingBean);
190190
}
@@ -193,11 +193,11 @@ public void autowireBeanProperties(Object existingBean, int autowireMode,
193193
dependencyCheck);
194194
}
195195
}
196-
196+
197197
protected void populateBeanInAutowireByName(final Object existingBean) {
198198
// list of bean properties for that a bean exists
199199
Map<String, PropertyDescriptor> autowireableBeanProps = resolveAutowireablePropertyDescriptors(existingBean);
200-
200+
201201
// apply autowire instances directly without all the layers of Spring
202202
autowireBeanInAutowireByName(existingBean, autowireableBeanProps);
203203
}
@@ -234,9 +234,7 @@ public Object run() throws Exception {
234234
if (ex.getTargetException() instanceof ClassCastException) {
235235
throw new TypeMismatchException(propertyChangeEvent, pd.getPropertyType(), ex.getTargetException());
236236
}
237-
else {
238-
throw new MethodInvocationException(propertyChangeEvent, ex.getTargetException());
239-
}
237+
throw new MethodInvocationException(propertyChangeEvent, ex.getTargetException());
240238
}
241239
catch (Exception ex) {
242240
PropertyChangeEvent pce = new PropertyChangeEvent(existingBean, beanName, null, value);

grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/GrailsProjectCompiler.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class GrailsProjectCompiler {
111111
}
112112
}
113113
}
114-
114+
115115
AntBuilder getAnt() {
116116
if (ant == null) {
117117
ant = new AntBuilder()

grails-core/src/main/groovy/org/codehaus/groovy/grails/orm/support/TransactionManagerPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void initialize() {
7979
// otherwise we end up in an endless loop (it triggers the current method).
8080
String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
8181
beanFactory, PlatformTransactionManager.class, false, false);
82-
82+
8383
// If at least one is found, use the first of them as the
8484
// transaction manager for the application.
8585
if (beanNames.length > 0) {

grails-docs/src/test/groovy/grails/doc/internal/LegacyTocStrategySpec.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class LegacyTocStrategySpec extends Specification {
1111
def toc = strategy.generateToc([
1212
[name: "1. Introduction.gdoc"],
1313
[name: "1.1.10 Web Features.gdoc"],
14-
[name: "1.1 What's new in Grails 1.4?.gdoc"],
14+
[name: "1.1 What's new in Grails 2.0?.gdoc"],
1515
[name: "1.1.2. Core Features.gdoc"],
1616
[name: "1.2.1 Part One.gdoc"],
1717
[name: "2.2 Upgrading from previous versions of Grails.gdoc"],
@@ -28,9 +28,9 @@ class LegacyTocStrategySpec extends Specification {
2828
toc.children[0].title == "Introduction"
2929
toc.children[0].file == "1. Introduction.gdoc"
3030
toc.children[0].parent == toc
31-
toc.children[0].children*.name == ["1.1 What's new in Grails 1.4?", "1.2. Breaking Changes"]
32-
toc.children[0].children*.title == ["What's new in Grails 1.4?", "Breaking Changes"]
33-
toc.children[0].children*.file == ["1.1 What's new in Grails 1.4?.gdoc", "1.2. Breaking Changes.gdoc"]
31+
toc.children[0].children*.name == ["1.1 What's new in Grails 2.0?", "1.2. Breaking Changes"]
32+
toc.children[0].children*.title == ["What's new in Grails 2.0?", "Breaking Changes"]
33+
toc.children[0].children*.file == ["1.1 What's new in Grails 2.0?.gdoc", "1.2. Breaking Changes.gdoc"]
3434
toc.children[0].children[0].children[1].name == "1.1.2. Core Features"
3535
toc.children[0].children[0].children[1].title == "Core Features"
3636
toc.children[0].children[0].children[1].file == "1.1.2. Core Features.gdoc"

grails-docs/src/test/groovy/grails/doc/internal/YamlTocStrategySpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class YamlTocStrategySpec extends Specification {
2424
intro:
2525
title: Introduction
2626
whatsNew:
27-
title: What's new in Grails 1.4?
27+
title: What's new in Grails 2.0?
2828
devEnvFeatures: Development Environment Features
2929
coreFeatures: Core Features
3030
webFeatures: Web Features
@@ -47,7 +47,7 @@ class YamlTocStrategySpec extends Specification {
4747
toc.children[0].file == "intro.gdoc"
4848
toc.children[0].parent == toc
4949
toc.children[0].children*.name == ["whatsNew", "changes"]
50-
toc.children[0].children*.title == ["What's new in Grails 1.4?", "Breaking Changes"]
50+
toc.children[0].children*.title == ["What's new in Grails 2.0?", "Breaking Changes"]
5151
toc.children[0].children*.file == ["intro" + File.separatorChar + "whatsNew.gdoc", "intro" + File.separatorChar + "changes.gdoc"]
5252
toc.children[0].children[0].children[1].name == "coreFeatures"
5353
toc.children[0].children[0].children[1].title == "Core Features"

grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/GrailsHibernateTemplate.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2011 SpringSource.
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+
* http://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+
*/
116
package org.codehaus.groovy.grails.orm.hibernate;
217

318
import org.codehaus.groovy.grails.commons.GrailsApplication;
@@ -8,8 +23,8 @@
823
import org.springframework.orm.hibernate3.HibernateTemplate;
924

1025
public class GrailsHibernateTemplate extends HibernateTemplate {
26+
1127
public GrailsHibernateTemplate() {
12-
super();
1328
initialize(null);
1429
}
1530

@@ -27,22 +42,22 @@ public GrailsHibernateTemplate(SessionFactory sessionFactory, GrailsApplication
2742
super(sessionFactory);
2843
initialize(application);
2944
}
30-
45+
3146
private void initialize(GrailsApplication application) {
3247
setExposeNativeSession(true);
33-
if(application != null) {
48+
if (application != null) {
3449
setCacheQueries(GrailsHibernateUtil.isCacheQueriesByDefault(application));
3550
}
3651
}
3752

3853
public void applySettings(Query queryObject) {
39-
if(isExposeNativeSession()) {
54+
if (isExposeNativeSession()) {
4055
super.prepareQuery(queryObject);
4156
}
4257
}
4358

4459
public void applySettings(Criteria criteria) {
45-
if(isExposeNativeSession()) {
60+
if (isExposeNativeSession()) {
4661
super.prepareCriteria(criteria);
4762
}
4863
}

grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/HibernateSession.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
/**
5050
* Session implementation that wraps a Hibernate {@link org.hibernate.Session}.
51-
*
51+
*
5252
* @author Graeme Rocher
5353
* @since 1.0
5454
*/
@@ -193,10 +193,9 @@ public void delete(Object obj) {
193193
}
194194

195195
/**
196-
* Deletes all objects matching the given criteria
197-
*
198-
* @param criteria
199-
* The criteria
196+
* Deletes all objects matching the given criteria.
197+
*
198+
* @param criteria The criteria
200199
* @return The total number of records deleted
201200
*/
202201
public int deleteAll(final QueryableCriteria criteria) {
@@ -221,12 +220,10 @@ public Integer doInHibernate(Session session) throws HibernateException, SQLExce
221220
}
222221

223222
/**
224-
* Updates all objects matching the given criteria and property values
225-
*
226-
* @param criteria
227-
* The criteria
228-
* @param properties
229-
* The properties
223+
* Updates all objects matching the given criteria and property values.
224+
*
225+
* @param criteria The criteria
226+
* @param properties The properties
230227
* @return The total number of records updated
231228
*/
232229
public int updateAll(final QueryableCriteria criteria, final Map<String, Object> properties) {

0 commit comments

Comments
 (0)