Enforce method names

This commit is contained in:
ByteHamster 2020-02-02 17:47:41 +01:00
parent b2fb239853
commit 8f08bd1f6d
3 changed files with 24 additions and 23 deletions

View File

@ -4,10 +4,12 @@
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<property name="severity" value="error"/>
<property name="fileExtensions" value="java, xml"/>
<module name="SuppressionFilter">
<property name="file" value="suppressions.xml" />
</module>
<module name="TreeWalker">
<module name="OuterTypeFilename"/>
@ -91,6 +93,11 @@
<property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern"
value="Method name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="SingleLineJavadoc">
<property name="ignoreInlineTags" value="false"/>
</module>

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="MethodName" files="core/src/test/java/android/util/Log.java" />
</suppressions>

View File

@ -27,7 +27,6 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.export.opml.OpmlElement;
import de.danoeh.antennapod.core.export.opml.OpmlReader;
import de.danoeh.antennapod.core.export.opml.OpmlWriter;
@ -45,18 +44,6 @@ public class OpmlBackupAgent extends BackupAgentHelper {
addHelper(OPML_BACKUP_KEY, new OpmlBackupHelper(this));
}
private static void LOGD(String tag, String msg) {
if (BuildConfig.DEBUG && Log.isLoggable(tag, Log.DEBUG)) {
Log.d(tag, msg);
}
}
private static void LOGD(String tag, String msg, Throwable tr) {
if (BuildConfig.DEBUG && Log.isLoggable(tag, Log.DEBUG)) {
Log.d(tag, msg, tr);
}
}
/**
* Class for backing up and restoring the OPML file.
*/
@ -98,7 +85,7 @@ public class OpmlBackupAgent extends BackupAgentHelper {
// Compare checksum of new and old file to see if we need to perform a backup at all
if (digester != null) {
byte[] newChecksum = digester.digest();
LOGD(TAG, "New checksum: " + new BigInteger(1, newChecksum).toString(16));
Log.d(TAG, "New checksum: " + new BigInteger(1, newChecksum).toString(16));
// Get the old checksum
if (oldState != null) {
@ -108,10 +95,10 @@ public class OpmlBackupAgent extends BackupAgentHelper {
if (len != -1) {
byte[] oldChecksum = new byte[len];
inState.read(oldChecksum);
LOGD(TAG, "Old checksum: " + new BigInteger(1, oldChecksum).toString(16));
Log.d(TAG, "Old checksum: " + new BigInteger(1, oldChecksum).toString(16));
if (Arrays.equals(oldChecksum, newChecksum)) {
LOGD(TAG, "Checksums are the same; won't backup");
Log.d(TAG, "Checksums are the same; won't backup");
return;
}
}
@ -120,7 +107,7 @@ public class OpmlBackupAgent extends BackupAgentHelper {
writeNewStateDescription(newState, newChecksum);
}
LOGD(TAG, "Backing up OPML");
Log.d(TAG, "Backing up OPML");
byte[] bytes = byteStream.toByteArray();
data.writeEntityHeader(OPML_ENTITY_KEY, bytes.length);
data.writeEntityData(bytes, bytes.length);
@ -138,10 +125,10 @@ public class OpmlBackupAgent extends BackupAgentHelper {
@Override
public void restoreEntity(BackupDataInputStream data) {
LOGD(TAG, "Backup restore");
Log.d(TAG, "Backup restore");
if (!OPML_ENTITY_KEY.equals(data.getKey())) {
LOGD(TAG, "Unknown entity key: " + data.getKey());
Log.d(TAG, "Unknown entity key: " + data.getKey());
return;
}
@ -167,7 +154,7 @@ public class OpmlBackupAgent extends BackupAgentHelper {
try {
downloader.downloadFeed(mContext, feed);
} catch (DownloadRequestException e) {
LOGD(TAG, "Error while restoring/downloading feed", e);
Log.d(TAG, "Error while restoring/downloading feed", e);
}
}
} catch (XmlPullParserException e) {