RequireThis rule and fixThis Gradle task

* `gradlew clean check -x test --parallel --continue` - to collect reports
* `gradlew fixThis --parallel` - to fix all possible vulnerabilities. With `-Dfile.encoding=UTF-8` on Windows

Since the `RequireThisCheck` doesn't see parents for anonymous classes (e.g. `Runnable` callback), its report doesn't contains the outer class name with `this.`,
therefore we still have to fix those cases manually.
Thanks to the wrong `replacer` just with `this.` we have uncompilable code enough easy to find problems.
Not so easy to fix for good readability though...

* Upgrade to Grade 2.12
* Upgrade to SonarQube native plugin

The fix contains at about 300 files. So, will be done on merge.

Fix `fixThis.gradle` according PR comments

Apply `fixThis` and also `fixModifiers` for test classes.
 Fix some `this.` inner issues manually.
 Make code polishing for long lines after `fixThis`

Fix conflicts and vulnerabilities after the rebase
This commit is contained in:
Artem Bilan
2016-03-17 17:02:15 -04:00
parent e189307ab6
commit 2b0598291c
348 changed files with 1828 additions and 1781 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,7 +90,7 @@ public class ChannelSecurityMetadataSource implements SecurityMetadataSource {
public Collection<ConfigAttribute> getAllConfigAttributes() {
Set<ConfigAttribute> allAttributes = new HashSet<ConfigAttribute>();
for (ChannelAccessPolicy policy : patternMappings.values()) {
for (ChannelAccessPolicy policy : this.patternMappings.values()) {
Collection<ConfigAttribute> receiveAttributes = policy.getConfigAttributesForReceive();
allAttributes.addAll(receiveAttributes);
Collection<ConfigAttribute> sendAttributes = policy.getConfigAttributesForSend();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,23 +56,23 @@ public class DefaultChannelAccessPolicy implements ChannelAccessPolicy {
"At least one of 'sendAccess' and 'receiveAccess' must not be null and have at least one entry.");
if (sendAccessDefined) {
String[] sendAccessValues = StringUtils.commaDelimitedListToStringArray(sendAccess);
configAttributeDefinitionForSend = new HashSet<ConfigAttribute>();
this.configAttributeDefinitionForSend = new HashSet<ConfigAttribute>();
for (String sendAccessValue : sendAccessValues) {
configAttributeDefinitionForSend.add(new SecurityConfig(StringUtils.trimAllWhitespace(sendAccessValue)));
this.configAttributeDefinitionForSend.add(new SecurityConfig(StringUtils.trimAllWhitespace(sendAccessValue)));
}
}
else {
configAttributeDefinitionForSend = Collections.emptySet();
this.configAttributeDefinitionForSend = Collections.emptySet();
}
if (receiveAccessDefined) {
String[] receiveAccessValues = StringUtils.commaDelimitedListToStringArray(receiveAccess);
configAttributeDefinitionForReceive = new HashSet<ConfigAttribute>();
this.configAttributeDefinitionForReceive = new HashSet<ConfigAttribute>();
for (String receiveAccessValue : receiveAccessValues) {
configAttributeDefinitionForReceive.add(new SecurityConfig(StringUtils.trimAllWhitespace(receiveAccessValue)));
this.configAttributeDefinitionForReceive.add(new SecurityConfig(StringUtils.trimAllWhitespace(receiveAccessValue)));
}
}
else {
configAttributeDefinitionForReceive = Collections.emptySet();
this.configAttributeDefinitionForReceive = Collections.emptySet();
}
}
@@ -90,22 +90,22 @@ public class DefaultChannelAccessPolicy implements ChannelAccessPolicy {
Assert.isTrue(sendAccessDefined || receiveAccessDefined,
"At least one of 'sendAccess' and 'receiveAccess' must not be null.");
if (sendAccessDefined) {
configAttributeDefinitionForSend = new HashSet<ConfigAttribute>();
this.configAttributeDefinitionForSend = new HashSet<ConfigAttribute>();
for (String sendAccessValue : sendAccess) {
configAttributeDefinitionForSend.add(new SecurityConfig(sendAccessValue));
this.configAttributeDefinitionForSend.add(new SecurityConfig(sendAccessValue));
}
}
else {
configAttributeDefinitionForSend = Collections.emptySet();
this.configAttributeDefinitionForSend = Collections.emptySet();
}
if (receiveAccessDefined) {
configAttributeDefinitionForReceive = new HashSet<ConfigAttribute>();
this.configAttributeDefinitionForReceive = new HashSet<ConfigAttribute>();
for (String receiveAccessValue : receiveAccess) {
configAttributeDefinitionForReceive.add(new SecurityConfig(receiveAccessValue));
this.configAttributeDefinitionForReceive.add(new SecurityConfig(receiveAccessValue));
}
}
else {
configAttributeDefinitionForReceive = Collections.emptySet();
this.configAttributeDefinitionForReceive = Collections.emptySet();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class ChannelSecurityInterceptorBeanPostProcessor extends AbstractAutoPro
public Object postProcessBeforeInitialization(Object bean, String beanName) {
if (this.accessPolicyMapping != null
&& bean instanceof ChannelSecurityInterceptor
&& accessPolicyMapping.containsKey(beanName)) {
&& this.accessPolicyMapping.containsKey(beanName)) {
Map<Pattern, ChannelAccessPolicy> accessPolicies = this.accessPolicyMapping.get(beanName);
ChannelSecurityMetadataSource securityMetadataSource =
(ChannelSecurityMetadataSource) ((ChannelSecurityInterceptor) bean).obtainSecurityMetadataSource();