1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +01:00

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"> <module name="SuppressionFilter">
<property name="file" value="config/suppressions.xml"/> <property name="file" value="config/suppressions.xml"/>
</module> </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"> <module name="Header">
<property name="headerFile" value="config/${checkstyleLicenseHeader}.txt"/> <property name="headerFile" value="config/${checkstyleLicenseHeader}.txt"/>
<property name="ignoreLines" value="3"/> <property name="ignoreLines" value="3"/>
@ -61,6 +66,14 @@
<property name="format" value="^\s*//[^\s]"/> <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?"/> <property name="message" value="Comment start ('//') followed by non-space character. You would not continue after a punctuation without a space, would you?"/>
</module> </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="JavadocPackage"/>
<module name="TreeWalker"> <module name="TreeWalker">
<module name="SuppressionCommentFilter"/> <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. * @param connection the XMPP connection to get the archive for.
* @return the instance of MamManager. * @return the instance of MamManager.
*/ */
// CHECKSTYLE:OFF:RegexpSingleline
public static MamManager getInstanceFor(XMPPConnection connection) { public static MamManager getInstanceFor(XMPPConnection connection) {
// CHECKSTYLE:ON:RegexpSingleline
return getInstanceFor(connection, (Jid) null); return getInstanceFor(connection, (Jid) null);
} }