Add checkstyle rule for 'synchronized' on Manager.getInstanceFor()

This commit is contained in:
Florian Schmaus 2019-04-15 09:46:43 +02:00
parent 488055948d
commit 11775ed6b0
2 changed files with 15 additions and 0 deletions

View File

@ -6,6 +6,11 @@
<module name="SuppressionFilter">
<property name="file" value="config/suppressions.xml"/>
</module>
<module name="SuppressWithPlainTextCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE\:OFF\:(\w+)"/>
<property name="onCommentFormat" value="CHECKSTYLE\:ON\:(\w+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="Header">
<property name="headerFile" value="config/${checkstyleLicenseHeader}.txt"/>
<property name="ignoreLines" value="3"/>
@ -61,6 +66,14 @@
<property name="format" value="^\s*//[^\s]"/>
<property name="message" value="Comment start ('//') followed by non-space character. You would not continue after a punctuation without a space, would you?"/>
</module>
<!-- Check for synchronized keyword on Manager's static
getInstanceFor() method. Note that if XMPPConnection is every
replaced with something else, then we need to change it here
too. -->
<module name="RegexpSingleline">
<property name="format" value="^\s*public(?!.*synchronized).*getInstanceFor\(XMPPConnection.*$"/>
<property name="message" value="getInstanceFor() should be synchronized"/>
</module>
<module name="JavadocPackage"/>
<module name="TreeWalker">
<module name="SuppressionCommentFilter"/>

View File

@ -178,7 +178,9 @@ public final class MamManager extends Manager {
* @param connection the XMPP connection to get the archive for.
* @return the instance of MamManager.
*/
// CHECKSTYLE:OFF:RegexpSingleline
public static MamManager getInstanceFor(XMPPConnection connection) {
// CHECKSTYLE:ON:RegexpSingleline
return getInstanceFor(connection, (Jid) null);
}