Improved: Remove Checkstyle warning related to double parenthesis at start of lines (OFBIZ-12340)
At https://markmail.org/message/3mhzlqew3igad3r2 I reported an issue that I was not able to really qualify. After exchanging with a Checkstyle expert (see markmail thread). I was unable to find what in our checkstyle.xml file was wrongly throwing these warnings. I decided that there was no reason to throw those warnings. So I decided to put the SuppressionCommentFilter in our checkstyle.xml file and use CHECKSTYLE_OFF: ALMOST_ALL/CHECKSTYLE_ON: ALMOST_ALL around the concerned lines as documented here https://checkstyle.sourceforge.io/config_filters.html#SuppressionCommentFilter_Examples
This commit is contained in:
+2
@@ -467,7 +467,9 @@ public class CommunicationEventServices {
|
||||
try (EntityListIterator eli = eq.queryIterator()) {
|
||||
// Send an email to each contact list member
|
||||
// loop through the list iterator
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
for (GenericValue contactListPartyAndContactMech; (contactListPartyAndContactMech = eli.next()) != null;) {
|
||||
// CHECKSTYLE_N: ALMOST_ALL
|
||||
Debug.logInfo("Contact info: " + contactListPartyAndContactMech, MODULE);
|
||||
// Any exceptions thrown in this inner block will only relate to a single email of the list, so should
|
||||
// only be logged and not cause the service to return an error
|
||||
|
||||
@@ -49,6 +49,11 @@ under the License.
|
||||
|
||||
<module name="TreeWalker">
|
||||
<!-- Naming conventions -->
|
||||
<module name="SuppressionCommentFilter">
|
||||
<!-- see OFBIZ-12340 for details -->
|
||||
<property name="offCommentFormat" value="CHECKSTYLE_OFF: ALMOST_ALL"/>
|
||||
<property name="onCommentFormat" value="CHECKSTYLE_ON: ALMOST_ALL"/>
|
||||
</module>
|
||||
<module name="ConstantName"/>
|
||||
<module name="LocalFinalVariableName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
|
||||
@@ -34,7 +34,9 @@ public class NumberConverters implements ConverterLoader {
|
||||
protected static Number fromString(String str, Locale locale) throws ConversionException {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(locale);
|
||||
if (nf instanceof DecimalFormat) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((DecimalFormat) nf).setParseBigDecimal(true);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
try {
|
||||
return nf.parse(str);
|
||||
|
||||
@@ -477,7 +477,9 @@ public class HttpClient {
|
||||
}
|
||||
|
||||
if ((con instanceof HttpURLConnection)) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((HttpURLConnection) con).setInstanceFollowRedirects(followRedirects);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
if (Debug.verboseOn() || debug) {
|
||||
Debug.logVerbose("Connection is of type HttpURLConnection, more specifically: " + con.getClass().getName(), MODULE);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,9 @@ public final class ReferenceCleaner {
|
||||
public void run() {
|
||||
while (keepRunning) {
|
||||
try {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((Removable) QUEUE.remove()).remove();
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
} catch (Throwable t) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@@ -115,7 +115,9 @@ public final class SSLUtil {
|
||||
for (TrustManager mgr : mgrs) {
|
||||
if (mgr instanceof X509TrustManager) {
|
||||
try {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((X509TrustManager) mgr).checkClientTrusted(chain, authType);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
return true;
|
||||
} catch (CertificateException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
|
||||
@@ -154,7 +154,9 @@ public class URLConnector {
|
||||
// closes the HttpURLConnection does nothing to others
|
||||
private static void close(URLConnection con) {
|
||||
if (con instanceof HttpURLConnection) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((HttpURLConnection) con).disconnect();
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,7 +544,9 @@ public final class UtilCache<K, V> implements Serializable, EvictionListener<Obj
|
||||
|
||||
if (newInMemory > 0) {
|
||||
if (this.memoryTable instanceof ConcurrentLinkedHashMap<?, ?>) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((ConcurrentLinkedHashMap<?, ?>) this.memoryTable).setCapacity(newInMemory);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
return;
|
||||
}
|
||||
this.memoryTable = new Builder<Object, CacheLine<V>>()
|
||||
|
||||
+4
@@ -115,7 +115,9 @@ public class CatalinaContainer implements Container {
|
||||
ofBizRealm.setCredentialHandler(new SimpleCredentialHandler());
|
||||
}
|
||||
host.setRealm(ofBizRealm);
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((StandardHost) host).addValve(new SingleSignOn());
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
|
||||
// clustering, valves and connectors setup
|
||||
@@ -227,8 +229,10 @@ public class CatalinaContainer implements Container {
|
||||
host.setDeployOnStartup(false);
|
||||
host.setBackgroundProcessorDelay(5);
|
||||
host.setAutoDeploy(false);
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((StandardHost) host).setWorkDir(new File(System.getProperty(Globals.CATALINA_HOME_PROP),
|
||||
"work" + File.separator + host.getName()).getAbsolutePath());
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
|
||||
return host;
|
||||
}
|
||||
|
||||
@@ -150,8 +150,10 @@ public final class EntityExpr implements EntityCondition {
|
||||
@Override
|
||||
public void checkCondition(ModelEntity modelEntity) throws GenericModelException {
|
||||
if (lhs instanceof EntityCondition) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((EntityCondition) lhs).checkCondition(modelEntity);
|
||||
((EntityCondition) rhs).checkCondition(modelEntity);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -633,7 +633,9 @@ public class MimeMessageWrapper implements java.io.Serializable {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
byte[] buffer = new byte[4096];
|
||||
try {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
for (int n; (n = stream.read(buffer)) != -1;) {
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
builder.append(new String(buffer, 0, n, "UTF-8"));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -651,7 +653,9 @@ public class MimeMessageWrapper implements java.io.Serializable {
|
||||
protected ByteBuffer getByteBufferFromStream(InputStream stream) {
|
||||
byte[] buffer = new byte[4096];
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
for (int n; (n = stream.read(buffer)) != -1;) {
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
baos.write(buffer, 0, n);
|
||||
}
|
||||
return ByteBuffer.wrap(baos.toByteArray());
|
||||
|
||||
@@ -123,11 +123,13 @@ public class RmiServiceContainer implements Container {
|
||||
|
||||
// set the client auth flag on our custom SSL socket factory
|
||||
if (ssf != null && ssf instanceof org.apache.ofbiz.service.rmi.socket.ssl.SSLServerSocketFactory) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((org.apache.ofbiz.service.rmi.socket.ssl.SSLServerSocketFactory) ssf).setNeedClientAuth(clientAuth);
|
||||
((org.apache.ofbiz.service.rmi.socket.ssl.SSLServerSocketFactory) ssf).setKeyStoreAlias(ksAlias);
|
||||
if (keystore != null) {
|
||||
((org.apache.ofbiz.service.rmi.socket.ssl.SSLServerSocketFactory) ssf).setKeyStore(keystore, ksType, ksPass);
|
||||
}
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
|
||||
// get the delegator for this container
|
||||
|
||||
+2
@@ -115,7 +115,9 @@ public class AliasSupportedTransportFactory extends XmlRpcTransportFactoryImpl {
|
||||
@Override
|
||||
protected void close() throws XmlRpcClientException {
|
||||
if (con instanceof HttpURLConnection) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((HttpURLConnection) con).disconnect();
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -199,10 +199,12 @@ public class ModelTestSuite {
|
||||
prepareTest(subTests.nextElement());
|
||||
}
|
||||
} else if (test instanceof EntityTestCase) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((EntityTestCase) test).setDelegator(delegator);
|
||||
if (test instanceof OFBizTestCase) {
|
||||
((OFBizTestCase) test).setDispatcher(dispatcher);
|
||||
}
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
} else if (test instanceof GroovyScriptTestCase) {
|
||||
prepareGroovyScriptTestCase((GroovyScriptTestCase) test);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ import java.util.function.Predicate;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.ofbiz.base.util.Debug;
|
||||
import org.apache.ofbiz.base.util.UtilGenerics;
|
||||
import org.apache.ofbiz.base.util.UtilMisc;
|
||||
@@ -58,8 +60,6 @@ import org.apache.ofbiz.widget.model.ModelGrid;
|
||||
import org.apache.ofbiz.widget.model.ModelWidget;
|
||||
import org.apache.ofbiz.widget.renderer.html.HtmlWidgetRenderer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* A form rendering engine.
|
||||
*
|
||||
@@ -895,7 +895,9 @@ public class FormRenderer {
|
||||
|
||||
if (iter instanceof EntityListIterator) {
|
||||
try {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((EntityListIterator) iter).close();
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Error closing list form render EntityListIterator: " + e.toString(), MODULE);
|
||||
}
|
||||
@@ -1024,7 +1026,9 @@ public class FormRenderer {
|
||||
List<FieldGroupBase> inbetweenList = getInbetweenList(lastFieldGroup, currentFieldGroup);
|
||||
for (FieldGroupBase obj : inbetweenList) {
|
||||
if (obj instanceof ModelForm.Banner) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((ModelForm.Banner) obj).renderString(writer, context, formStringRenderer);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
}
|
||||
if (currentFieldGroup != null && (lastFieldGroup == null || !lastFieldGroupName.equals(currentFieldGroupName))) {
|
||||
@@ -1069,7 +1073,9 @@ public class FormRenderer {
|
||||
List<FieldGroupBase> inbetweenList = getInbetweenList(lastFieldGroup, currentFieldGroup);
|
||||
for (FieldGroupBase obj : inbetweenList) {
|
||||
if (obj instanceof ModelForm.Banner) {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((ModelForm.Banner) obj).renderString(writer, context, formStringRenderer);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,9 @@ public final class Paginator {
|
||||
// The EntityListIterator will be closed at the end of FormRenderer.renderItemRows()
|
||||
// Note: it's also used in MacroScreenRenderer.renderScreenletPaginateMenu() but I could not find where it's then closed, nor issues...
|
||||
try {
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((EntityListIterator) iter).beforeFirst();
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Error rewinding list form render EntityListIterator: " + e.toString(), MODULE);
|
||||
}
|
||||
|
||||
+4
@@ -253,7 +253,9 @@ public class HtmlMenuWrapper {
|
||||
*/
|
||||
public void setRequest(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((HtmlMenuRenderer) renderer).setRequest(request);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +264,9 @@ public class HtmlMenuWrapper {
|
||||
*/
|
||||
public void setResponse(HttpServletResponse response) {
|
||||
this.response = response;
|
||||
// CHECKSTYLE_OFF: ALMOST_ALL
|
||||
((HtmlMenuRenderer) renderer).setResponse(response);
|
||||
// CHECKSTYLE_ON: ALMOST_ALL
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user