Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
Fixes violations for CodeNarc Checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed Sep 28, 2022
1 parent 6ed60b0 commit 3918c71
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class GroovyPageCompiler {
compilerConfig.setTargetDirectory(targetDir)
compilerConfig.setSourceEncoding(encoding)
ExecutorService threadPool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2)
CompletionService completionService = new ExecutorCompletionService(threadPool);
CompletionService completionService = new ExecutorCompletionService(threadPool)
List<Future<Map>> futures = []
try {
Integer collationLevel = Runtime.getRuntime().availableProcessors() * 2
Expand Down Expand Up @@ -137,11 +137,11 @@ class GroovyPageCompiler {
// Wait for up to 100ms to see if anything has completed.
// The completed future is returned if one is found; otherwise null.
// (Tune 100ms as desired)
def completed = completionService.poll(100, TimeUnit.MILLISECONDS);
def completed = completionService.poll(100, TimeUnit.MILLISECONDS)
if (completed != null) {
Map results = completed.get() as Map //need this to throw exceptions on main thread it seems
compileGSPRegistry += results
--pending;
--pending
}
}

Expand All @@ -152,7 +152,7 @@ class GroovyPageCompiler {
if (viewregistryFile.exists()) {
// only changed files are added to the mapping, read the existing mapping file
viewregistryFile.withInputStream { stream ->
views.load(new InputStreamReader(stream, "UTF-8"));
views.load(new InputStreamReader(stream, "UTF-8"))
}
}
views.putAll(compileGSPRegistry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class DefaultGrailsTagDateHelper implements GrailsTagDateHelper {
}
else {
throw new IllegalArgumentException("Cannot format class as date: " +
(date == null ? "<null>" : date.getClass().getName()));
(date == null ? "<null>" : date.getClass().getName()))
}
((DateTimeFormatter) formatter).format(instant)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class GrailsLayoutViewResolverPostProcessor implements BeanDefinitionRegistryPos
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
if (enabled && registry.containsBeanDefinition(GRAILS_VIEW_RESOLVER_BEAN_NAME)) {
BeanDefinition previousViewResolver = registry.getBeanDefinition(GRAILS_VIEW_RESOLVER_BEAN_NAME);
registry.removeBeanDefinition(GRAILS_VIEW_RESOLVER_BEAN_NAME);
BeanDefinition previousViewResolver = registry.getBeanDefinition(GRAILS_VIEW_RESOLVER_BEAN_NAME)
registry.removeBeanDefinition(GRAILS_VIEW_RESOLVER_BEAN_NAME)

GenericBeanDefinition beanDefinition = new GenericBeanDefinition()
beanDefinition.beanClass = layoutViewResolverClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TagLibraryMetaUtils {
@CompileStatic
static registerMethodMissingForTags(MetaClass metaClass, TagLibraryLookup gspTagLibraryLookup, String namespace, String name,
boolean addAll = true, boolean overrideMethods = true) {
GroovyObject mc = (GroovyObject) metaClass;
GroovyObject mc = (GroovyObject) metaClass

if (overrideMethods || !doesMethodExist(metaClass, name, [Map, Closure] as Class[])) {
mc.setProperty(name) { Map attrs, Closure body ->
Expand Down Expand Up @@ -102,7 +102,7 @@ class TagLibraryMetaUtils {

@CompileStatic
static void registerPropertyMissingForTag(MetaClass metaClass, String name, Object result) {
GroovyObject mc = (GroovyObject) metaClass;
GroovyObject mc = (GroovyObject) metaClass
mc.setProperty(GrailsClassUtils.getGetterName(name)) { -> result }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class JspTagImpl implements JspTag {
tagBean.setPropertyValue key, value
}
else if (key && tag instanceof DynamicAttributes) {
((DynamicAttributes) tag).setDynamicAttribute(null, key, value);
((DynamicAttributes) tag).setDynamicAttribute(null, key, value)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,35 @@ trait TagLibrary implements WebAttributes, ServletAttributes, TagLibraryInvoker
* @throws MissingPropertyException When no tag namespace or tag is found
*/
Object propertyMissing(String name) {
TagLibraryLookup gspTagLibraryLookup = getTagLibraryLookup();
TagLibraryLookup gspTagLibraryLookup = getTagLibraryLookup()
if (gspTagLibraryLookup != null) {
Object result = gspTagLibraryLookup.lookupNamespaceDispatcher(name);
Object result = gspTagLibraryLookup.lookupNamespaceDispatcher(name)
if (result == null) {
String namespace = getTaglibNamespace()
GroovyObject tagLibrary = gspTagLibraryLookup.lookupTagLibrary(namespace, name);
GroovyObject tagLibrary = gspTagLibraryLookup.lookupTagLibrary(namespace, name)
if (tagLibrary == null) {
tagLibrary = gspTagLibraryLookup.lookupTagLibrary(TagOutput.DEFAULT_NAMESPACE, name);
tagLibrary = gspTagLibraryLookup.lookupTagLibrary(TagOutput.DEFAULT_NAMESPACE, name)
}

if (tagLibrary != null) {
Object tagProperty = tagLibrary.getProperty(name);
Object tagProperty = tagLibrary.getProperty(name)
if (tagProperty instanceof Closure) {
result = ((Closure<?>) tagProperty).clone();
result = ((Closure<?>) tagProperty).clone()
}
}
}

if (result != null && !Environment.isDevelopmentMode()) {
MetaClass mc = GrailsMetaClassUtils.getExpandoMetaClass(getClass())
TagLibraryMetaUtils.registerPropertyMissingForTag(mc, name, result);
TagLibraryMetaUtils.registerPropertyMissingForTag(mc, name, result)
}

if (result != null) {
return result;
return result
}
}

throw new MissingPropertyException(name, this.getClass());
throw new MissingPropertyException(name, this.getClass())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import org.grails.taglib.encoder.WithCodecHelper
trait TagLibraryInvoker extends WebAttributes {

private TagLibraryLookup tagLibraryLookup
private final boolean developmentMode = Environment.isDevelopmentMode();
private final boolean developmentMode = Environment.isDevelopmentMode()

@Autowired(required = false)
void setTagLibraryLookup(TagLibraryLookup tagLibraryLookup) {
Expand Down Expand Up @@ -77,8 +77,8 @@ trait TagLibraryInvoker extends WebAttributes {
def usedNamespace = getTaglibNamespace()
GroovyObject tagLibrary = lookup.lookupTagLibrary(usedNamespace, methodName)
if (tagLibrary == null) {
tagLibrary = lookup.lookupTagLibrary(TagOutput.DEFAULT_NAMESPACE, methodName);
usedNamespace = TagOutput.DEFAULT_NAMESPACE;
tagLibrary = lookup.lookupTagLibrary(TagOutput.DEFAULT_NAMESPACE, methodName)
usedNamespace = TagOutput.DEFAULT_NAMESPACE
}

if (tagLibrary) {
Expand Down

0 comments on commit 3918c71

Please sign in to comment.