Skip to content

Commit

Permalink
Merge pull request getodk#279 from lognaturel/require-linting
Browse files Browse the repository at this point in the history
Fixed linter problems. Required successful lint run as part of the automated builds.
  • Loading branch information
batkinson authored Jan 17, 2017
2 parents 110a9ba + 45f6054 commit 21748b5
Show file tree
Hide file tree
Showing 54 changed files with 123 additions and 436 deletions.
9 changes: 6 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ dependencies:

test:
pre:
- ./gradlew assembleRelease
- ./gradlew assembleAndroidTest
- ./gradlew lint assembleRelease assembleAndroidTest

override:
- ./gradlew testReleaseUnitTest
- cp -r collect_app/build/outputs/apk $CIRCLE_ARTIFACTS

post:
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find . -type f -regex ".*/build/test-results/.*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
- find . -type f -regex ".*/build/test-results/.*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;

# Lint
- mkdir -p $CIRCLE_TEST_REPORTS/lint/
- find . -type f -regex ".*/collect_app/build/outputs/lint-results-*.*" -exec cp --parent {} $CIRCLE_TEST_REPORTS/lint/ \;
7 changes: 6 additions & 1 deletion collect_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ android {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

lintOptions {
abortOnError true
}
}

task checkstyle(type: Checkstyle) {
Expand All @@ -95,9 +99,10 @@ configurations.all {

allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
options.compilerArgs << "-Xlint:all"
}
}

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.google.android.gms:play-services:4.1.32'
Expand Down
12 changes: 12 additions & 0 deletions collect_app/lint.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<lint>
<!-- make sure classes referenced in the manifest or in a layout file are in the project -->
<issue id="MissingRegistered" severity="error" />

<!-- require inputType attribute on all text fields -->
<issue id="TextFields" severity="error" />

<issue id="StaticFieldLeak" severity="error" />

<issue id="GradleOverrides" severity="error" />

<issue id="SetTextI18n" severity="error" />
<issue id="HardcodedText" severity="error" />
</lint>
5 changes: 0 additions & 5 deletions collect_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.odk.collect.android"
android:versionCode="1058"
android:versionName="1.4.8"

>

<uses-feature android:name="android.hardware.location" android:required="false" />
Expand Down Expand Up @@ -51,8 +48,6 @@
<uses-permission android:name="org.odk.collect.android.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />

<supports-screens
android:anyDensity="true"
android:xlargeScreens="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private void createDeleteInstancesDialog() {
mAlertDialog = new AlertDialog.Builder(this).create();
mAlertDialog.setTitle(getString(R.string.delete_file));
mAlertDialog.setMessage(getString(R.string.delete_confirm,
mSelected.size()));
String.valueOf(mSelected.size())));
DialogInterface.OnClickListener dialogYesNoListener =
new DialogInterface.OnClickListener() {
@Override
Expand Down Expand Up @@ -260,16 +260,16 @@ public void deleteComplete(int deletedInstances) {
if (deletedInstances == mSelected.size()) {
// all deletes were successful
Toast.makeText(this,
getString(R.string.file_deleted_ok, deletedInstances),
getString(R.string.file_deleted_ok, String.valueOf(deletedInstances)),
Toast.LENGTH_SHORT).show();
} else {
// had some failures
Log.e(t, "Failed to delete "
+ (mSelected.size() - deletedInstances) + " instances");
Toast.makeText(
this,
getString(R.string.file_deleted_error, mSelected.size()
- deletedInstances, mSelected.size()),
getString(R.string.file_deleted_error, String.valueOf(mSelected.size()
- deletedInstances), String.valueOf(mSelected.size())),
Toast.LENGTH_LONG).show();
}
mDeleteInstancesTask = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ public void onClick(DialogInterface dialog, int i) {

@Override
public void progressUpdate(String currentFile, int progress, int total) {
mAlertMsg = getString(R.string.fetching_file, currentFile, progress, total);
mAlertMsg = getString(R.string.fetching_file, currentFile, String.valueOf(progress), String.valueOf(total));
mProgressDialog.setMessage(mAlertMsg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void createDeleteFormsDialog() {
mAlertDialog = new AlertDialog.Builder(this).create();
mAlertDialog.setTitle(getString(R.string.delete_file));
mAlertDialog.setMessage(getString(R.string.delete_confirm,
mSelected.size()));
String.valueOf(mSelected.size())));
DialogInterface.OnClickListener dialogYesNoListener =
new DialogInterface.OnClickListener() {
@Override
Expand Down Expand Up @@ -306,16 +306,16 @@ public void deleteComplete(int deletedForms) {
if (deletedForms == mSelected.size()) {
// all deletes were successful
Toast.makeText(getApplicationContext(),
getString(R.string.file_deleted_ok, deletedForms),
getString(R.string.file_deleted_ok, String.valueOf(deletedForms)),
Toast.LENGTH_SHORT).show();
} else {
// had some failures
Log.e(t, "Failed to delete " + (mSelected.size() - deletedForms)
+ " forms");
Toast.makeText(
getApplicationContext(),
getString(R.string.file_deleted_error, mSelected.size()
- deletedForms, mSelected.size()),
getString(R.string.file_deleted_error, String.valueOf(mSelected.size()
- deletedForms), String.valueOf(mSelected.size())),
Toast.LENGTH_LONG).show();
}
mBackgroundTasks.mDeleteFormsTask = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void onClick(View v) {
mLayers.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mHelper.showLayersDialog();
mHelper.showLayersDialog(GeoPointMapActivity.this);
}
});
zoomDialogView = getLayoutInflater().inflate(R.layout.geopoint_zoom_dialog, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void onClick(View v) {
mLayersButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mHelper.showLayersDialog();
mHelper.showLayersDialog(GeoPointOsmMapActivity.this);

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void onClick(View v) {

@Override
public void onClick(View v) {
mHelper.showLayersDialog();
mHelper.showLayersDialog(GeoShapeGoogleMapActivity.this);

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void onClick(View v) {

@Override
public void onClick(View v) {
mHelper.showLayersDialog();
mHelper.showLayersDialog(GeoShapeOsmMapActivity.this);

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void onClick(View v) {
layers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mHelper.showLayersDialog();
mHelper.showLayersDialog(GeoTraceGoogleMapActivity.this);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onClick(View v) {
mHelper.showLayersDialog();
mHelper.showLayersDialog(GeoTraceOsmMapActivity.this);

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import java.util.Set;

public class GoogleSheetsUploaderActivity extends Activity implements InstanceUploaderListener {
private final static String tag = "GoogleSheetsUploaderActivity";
private final static String TAG = "SheetsUploaderActivity";

private final static int PROGRESS_DIALOG = 1;
private final static int GOOGLE_USER_DIALOG = 3;
Expand All @@ -73,7 +73,7 @@ public class GoogleSheetsUploaderActivity extends Activity implements InstanceUp
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(tag, "onCreate: " + ((savedInstanceState == null) ? "creating" : "re-initializing"));
Log.i(TAG, "onCreate: " + ((savedInstanceState == null) ? "creating" : "re-initializing"));

// if we start this activity, the following must be true:
// 1) Google Sheets is selected in preferences
Expand Down Expand Up @@ -110,11 +110,11 @@ protected void onCreate(Bundle savedInstanceState) {

// at this point, we don't expect this to be empty...
if (mInstancesToSend.length == 0) {
Log.e(tag, "onCreate: No instances to upload!");
Log.e(TAG, "onCreate: No instances to upload!");
// drop through --
// everything will process through OK
} else {
Log.i(tag, "onCreate: Beginning upload of " + mInstancesToSend.length + " instances!");
Log.i(TAG, "onCreate: Beginning upload of " + mInstancesToSend.length + " instances!");
}

runTask();
Expand Down Expand Up @@ -163,7 +163,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// the user backed out
finish();
} else {
Log.e(tag, "unknown request: " + requestCode + " :: result: " + resultCode);
Log.e(TAG, "unknown request: " + requestCode + " :: result: " + resultCode);
}
}

Expand Down Expand Up @@ -230,7 +230,7 @@ public void uploadingComplete(HashMap<String, String> result) {
// probably got an auth request, so ignore
return;
}
Log.i(tag, "uploadingComplete: Processing results (" + result.size() + ") from upload of "
Log.i(TAG, "uploadingComplete: Processing results (" + result.size() + ") from upload of "
+ mInstancesToSend.length + " instances!");

StringBuilder selection = new StringBuilder();
Expand Down Expand Up @@ -279,7 +279,7 @@ public void uploadingComplete(HashMap<String, String> result) {

@Override
public void progressUpdate(int progress, int total) {
mAlertMsg = getString(R.string.sending_items, progress, total);
mAlertMsg = getString(R.string.sending_items, String.valueOf(progress), String.valueOf(total));
mProgressDialog.setMessage(mAlertMsg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ protected void onCreate(Bundle savedInstanceState) {
// create intent for saved tab
Intent saved = new Intent(this, InstanceChooserList.class);
tabHost.addTab(tabHost.newTabSpec(SAVED_TAB)
.setIndicator(getString(R.string.saved_data, mSavedCount)).setContent(saved));
.setIndicator(getString(R.string.saved_data, String.valueOf(mSavedCount))).setContent(saved));

// create intent for completed tab
Intent completed = new Intent(this, InstanceChooserList.class);
tabHost.addTab(tabHost.newTabSpec(COMPLETED_TAB)
.setIndicator(getString(R.string.completed_data, mCompletedCount))
.setIndicator(getString(R.string.completed_data, String.valueOf(mCompletedCount)))
.setContent(completed));

// hack to set font size and padding in tab headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/
public class InstanceUploaderActivity extends Activity implements InstanceUploaderListener,
AuthDialogUtility.AuthDialogUtilityResultListener {
private final static String t = "InstanceUploaderActivity";
private final static String TAG = "InstanceUploaderActiv";
private final static int PROGRESS_DIALOG = 1;
private final static int AUTH_DIALOG = 2;

Expand All @@ -79,7 +79,7 @@ public class InstanceUploaderActivity extends Activity implements InstanceUpload
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(t, "onCreate: " + ((savedInstanceState == null) ? "creating" : "re-initializing"));
Log.i(TAG, "onCreate: " + ((savedInstanceState == null) ? "creating" : "re-initializing"));

mAlertMsg = getString(R.string.please_wait);
mAlertShowing = false;
Expand Down Expand Up @@ -120,10 +120,10 @@ protected void onCreate(Bundle savedInstanceState) {

// at this point, we don't expect this to be empty...
if (mInstancesToSend.length == 0) {
Log.e(t, "onCreate: No instances to upload!");
Log.e(TAG, "onCreate: No instances to upload!");
// drop through -- everything will process through OK
} else {
Log.i(t, "onCreate: Beginning upload of " + mInstancesToSend.length + " instances!");
Log.i(TAG, "onCreate: Beginning upload of " + mInstancesToSend.length + " instances!");
}

// get the task if we've changed orientations. If it's null it's a new upload.
Expand All @@ -148,7 +148,7 @@ protected void onStart() {

@Override
protected void onResume() {
Log.i(t, "onResume: Resuming upload of " + mInstancesToSend.length + " instances!");
Log.i(TAG, "onResume: Resuming upload of " + mInstancesToSend.length + " instances!");
if (mInstanceUploaderTask != null) {
mInstanceUploaderTask.setUploaderListener(this);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ public Object onRetainNonConfigurationInstance() {

@Override
protected void onPause() {
Log.i(t, "onPause: Pausing upload of " + mInstancesToSend.length + " instances!");
Log.i(TAG, "onPause: Pausing upload of " + mInstancesToSend.length + " instances!");
super.onPause();
if (mAlertDialog != null && mAlertDialog.isShowing()) {
mAlertDialog.dismiss();
Expand All @@ -205,7 +205,7 @@ protected void onDestroy() {

@Override
public void uploadingComplete(HashMap<String, String> result) {
Log.i(t, "uploadingComplete: Processing results (" + result.size() + ") from upload of "
Log.i(TAG, "uploadingComplete: Processing results (" + result.size() + ") from upload of "
+ mInstancesToSend.length + " instances!");

try {
Expand Down Expand Up @@ -260,7 +260,7 @@ public void uploadingComplete(HashMap<String, String> result) {

@Override
public void progressUpdate(int progress, int total) {
mAlertMsg = getString(R.string.sending_items, progress, total);
mAlertMsg = getString(R.string.sending_items, String.valueOf(progress), String.valueOf(total));
mProgressDialog.setMessage(mAlertMsg);
}

Expand Down Expand Up @@ -293,7 +293,7 @@ public void onClick(DialogInterface dialog, int which) {
mProgressDialog.setButton(getString(R.string.cancel), loadingButtonListener);
return mProgressDialog;
case AUTH_DIALOG:
Log.i(t, "onCreateDialog(AUTH_DIALOG): for upload of " + mInstancesToSend.length
Log.i(TAG, "onCreateDialog(AUTH_DIALOG): for upload of " + mInstancesToSend.length
+ " instances!");
Collect.getInstance().getActivityLogger().logAction(this,
"onCreateDialog.AUTH_DIALOG", "show");
Expand Down Expand Up @@ -329,7 +329,7 @@ public void authRequest(Uri url, HashMap<String, String> doneSoFar) {
Long removeMe = Long.valueOf(itr.next());
boolean removed = workingSet.remove(removeMe);
if (removed) {
Log.i(t, removeMe
Log.i(TAG, removeMe
+ " was already sent, removing from queue before restarting task");
}
}
Expand Down Expand Up @@ -390,4 +390,4 @@ public void updatedCredentials() {
public void cancelledUpdatingCredentials() {
finish();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ private void updateButtons() {
mFinalizedCursor.requery();
mCompletedCount = mFinalizedCursor.getCount();
if (mCompletedCount > 0) {
mSendDataButton.setText(getString(R.string.send_data_button, mCompletedCount));
mSendDataButton.setText(getString(R.string.send_data_button, String.valueOf(mCompletedCount)));
} else {
mSendDataButton.setText(getString(R.string.send_data));
}
Expand All @@ -493,7 +493,7 @@ private void updateButtons() {
mSavedCount = mSavedCursor.getCount();
if (mSavedCount > 0) {
mReviewDataButton.setText(getString(R.string.review_data_button,
mSavedCount));
String.valueOf(mSavedCount)));
} else {
mReviewDataButton.setText(getString(R.string.review_data));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static FormDef.EvalBehavior getConfiguredFormProcessingLogic(Context cont
}
} catch (Exception e) {
e.printStackTrace();
Log.w("AdminPreferencesActivity",
Log.w("AdminPrefActivity",
"Unable to get EvalBehavior -- defaulting to recommended mode");
mode = FormDef.recommendedMode;
}
Expand Down
Loading

0 comments on commit 21748b5

Please sign in to comment.