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-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.
@@ -64,7 +64,7 @@ public class DefaultMessageConverter implements MessageConverter, BeanFactoryAwa
}
protected boolean asMap() {
return asMap;
return this.asMap;
}
@Override

View File

@@ -205,7 +205,7 @@ public class RFC5424SyslogParser {
private int mark;
public Reader(String l) {
line = l;
this.line = l;
}
public void mark() {
@@ -214,23 +214,23 @@ public class RFC5424SyslogParser {
public String getMarkedSegment() {
Assert.state(this.mark <= this.idx, "mark is greater than this.idx");
return this.line.substring(mark, this.idx);
return this.line.substring(this.mark, this.idx);
}
public int current() {
return line.charAt(this.idx);
return this.line.charAt(this.idx);
}
public int prev() {
return line.charAt(this.idx - 1);
return this.line.charAt(this.idx - 1);
}
public int getc() {
return line.charAt(this.idx++);
return this.line.charAt(this.idx++);
}
public int peek() {
return line.charAt(this.idx + 1);
return this.line.charAt(this.idx + 1);
}
public void ungetc() {
@@ -271,19 +271,19 @@ public class RFC5424SyslogParser {
}
public boolean is(char c) {
return line.charAt(this.idx) == c;
return this.line.charAt(this.idx) == c;
}
public boolean was(char c) {
return line.charAt(this.idx - 1) == c;
return this.line.charAt(this.idx - 1) == c;
}
public boolean isDigit() {
return Character.isDigit(line.charAt(this.idx));
return Character.isDigit(this.line.charAt(this.idx));
}
public void expect(char c) {
if (line.charAt(this.idx++) != c) {
if (this.line.charAt(this.idx++) != c) {
throw new IllegalStateException("Expected '" + c + "' @" + this.idx);
}
}
@@ -296,7 +296,7 @@ public class RFC5424SyslogParser {
}
public String rest() {
return line.substring(this.idx);
return this.line.substring(this.idx);
}
public String getIdentifier() {
@@ -346,11 +346,11 @@ public class RFC5424SyslogParser {
}
public int level() {
return level;
return this.level;
}
public String label() {
return label;
return this.label;
}
public static Severity parseInt(int syslogSeverity) {

View File

@@ -97,7 +97,7 @@ public class RFC6587SyslogDeserializer implements Deserializer<Map<String, ?>> {
else {
throw new IllegalStateException("Expected a digit or '<', got 0x" + Integer.toHexString(peek));
}
return parser.parse(line, octetCount, shortRead);
return this.parser.parse(line, octetCount, shortRead);
}
private boolean isDigit(int peek) {

View File

@@ -77,7 +77,7 @@ public abstract class SyslogReceivingChannelAdapterSupport extends MessageProduc
@Override
protected void onInit() {
super.onInit();
if (!converterSet) {
if (!this.converterSet) {
((DefaultMessageConverter) this.converter).setBeanFactory(this.getBeanFactory());
}
}
@@ -85,8 +85,8 @@ public abstract class SyslogReceivingChannelAdapterSupport extends MessageProduc
protected void convertAndSend(Message<?> message) {
try {
if (message instanceof ErrorMessage) {
if (logger.isDebugEnabled()) {
logger.debug("Error on syslog socket:" + ((ErrorMessage) message).getPayload().getMessage());
if (this.logger.isDebugEnabled()) {
this.logger.debug("Error on syslog socket:" + ((ErrorMessage) message).getPayload().getMessage());
}
}
else {