Skip to content

Commit

Permalink
Merge pull request google#834 from cco3/soterpmd
Browse files Browse the repository at this point in the history
Fix pmd errors
  • Loading branch information
cco3 authored Sep 20, 2016
2 parents 8fbfb2c + 0265ef5 commit c384d94
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 14 deletions.
28 changes: 25 additions & 3 deletions android/PhysicalWeb/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'si.dlabs.soter'
apply plugin: 'pmd'

android {
compileSdkVersion 24
Expand Down Expand Up @@ -81,6 +82,27 @@ dependencies {
pmdRules files('config/pmd/pmd-ruleset.xml')
}

task customPmd(type: Pmd) {
ignoreFailures = false
ruleSetFiles = files("${project.rootDir}/app/config/pmd/pmd-ruleset.xml")
ruleSets = []

source 'src'
include '**/*.java'
exclude '**/gen/**'

reports {
xml {
enabled = false
destination "$project.buildDir/reports/pmd/pmd.xml"
}
html {
enabled = true
destination "$project.buildDir/reports/pmd/pmd.html"
}
}
}

soter {
checkstyle {
enabled true
Expand All @@ -96,10 +118,10 @@ soter {
}

pmd {
enabled true
// Soter currently forces pmd rules we don't want, so we need to include pmd ourselves.
enabled false
ignoreFailures false
}
}


check.dependsOn 'lint'
check.dependsOn 'customPmd', 'lint'
5 changes: 5 additions & 0 deletions android/PhysicalWeb/app/config/pmd/pmd-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
<rule ref="rulesets/java/finalizers.xml" />
<rule ref="rulesets/java/imports.xml" />
<rule ref="rulesets/java/logging-java.xml" />
<rule ref="rulesets/java/android.xml" />
<rule ref="rulesets/java/braces.xml" />
<rule ref="rulesets/java/strings.xml" />
<rule ref="rulesets/java/basic.xml">
<exclude name="AvoidUsingHardCodedIP" />
<exclude name="UselessParentheses" />
</rule>
<rule ref="rulesets/java/naming.xml">
<exclude name="AbstractNaming" />
Expand All @@ -28,4 +30,7 @@
<exclude name="ShortVariable" />
<exclude name="VariableNamingConventions" />
</rule>
<rule ref="rulesets/java/unnecessary.xml">
<exclude name="UselessParentheses" />
</rule>
</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public class FileBroadcastService extends Service {
// callbacks
/////////////////////////////////

@Override
public void onCreate() {
super.onCreate();
}

@Override
public IBinder onBind(Intent intent) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,13 @@ public void onPwsResultAbsent(String url) {
Toast.makeText(getApplicationContext(), getString(R.string.shorten_error),
Toast.LENGTH_LONG).show();
stopSelf();
return;
}

@Override
public void onPwsResultError(Collection<String> urls, int httpResponseCode, Exception e) {
Toast.makeText(getApplicationContext(), getString(R.string.shorten_error),
Toast.LENGTH_LONG).show();
stopSelf();
return;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public static boolean is16BitUuid(ParcelUuid parcelUuid) {
if (uuid.getLeastSignificantBits() != BASE_UUID.getUuid().getLeastSignificantBits()) {
return false;
}
return ((uuid.getMostSignificantBits() & 0xFFFF0000FFFFFFFFL) == 0x1000L);
return (uuid.getMostSignificantBits() & 0xFFFF0000FFFFFFFFL) == 0x1000L;
}

/**
Expand All @@ -296,6 +296,6 @@ public static boolean is32BitUuid(ParcelUuid parcelUuid) {
if (is16BitUuid(parcelUuid)) {
return false;
}
return ((uuid.getMostSignificantBits() & 0xFFFFFFFFL) == 0x1000L);
return (uuid.getMostSignificantBits() & 0xFFFFFFFFL) == 0x1000L;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static String toString(SparseArray<byte[]> array) {
StringBuilder buffer = new StringBuilder();
buffer.append('{');
for (int i = 0; i < array.size(); ++i) {
buffer.append(array.keyAt(i)).append("=").append(array.valueAt(i));
buffer.append(array.keyAt(i)).append('=').append(array.valueAt(i));
}
buffer.append('}');
return buffer.toString();
Expand All @@ -70,7 +70,7 @@ static <T> String toString(Map<T, byte[]> map) {
while (it.hasNext()) {
Map.Entry<T, byte[]> entry = it.next();
Object key = entry.getKey();
buffer.append(key).append("=").append(Arrays.toString(map.get(key)));
buffer.append(key).append('=').append(Arrays.toString(map.get(key)));
if (it.hasNext()) {
buffer.append(", ");
}
Expand Down

0 comments on commit c384d94

Please sign in to comment.