Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Error Prone code style verification #632

Merged
merged 40 commits into from
Oct 31, 2020
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5ae71f6
Add Error Prone code style verification
vlsi Oct 18, 2020
43217ec
Remove LoggingManager class (it has been deprecated since JMeter 3.2)
vlsi Oct 18, 2020
797f9e4
Use UTF-8 encoding in BeanShellClient instead of platform-specific one
vlsi Oct 18, 2020
f6b1bfa
Add JavaDoc summaries to RandomVariableConfig, CounterConfig, JavaSam…
vlsi Oct 18, 2020
f5e3d7a
Suppress error-prone errors for junit-sample
vlsi Oct 18, 2020
ba94b52
Replace obsolete Vector and Hashtable with ArrayList and HashMap
vlsi Oct 18, 2020
b3b2eec
Replace LinkedList with ArrayList
vlsi Oct 18, 2020
db768c0
Remove uses of deprecated APIs
vlsi Oct 18, 2020
77d5d1b
Remove excessive parenthesis
vlsi Oct 18, 2020
73b925c
Avoid unsafe reflection cast
vlsi Oct 18, 2020
f5c64e1
Avoid use of Enumeration in ClassFinder
vlsi Oct 18, 2020
e8fbfa7
Fixup JavaDocs
vlsi Oct 18, 2020
9c92e99
Make constructors of abstract classes protected rather than public
vlsi Oct 18, 2020
7e42131
Avoid import Map.Entry to avoid amboguity
vlsi Oct 18, 2020
93e27d7
Use lower-case field names for non-static fields in StatCalculator
vlsi Oct 18, 2020
dc4bdc0
Make enums immutable
vlsi Oct 18, 2020
63d791c
Suppresss MissingSummary and EmptyBlockTag for now
vlsi Oct 18, 2020
599fcc9
Suppress deprecation warnings for TestResultAction
vlsi Oct 18, 2020
2fde32b
Suppress deprecation warnings in SamplerMetricFixedModeTest
vlsi Oct 18, 2020
80c3914
Suppress DefaultCharset usage: either suppress the warning or use a c…
vlsi Oct 18, 2020
e78352a
Fix InconsistentCapitalization warnings
vlsi Oct 18, 2020
369f651
Suppress JdkObsolete warnings for Enumeration
vlsi Oct 18, 2020
deb89ba
Remove unused variables
vlsi Oct 18, 2020
3d133a8
Suppress JdkObsolete warnings for usages of Date
vlsi Oct 18, 2020
5f84f1e
Add missing @Override annotations
vlsi Oct 18, 2020
b1255aa
Mark empty catch blocks with a comment
vlsi Oct 18, 2020
d756670
Suppress FutureReturnValueIgnored
vlsi Oct 18, 2020
bb34632
Suppress Thread.yield usage
vlsi Oct 18, 2020
c441e5b
Suppress JavaTimeDefaultTimeZone
vlsi Oct 18, 2020
ac19a29
Inline format specifiers when they are used only once
vlsi Oct 18, 2020
ecf72b7
Resolve MixedMutabilityReturnType: make the returned lists unmodifiable
vlsi Oct 18, 2020
8f5ca8d
Suppress UnnecessaryAnonymousClass as the only two warnings seem to b…
vlsi Oct 18, 2020
8ae3458
Resolve SynchronizeOnNonFinalField
vlsi Oct 18, 2020
9d7b694
Suppress warnings for Hashtable usage when the class is required for …
vlsi Oct 18, 2020
a4c1ab8
Move .lock() statements out of try to avoid accidetal release if lock…
vlsi Oct 18, 2020
ee0aead
Suppress StaticAssignmentInConstructor in Summarizer
vlsi Oct 18, 2020
7e2a47d
Suppress JdkObsolete when using appendReplacement(StringBuffer,...)
vlsi Oct 18, 2020
5fad27c
Suppress JavaLangClash for ThreadGroup
vlsi Oct 18, 2020
ebe65b8
Avoid NarrowingCompoundAssignment warning
vlsi Oct 18, 2020
150a275
Make members of final classes package-private
vlsi Oct 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove excessive parenthesis
  • Loading branch information
vlsi committed Oct 31, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 77d5d1bc92dd70555ed689bd0ec5f25685f68d66
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ public void init() {
@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if ((sampleResult != null) && (TESTER_COMMAND.equals(command))) {
if ((sampleResult != null) && TESTER_COMMAND.equals(command)) {
String response = jsonDataField.getText();
executeTester(response);
}
Original file line number Diff line number Diff line change
@@ -403,7 +403,7 @@ private double findMax(double[][] datas) {
double max = 0;
for (double[] data : datas) {
for (final double value : data) {
if ((!Double.isNaN(value)) && (value > max)) {
if (!Double.isNaN(value) && (value > max)) {
max = value;
}
}
Original file line number Diff line number Diff line change
@@ -295,7 +295,7 @@ public void add(final SampleResult sampleResult) {
if (samplerSelection.isSelected() && pattern != null) {
matcher = pattern.matcher(sampleLabel);
}
if ((matcher == null) || (matcher.find())) {
if (matcher == null || matcher.find()) {
final long startTimeMS = sampleResult.getStartTime();
final long startTimeInterval = startTimeMS / intervalValue;
JMeterUtils.runSafe(false, () -> {
Original file line number Diff line number Diff line change
@@ -282,7 +282,7 @@ public boolean executeAndShowTextFind(Pattern pattern) {
String body = contentDoc.getText(lastPosition, contentDoc.getLength() - lastPosition);
matcher = pattern.matcher(body);

if ((matcher != null) && (matcher.find())) {
if (matcher.find()) {
selection.removeAllHighlights();
selection.addHighlight(lastPosition + matcher.start(),
lastPosition + matcher.end(), painter);
Original file line number Diff line number Diff line change
@@ -477,7 +477,7 @@ public void add(final SampleResult res) {
if (columnSelection.isSelected() && pattern != null) {
matcher = pattern.matcher(sampleLabel);
}
if ((matcher == null) || (matcher.find())) {
if (matcher == null || matcher.find()) {
SamplingStatCalculator row = tableRows.computeIfAbsent(sampleLabel, label -> {
SamplingStatCalculator newRow = new SamplingStatCalculator(label);
newRows.addLast(newRow);
Original file line number Diff line number Diff line change
@@ -403,7 +403,7 @@ private void valueChanged(TreeSelectionEvent e, boolean forceRendering) {
* @return true if sampleResult is text or has empty content type
*/
protected static boolean isTextDataType(SampleResult sampleResult) {
return (SampleResult.TEXT).equals(sampleResult.getDataType())
return SampleResult.TEXT.equals(sampleResult.getDataType())
|| StringUtils.isEmpty(sampleResult.getDataType());
}

@@ -571,7 +571,7 @@ public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean failure = true;
Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
if (userObject instanceof SampleResult) {
failure = !(((SampleResult) userObject).isSuccessful());
failure = !((SampleResult) userObject).isSuccessful();
} else if (userObject instanceof AssertionResult) {
AssertionResult assertion = (AssertionResult) userObject;
failure = assertion.isError() || assertion.isFailure();
Original file line number Diff line number Diff line change
@@ -298,7 +298,7 @@ public void handleSampleResults(List<SampleResult> sampleResults, BackendListene
for (SampleResult sampleResult : sampleResults) {
userMetrics.add(sampleResult);
Matcher matcher = samplersToFilter.matcher(sampleResult.getSampleLabel());
if (!summaryOnly && (matcher.find())) {
if (!summaryOnly && matcher.find()) {
SamplerMetric samplerMetric = getSamplerMetricInfluxdb(sampleResult.getSampleLabel());
samplerMetric.add(sampleResult);
}
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ public final void addNode(Object node, HashTree subTree) {
protected Object addNodeToTree(Object node) {
if ( (node instanceof TestElement) // Check can cast for clone
// Don't clone NoThreadClone unless honourNoThreadClone == false
&& (!(honourNoThreadClone && (node instanceof NoThreadClone)))
&& !(honourNoThreadClone && node instanceof NoThreadClone)
) {
Object newNode = ((TestElement) node).clone();
newTree.add(objects, newNode);
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ public final class IconToolbarBean {
public String getActionNameResolve() {
final String aName;
try {
aName = (String) (ActionNames.class.getField(this.actionName).get(null));
aName = (String) ActionNames.class.getField(this.actionName).get(null);
} catch (Exception e) {
log.warn("Toolbar icon Action names error: {}, use unknown action.", this.actionName); //$NON-NLS-1$
return this.actionName; // return unknown action names for display error msg
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ private void scheduleThread(JMeterThread thread, long now) {

// set the endtime for the Thread
if (getDuration() > 0) {// Duration is in seconds
thread.setEndTime(getDuration() * 1000 + (thread.getStartTime()));
thread.setEndTime(getDuration() * 1000 + thread.getStartTime());
} else {
throw new JMeterStopTestException("Invalid duration " + getDuration() + " set in Thread Group:" + getName());
}
Original file line number Diff line number Diff line change
@@ -169,7 +169,7 @@ protected Object processFileOrScript(ScriptEngine scriptEngine, final Bindings p
// Hack: bsh-2.0b5.jar BshScriptEngine implements Compilable but throws
// "java.lang.Error: unimplemented"
boolean supportsCompilable = scriptEngine instanceof Compilable
&& !("bsh.engine.BshScriptEngine".equals(scriptEngine.getClass().getName())); // NOSONAR // $NON-NLS-1$
&& !"bsh.engine.BshScriptEngine".equals(scriptEngine.getClass().getName()); // NOSONAR // $NON-NLS-1$
try {
if (!StringUtils.isEmpty(getFilename())) {
if (scriptFile.exists() && scriptFile.canRead()) {
@@ -245,7 +245,7 @@ public boolean compile()
String lang = getScriptLanguageWithDefault();
ScriptEngine scriptEngine = getInstance().getEngineByName(lang);
boolean supportsCompilable = scriptEngine instanceof Compilable
&& !("bsh.engine.BshScriptEngine".equals(scriptEngine.getClass().getName())); // NOSONAR // $NON-NLS-1$
&& !"bsh.engine.BshScriptEngine".equals(scriptEngine.getClass().getName()); // NOSONAR // $NON-NLS-1$
if(!supportsCompilable) {
return true;
}
Original file line number Diff line number Diff line change
@@ -157,7 +157,7 @@ static synchronized void logDetails(Logger logger, String stringToLog, String pr
}

final String threadName = Thread.currentThread().getName();
final String separator = (comment.isEmpty()) ? DEFAULT_SEPARATOR : comment;
final String separator = comment.isEmpty() ? DEFAULT_SEPARATOR : comment;

switch (prioLevel) {
case ERROR:
Original file line number Diff line number Diff line change
@@ -75,15 +75,15 @@ public String execute(SampleResult previousResult, Sampler currentSampler)

String charsToUse = null;//means no restriction
if (values.length >= CHARS) {
charsToUse = (values[CHARS - 1]).execute().trim();
charsToUse = values[CHARS - 1].execute().trim();
if (charsToUse.length() <= 0) { // empty chars, return to null
charsToUse = null;
}
}

String myName = "";//$NON-NLS-1$
if (values.length >= PARAM_NAME) {
myName = (values[PARAM_NAME - 1]).execute().trim();
myName = values[PARAM_NAME - 1].execute().trim();
}

String myValue = null;
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ public static boolean isAnchorMatched(HTTPSamplerBase newLink, HTTPSamplerBase c
Argument item = (Argument) argument.getObjectValue();
final String name = item.getName();
if (!query.contains(name + "=")) { // $NON-NLS-1$
if (!(matcher.contains(query, patternCache.getPattern(name, Perl5Compiler.READ_ONLY_MASK)))) {
if (!matcher.contains(query, patternCache.getPattern(name, Perl5Compiler.READ_ONLY_MASK))) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ protected void computeFromPostBody(HTTPSamplerBase sampler,
// If it was a HTTP GET request, then all parameters in the URL
// has been handled by the sampler.setPath above, so we just need
// to do parse the rest of the request if it is not a GET request
if((!HTTPConstants.CONNECT.equals(request.getMethod())) && (!HTTPConstants.GET.equals(request.getMethod()))) {
if(!HTTPConstants.CONNECT.equals(request.getMethod()) && !HTTPConstants.GET.equals(request.getMethod())) {
// Check if it was a multipart http post request
final String contentType = request.getContentType();
MultipartUrlConfig urlConfig = request.getMultipartConfig(contentType);
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ public void addFormActionsAndCharSet(String html, Map<String, String> formEncodi
Elements forms = document.select("form");
for (Element element : forms) {
String action = element.attr("action");
if( !(StringUtils.isEmpty(action)) ) {
if (!StringUtils.isEmpty(action)) {
// We use the page encoding where the form resides, as the
// default encoding for the form
String formCharSet = pageEncoding;
Original file line number Diff line number Diff line change
@@ -185,7 +185,7 @@ public void run() {
// Use with SSL connection
OutputStream outStreamClient = clientSocket.getOutputStream();

if ((request.getMethod().startsWith(HTTPConstants.CONNECT)) && (outStreamClient != null)) {
if (request.getMethod().startsWith(HTTPConstants.CONNECT) && (outStreamClient != null)) {
log.debug("{} Method CONNECT => SSL", port);
// write a OK response to browser, to engage SSL exchange
outStreamClient.write(
Original file line number Diff line number Diff line change
@@ -326,7 +326,7 @@ private String setConnectionCookies(URL url, CookieManager cookies) {
if(cookies != null) {
cookieHeader = cookies.getCookieHeaderForURL(url);
for (JMeterProperty jMeterProperty : cookies.getCookies()) {
Cookie cookie = (Cookie)(jMeterProperty.getObjectValue());
Cookie cookie = (Cookie) jMeterProperty.getObjectValue();
setInt(0xA009); // Cookie
setString(cookie.getName()+"="+cookie.getValue());//$NON-NLS-1$
}
Original file line number Diff line number Diff line change
@@ -1464,7 +1464,7 @@ private String getAllHeadersExceptCookie(HttpRequest method) {
private String getOnlyCookieFromHeaders(HttpRequest method) {
String cookieHeader= getFromHeadersMatchingPredicate(method, ONLY_COOKIE).trim();
if(!cookieHeader.isEmpty()) {
return cookieHeader.substring((HTTPConstants.HEADER_COOKIE_IN_REQUEST).length(), cookieHeader.length()).trim();
return cookieHeader.substring(HTTPConstants.HEADER_COOKIE_IN_REQUEST.length()).trim();
}
return "";
}
Original file line number Diff line number Diff line change
@@ -397,7 +397,7 @@ private void setConnectionHeaders(HttpURLConnection conn, URL u,
private String getOnlyCookieFromHeaders(HttpURLConnection conn, Map<String, String> securityHeaders) {
String cookieHeader= getFromConnectionHeaders(conn, securityHeaders, ONLY_COOKIE, false).trim();
if(!cookieHeader.isEmpty()) {
return cookieHeader.substring((HTTPConstants.HEADER_COOKIE_IN_REQUEST).length(), cookieHeader.length()).trim();
return cookieHeader.substring(HTTPConstants.HEADER_COOKIE_IN_REQUEST.length()).trim();
}
return "";
}
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ public class JavaTest extends AbstractJavaSamplerClient implements Serializable,
public static final long DEFAULT_SLEEP_MASK = 0xff;

/** Formatted string representation of the default SleepMask. */
private static final String DEFAULT_MASK_STRING = "0x" + (Long.toHexString(DEFAULT_SLEEP_MASK)).toUpperCase(java.util.Locale.ENGLISH);
private static final String DEFAULT_MASK_STRING = "0x" + Long.toHexString(DEFAULT_SLEEP_MASK).toUpperCase(java.util.Locale.ENGLISH);

/** The name used to store the SleepMask parameter. */
private static final String MASK_NAME = "Sleep_Mask";
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ public SampleResult runTest(JavaSamplerContext context) {
public Arguments getDefaultParameters() {
Arguments params = new Arguments();
params.addArgument("SleepTime", String.valueOf(DEFAULT_SLEEP_TIME));
params.addArgument("SleepMask", "0x" + (Long.toHexString(DEFAULT_SLEEP_MASK)).toUpperCase(java.util.Locale.ENGLISH));
params.addArgument("SleepMask", "0x" + Long.toHexString(DEFAULT_SLEEP_MASK).toUpperCase(java.util.Locale.ENGLISH));
return params;
}

Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ public void configure(TestElement element) {
servername.setText(element.getPropertyAsString(LDAPSampler.SERVERNAME));
port.setText(element.getPropertyAsString(LDAPSampler.PORT));
rootdn.setText(element.getPropertyAsString(LDAPSampler.ROOTDN));
CardLayout cl = (CardLayout) (cards.getLayout());
CardLayout cl = (CardLayout) cards.getLayout();
final String testType = element.getPropertyAsString(LDAPSampler.TEST);
if (testType.equals(LDAPSampler.ADD)) {
addTest.setSelected(true);
@@ -232,7 +232,7 @@ public void clearGui() {
*/
@Override
public void itemStateChanged(ItemEvent ie) {
CardLayout cl = (CardLayout) (cards.getLayout());
CardLayout cl = (CardLayout) cards.getLayout();
if (userDefined.isSelected()) {
if (addTest.isSelected()) {
cl.show(cards, "Add");
Original file line number Diff line number Diff line change
@@ -218,7 +218,7 @@ public void configure(TestElement element) {
comparefilt.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREFILT));
modddn.setText(element.getPropertyAsString(LDAPExtSampler.MODDDN));
newdn.setText(element.getPropertyAsString(LDAPExtSampler.NEWDN));
CardLayout cl = (CardLayout) (cards.getLayout());
CardLayout cl = (CardLayout) cards.getLayout();
final String testType = element.getPropertyAsString(LDAPExtSampler.TEST);
if (testType.equals(LDAPExtSampler.UNBIND)) {
unbind.setSelected(true);
@@ -383,7 +383,7 @@ public void clearGui() {
**************************************************************************/
@Override
public void itemStateChanged(ItemEvent ie) {
CardLayout cl = (CardLayout) (cards.getLayout());
CardLayout cl = (CardLayout) cards.getLayout();
if (addTest.isSelected()) {
cl.show(cards, CARDS_ADD);
} else if (deleteTest.isSelected()) {
Original file line number Diff line number Diff line change
@@ -536,7 +536,7 @@ private ModificationItem[] getUserModAttributes() {
while (iter.hasNext()) {
BasicAttribute attr;
LDAPArgument item = (LDAPArgument) iter.next().getObjectValue();
if ((item.getValue()).length()==0) {
if (item.getValue().length() == 0) {
attr = new BasicAttribute(item.getName());
} else {
attr = getBasicAttribute(item.getName(), item.getValue());