Merge branch 'pmd-2' into 'master'

Enable a few more PMD rules

I did one last pass over https://pmd.github.io/pmd-5.4.1/pmd-java/rules/index.html and these are the only sane rules left that I could find.

So I'm pretty much done with adding PMD stuff :) Don't know if anyone feels strongly in favour of adding findbugs, but I think checkstyle+PMD is good for now.

See merge request !283
This commit is contained in:
Hans-Christoph Steiner 2016-05-12 12:53:56 +00:00
commit 2e04d4b82c
3 changed files with 12 additions and 3 deletions

View File

@ -372,7 +372,9 @@ public final class LocalRepoManager {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// max age is an EditTextPreference, which is always a String
int repoMaxAge = Float.valueOf(prefs.getString("max_repo_age_days", DEFAULT_REPO_MAX_AGE_DAYS)).intValue();
// TODO: This pref is probably never being set. Also, why
// are we mixing floats and ints?
int repoMaxAge = Float.valueOf(prefs.getString("max_repo_age_days", DEFAULT_REPO_MAX_AGE_DAYS)).intValue(); // NOPMD
serializer.startTag("", "repo");

View File

@ -96,10 +96,12 @@ public class SwapAppsView extends ListView implements
super.onFinishInflate();
repo = getActivity().getState().getPeerRepo();
/*
if (repo == null) {
// TODO: Uh oh, something stuffed up for this to happen.
// TODO: What is the best course of action from here?
TODO: Uh oh, something stuffed up for this to happen.
TODO: What is the best course of action from here?
}
*/
adapter = new AppListAdapter(getContext(), getContext().getContentResolver().query(
AppProvider.getRepoUri(repo), AppProvider.DataColumns.ALL, null, null, null));

View File

@ -17,9 +17,14 @@
<rule ref="rulesets/java/unnecessary.xml">
<exclude name="UselessParentheses"/> <!--Too nitpicky-->
</rule>
<rule ref="rulesets/java/empty.xml">
<exclude name="EmptyCatchBlock"/> <!--Ignoring an exception-->
<exclude name="EmptyWhileStmt"/> <!--Can be useful sometimes-->
</rule>
<rule ref="rulesets/java/optimizations.xml/PrematureDeclaration"/>
<rule ref="rulesets/java/optimizations.xml/AddEmptyString"/>
<rule ref="rulesets/java/optimizations.xml/UseArraysAsList"/>
<rule ref="rulesets/java/optimizations.xml/UnnecessaryWrapperObjectCreation"/>
<rule ref="rulesets/java/controversial.xml/UnnecessaryConstructor"/>
<rule ref="rulesets/java/controversial.xml/UnnecessaryParentheses"/>