Remove all tabs and add checkstyle rule that enforces no-tabs

Fixes SMACK-866.
This commit is contained in:
Florian Schmaus 2019-05-07 21:24:00 +02:00
parent 575364cc1f
commit 68d7d738b6
10 changed files with 104 additions and 158 deletions

View File

@ -40,10 +40,8 @@
<property name="message" value="Line containing only whitespace character(s)"/>
</module>
<module name="RegexpSingleline">
<!-- We use {2,} instead of + here to address the typical case where a file was written
with tabs but javadoc is causing '\t *' -->
<property name="format" value="^\t+ {2,}"/>
<property name="message" value="Line containing space(s) after tab(s)"/>
<property name="format" value="\t+"/>
<property name="message" value="Line containing tab character(s)"/>
</module>
<module name="RegexpSingleline">
<!--

View File

@ -440,9 +440,7 @@ public class PacketParserUtils {
String language = ParserUtils.getXmlLang(parser);
if (language != null && !"".equals(language.trim())) {
// CHECKSTYLE:OFF
presence.setLanguage(language);
// CHECKSTYLE:ON
presence.setLanguage(language);
}
// Parse sub-elements

View File

@ -781,44 +781,38 @@ public class PacketParserUtilsTest {
@Test
public void validateSimplePresence() throws Exception {
// CHECKSTYLE:OFF
String stanza = "<presence from='juliet@example.com/balcony' to='romeo@example.net'/>";
String stanza = "<presence from='juliet@example.com/balcony' to='romeo@example.net'/>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
// CHECKSTYLE:ON
assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
@Test
public void validatePresenceProbe() throws Exception {
// CHECKSTYLE:OFF
String stanza = "<presence from='mercutio@example.com' id='xv291f38' to='juliet@example.com' type='unsubscribed'/>";
String stanza = "<presence from='mercutio@example.com' id='xv291f38' to='juliet@example.com' type='unsubscribed'/>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertEquals(Presence.Type.unsubscribed, presence.getType());
// CHECKSTYLE:ON
assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertEquals(Presence.Type.unsubscribed, presence.getType());
}
@Test
public void validatePresenceOptionalElements() throws Exception {
// CHECKSTYLE:OFF
String stanza = "<presence xml:lang='en' type='unsubscribed'>"
+ "<show>dnd</show>"
+ "<status>Wooing Juliet</status>"
+ "<priority>1</priority>"
+ "</presence>";
String stanza = "<presence xml:lang='en' type='unsubscribed'>"
+ "<show>dnd</show>"
+ "<status>Wooing Juliet</status>"
+ "<priority>1</priority>"
+ "</presence>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertEquals(Presence.Type.unsubscribed, presence.getType());
assertEquals("dnd", presence.getMode().name());
assertEquals("en", presence.getLanguage());
assertEquals("Wooing Juliet", presence.getStatus());
assertEquals(1, presence.getPriority());
// CHECKSTYLE:ON
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertEquals(Presence.Type.unsubscribed, presence.getType());
assertEquals("dnd", presence.getMode().name());
assertEquals("en", presence.getLanguage());
assertEquals("Wooing Juliet", presence.getStatus());
assertEquals(1, presence.getPriority());
}
// @Test

View File

@ -257,11 +257,9 @@ public class EnhancedDebugger extends SmackDebugger {
new DefaultTableModel(
new Object[] {"Hide", "Timestamp", "", "", "Message", "Id", "Type", "To", "From"},
0) {
// CHECKSTYLE:OFF
private static final long serialVersionUID = 8136121224474217264L;
@Override
private static final long serialVersionUID = 8136121224474217264L;
@Override
public boolean isCellEditable(int rowIndex, int mColIndex) {
// CHECKSTYLE:ON
return false;
}
@ -689,11 +687,9 @@ public class EnhancedDebugger extends SmackDebugger {
new DefaultTableModel(new Object[][] { {"IQ", 0, 0}, {"Message", 0, 0},
{"Presence", 0, 0}, {"Other", 0, 0}, {"Total", 0, 0}},
new Object[] {"Type", "Received", "Sent"}) {
// CHECKSTYLE:OFF
private static final long serialVersionUID = -6793886085109589269L;
@Override
private static final long serialVersionUID = -6793886085109589269L;
@Override
public boolean isCellEditable(int rowIndex, int mColIndex) {
// CHECKSTYLE:ON
return false;
}
};

View File

@ -131,10 +131,8 @@ public class PrivacyItem {
* @return the allow communication status.
*/
public boolean isAllow() {
// CHECKSTYLE:OFF
return allow;
}
// CHECKSTYLE:ON
return allow;
}
/**
* Returns whether the receiver allow or deny incoming IQ stanzas or not.
@ -142,10 +140,8 @@ public class PrivacyItem {
* @return the iq filtering status.
*/
public boolean isFilterIQ() {
// CHECKSTYLE:OFF
return filterIQ;
}
// CHECKSTYLE:ON
return filterIQ;
}
/**
* Sets whether the receiver allows or denies incoming IQ stanzas or not.
@ -153,11 +149,8 @@ public class PrivacyItem {
* @param filterIQ indicates if the receiver allows or denies incoming IQ stanzas.
*/
public void setFilterIQ(boolean filterIQ) {
// CHECKSTYLE:OFF
this.filterIQ = filterIQ;
}
// CHECKSTYLE:ON
this.filterIQ = filterIQ;
}
/**
* Returns whether the receiver allows or denies incoming messages or not.
@ -165,10 +158,8 @@ public class PrivacyItem {
* @return the message filtering status.
*/
public boolean isFilterMessage() {
// CHECKSTYLE:OFF
return filterMessage;
}
// CHECKSTYLE:ON
return filterMessage;
}
/**
* Sets wheather the receiver allows or denies incoming messages or not.
@ -176,10 +167,8 @@ public class PrivacyItem {
* @param filterMessage indicates if the receiver allows or denies incoming messages or not.
*/
public void setFilterMessage(boolean filterMessage) {
// CHECKSTYLE:OFF
this.filterMessage = filterMessage;
}
// CHECKSTYLE:ON
this.filterMessage = filterMessage;
}
/**
* Returns whether the receiver allows or denies incoming presence or not.
@ -187,10 +176,8 @@ public class PrivacyItem {
* @return the iq filtering incoming presence status.
*/
public boolean isFilterPresenceIn() {
// CHECKSTYLE:OFF
return filterPresenceIn;
}
// CHECKSTYLE:ON
return filterPresenceIn;
}
/**
* Sets whether the receiver allows or denies incoming presence or not.
@ -198,10 +185,8 @@ public class PrivacyItem {
* @param filterPresenceIn indicates if the receiver allows or denies filtering incoming presence.
*/
public void setFilterPresenceIn(boolean filterPresenceIn) {
// CHECKSTYLE:OFF
this.filterPresenceIn = filterPresenceIn;
}
// CHECKSTYLE:ON
this.filterPresenceIn = filterPresenceIn;
}
/**
* Returns whether the receiver allows or denies incoming presence or not.
@ -209,10 +194,8 @@ public class PrivacyItem {
* @return the iq filtering incoming presence status.
*/
public boolean isFilterPresenceOut() {
// CHECKSTYLE:OFF
return filterPresenceOut;
}
// CHECKSTYLE:ON
return filterPresenceOut;
}
/**
* Sets whether the receiver allows or denies outgoing presence or not.
@ -220,10 +203,8 @@ public class PrivacyItem {
* @param filterPresenceOut indicates if the receiver allows or denies filtering outgoing presence
*/
public void setFilterPresenceOut(boolean filterPresenceOut) {
// CHECKSTYLE:OFF
this.filterPresenceOut = filterPresenceOut;
}
// CHECKSTYLE:ON
this.filterPresenceOut = filterPresenceOut;
}
/**
* Returns the order where the receiver is processed. List items are processed in
@ -235,10 +216,8 @@ public class PrivacyItem {
* @return the order number.
*/
public long getOrder() {
// CHECKSTYLE:OFF
return order;
}
// CHECKSTYLE:ON
return order;
}
/**
* Returns the type hold the kind of communication it will allow or block.
@ -248,9 +227,7 @@ public class PrivacyItem {
*/
public Type getType() {
return type;
// CHECKSTYLE:OFF
}
// CHECKSTYLE:ON
}
/**
* Returns the element identifier to apply the action.
@ -265,9 +242,7 @@ public class PrivacyItem {
*/
public String getValue() {
return value;
// CHECKSTYLE:OFF
}
// CHECKSTYLE:ON
}
/**
* Returns whether the receiver allows or denies every kind of communication.
@ -278,23 +253,22 @@ public class PrivacyItem {
* @return the all communications status.
*/
public boolean isFilterEverything() {
// CHECKSTYLE:OFF
return !(this.isFilterIQ() || this.isFilterMessage() || this.isFilterPresenceIn()
|| this.isFilterPresenceOut());
}
return !(this.isFilterIQ() || this.isFilterMessage() || this.isFilterPresenceIn()
|| this.isFilterPresenceOut());
}
/**
* Answer an xml representation of the receiver according to the RFC 3921.
*
* @return the text xml representation.
/**
* Answer an xml representation of the receiver according to the RFC 3921.
*
* @return the text xml representation.
*/
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<item");
if (this.isAllow()) {
buf.append(" action=\"allow\"");
buf.append(" action=\"allow\"");
} else {
buf.append(" action=\"deny\"");
buf.append(" action=\"deny\"");
}
buf.append(" order=\"").append(getOrder()).append('"');
if (getType() != null) {
@ -304,24 +278,23 @@ public class PrivacyItem {
buf.append(" value=\"").append(getValue()).append('"');
}
if (isFilterEverything()) {
buf.append("/>");
buf.append("/>");
} else {
buf.append('>');
if (this.isFilterIQ()) {
buf.append("<iq/>");
buf.append('>');
if (this.isFilterIQ()) {
buf.append("<iq/>");
}
if (this.isFilterMessage()) {
buf.append("<message/>");
if (this.isFilterMessage()) {
buf.append("<message/>");
}
if (this.isFilterPresenceIn()) {
buf.append("<presence-in/>");
if (this.isFilterPresenceIn()) {
buf.append("<presence-in/>");
}
if (this.isFilterPresenceOut()) {
buf.append("<presence-out/>");
if (this.isFilterPresenceOut()) {
buf.append("<presence-out/>");
}
buf.append("</item>");
buf.append("</item>");
}
// CHECKSTYLE:ON
return buf.toString();
}

View File

@ -155,9 +155,7 @@ public final class ChatManager extends Manager{
Message message = (Message) packet;
Chat chat;
if (message.getThread() == null) {
// CHECKSTYLE:OFF
chat = getUserChat(message.getFrom());
// CHECKSTYLE:ON
chat = getUserChat(message.getFrom());
}
else {
chat = getThreadChat(message.getThread());

View File

@ -113,31 +113,28 @@ public class MacroGroup {
}
public String toXML() {
// CHECKSTYLE:OFF
StringBuilder buf = new StringBuilder();
buf.append("<macrogroup>");
buf.append("<title>" + getTitle() + "</title>");
buf.append("<macros>");
for (Macro macro : getMacros())
{
buf.append("<macro>");
buf.append("<title>" + macro.getTitle() + "</title>");
buf.append("<type>" + macro.getType() + "</type>");
buf.append("<description>" + macro.getDescription() + "</description>");
buf.append("<response>" + macro.getResponse() + "</response>");
buf.append("</macro>");
}
buf.append("</macros>");
StringBuilder buf = new StringBuilder();
buf.append("<macrogroup>");
buf.append("<title>" + getTitle() + "</title>");
buf.append("<macros>");
for (Macro macro : getMacros()) {
buf.append("<macro>");
buf.append("<title>" + macro.getTitle() + "</title>");
buf.append("<type>" + macro.getType() + "</type>");
buf.append("<description>" + macro.getDescription() + "</description>");
buf.append("<response>" + macro.getResponse() + "</response>");
buf.append("</macro>");
}
buf.append("</macros>");
if (getMacroGroups().size() > 0) {
buf.append("<macroGroups>");
for (MacroGroup groups : getMacroGroups()) {
buf.append(groups.toXML());
}
buf.append("</macroGroups>");
}
buf.append("</macrogroup>");
return buf.toString();
// CHECKSTYLE:ON
if (getMacroGroups().size() > 0) {
buf.append("<macroGroups>");
for (MacroGroup groups : getMacroGroups()) {
buf.append(groups.toXML());
}
buf.append("</macroGroups>");
}
buf.append("</macrogroup>");
return buf.toString();
}
}

View File

@ -83,11 +83,9 @@ public class Macros extends IQ {
buf.append("<personal>true</personal>");
}
if (getPersonalMacroGroup() != null) {
// CHECKSTYLE:OFF
buf.append("<personalMacro>");
buf.append(StringUtils.escapeForXmlText(getPersonalMacroGroup().toXML()));
buf.append("</personalMacro>");
// CHECKSTYLE:ON
buf.append("<personalMacro>");
buf.append(StringUtils.escapeForXmlText(getPersonalMacroGroup().toXML()));
buf.append("</personalMacro>");
}
return buf;

View File

@ -478,17 +478,13 @@ public class Workgroup {
private void fireInvitationEvent(WorkgroupInvitation invitation) {
for (WorkgroupInvitationListener listener : invitationListeners) {
// CHECKSTYLE:OFF
listener.invitationReceived(invitation);
// CHECKSTYLE:ON
listener.invitationReceived(invitation);
}
}
private void fireQueueJoinedEvent() {
for (QueueListener listener : queueListeners) {
// CHECKSTYLE:OFF
listener.joinedQueue();
// CHECKSTYLE:ON
listener.joinedQueue();
}
}

View File

@ -50,30 +50,29 @@ public class RosterExchangeProvider extends ExtensionElementProvider<RosterExcha
@Override
public RosterExchange parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException {
// CHECKSTYLE:OFF
RosterExchange rosterExchange = new RosterExchange();
boolean done = false;
RemoteRosterEntry remoteRosterEntry;
Jid jid = null;
String name = "";
ArrayList<String> groupsName = new ArrayList<>();
String name = "";
ArrayList<String> groupsName = new ArrayList<>();
while (!done) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT) {
if (parser.getName().equals("item")) {
// Reset this variable since they are optional for each item
groupsName = new ArrayList<>();
// Initialize the variables from the parsed XML
// Reset this variable since they are optional for each item
groupsName = new ArrayList<>();
// Initialize the variables from the parsed XML
jid = ParserUtils.getJidAttribute(parser);
name = parser.getAttributeValue("", "name");
}
if (parser.getName().equals("group")) {
groupsName.add(parser.nextText());
groupsName.add(parser.nextText());
}
} else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if (parser.getName().equals("item")) {
// Create packet.
remoteRosterEntry = new RemoteRosterEntry(jid, name, groupsName.toArray(new String[groupsName.size()]));
// Create packet.
remoteRosterEntry = new RemoteRosterEntry(jid, name, groupsName.toArray(new String[groupsName.size()]));
rosterExchange.addRosterEntry(remoteRosterEntry);
}
if (parser.getName().equals("x")) {
@ -81,7 +80,6 @@ public class RosterExchangeProvider extends ExtensionElementProvider<RosterExcha
}
}
}
// CHECKSTYLE:ON
return rosterExchange;
}