mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Fixing codacy issues. Reduced reported count from 550 to 518.
This commit is contained in:
parent
9b8d8e9b7c
commit
fc9cd0a3b7
13 changed files with 51 additions and 41 deletions
|
|
@ -224,11 +224,13 @@ public class CommonsApplication extends Application {
|
||||||
if (getIndex() == allAccounts.length) {
|
if (getIndex() == allAccounts.length) {
|
||||||
Timber.d("All accounts have been removed");
|
Timber.d("All accounts have been removed");
|
||||||
//TODO: fix preference manager
|
//TODO: fix preference manager
|
||||||
PreferenceManager.getDefaultSharedPreferences(getInstance()).edit().clear().commit();
|
PreferenceManager.getDefaultSharedPreferences(getInstance())
|
||||||
|
.edit().clear().commit();
|
||||||
SharedPreferences preferences = context
|
SharedPreferences preferences = context
|
||||||
.getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
|
.getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
|
||||||
preferences.edit().clear().commit();
|
preferences.edit().clear().commit();
|
||||||
context.getSharedPreferences("prefs", Context.MODE_PRIVATE).edit().clear().commit();
|
context.getSharedPreferences("prefs", Context.MODE_PRIVATE)
|
||||||
|
.edit().clear().commit();
|
||||||
preferences.edit().putBoolean("firstrun", false).apply();
|
preferences.edit().putBoolean("firstrun", false).apply();
|
||||||
updateAllDatabases();
|
updateAllDatabases();
|
||||||
currentAccount = null;
|
currentAccount = null;
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ package fr.free.nrw.commons;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
public class License {
|
public class License {
|
||||||
String key;
|
private String key;
|
||||||
String template;
|
private String template;
|
||||||
String url;
|
private String url;
|
||||||
String name;
|
private String name;
|
||||||
|
|
||||||
public License(String key, String template, String url, String name) {
|
public License(String key, String template, String url, String name) {
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
|
|
|
||||||
|
|
@ -242,9 +242,9 @@ public class Utils {
|
||||||
public static boolean xmlFastForward(XmlPullParser parser, String namespace, String element) {
|
public static boolean xmlFastForward(XmlPullParser parser, String namespace, String element) {
|
||||||
try {
|
try {
|
||||||
while (parser.next() != XmlPullParser.END_DOCUMENT) {
|
while (parser.next() != XmlPullParser.END_DOCUMENT) {
|
||||||
if (parser.getEventType() == XmlPullParser.START_TAG &&
|
if (parser.getEventType() == XmlPullParser.START_TAG
|
||||||
parser.getNamespace().equals(namespace) &&
|
&& parser.getNamespace().equals(namespace)
|
||||||
parser.getName().equals(element)) {
|
&& parser.getName().equals(element)) {
|
||||||
// We found it!
|
// We found it!
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +267,8 @@ public class Utils {
|
||||||
extension = "jpg";
|
extension = "jpg";
|
||||||
}
|
}
|
||||||
title = jpegPattern.matcher(title).replaceFirst(".jpg");
|
title = jpegPattern.matcher(title).replaceFirst(".jpg");
|
||||||
if (extension != null && !title.toLowerCase(Locale.getDefault()).endsWith("." + extension.toLowerCase(Locale.ENGLISH))) {
|
if (extension != null && !title.toLowerCase(Locale.getDefault())
|
||||||
|
.endsWith("." + extension.toLowerCase(Locale.ENGLISH))) {
|
||||||
title += "." + extension;
|
title += "." + extension;
|
||||||
}
|
}
|
||||||
return title;
|
return title;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import timber.log.Timber;
|
||||||
|
|
||||||
public abstract class AuthenticatedActivity extends NavigationBaseActivity {
|
public abstract class AuthenticatedActivity extends NavigationBaseActivity {
|
||||||
|
|
||||||
String accountType;
|
private String accountType;
|
||||||
CommonsApplication app;
|
CommonsApplication app;
|
||||||
|
|
||||||
private String authCookie;
|
private String authCookie;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ public class SignupActivity extends BaseActivity {
|
||||||
|
|
||||||
webView.setWebViewClient(new MyWebViewClient());
|
webView.setWebViewClient(new MyWebViewClient());
|
||||||
WebSettings webSettings = webView.getSettings();
|
WebSettings webSettings = webView.getSettings();
|
||||||
//Needed to refresh Captcha. Might introduce XSS vulnerabilities, but we can trust Wikimedia's site... right?
|
/*Needed to refresh Captcha. Might introduce XSS vulnerabilities, but we can
|
||||||
|
trust Wikimedia's site... right?*/
|
||||||
webSettings.setJavaScriptEnabled(true);
|
webSettings.setJavaScriptEnabled(true);
|
||||||
|
|
||||||
webView.loadUrl(BuildConfig.SIGNUP_LANDING_URL);
|
webView.loadUrl(BuildConfig.SIGNUP_LANDING_URL);
|
||||||
|
|
|
||||||
|
|
@ -142,11 +142,13 @@ public class CategoryContentProvider extends ContentProvider {
|
||||||
public int update(@NonNull Uri uri, ContentValues contentValues, String selection,
|
public int update(@NonNull Uri uri, ContentValues contentValues, String selection,
|
||||||
String[] selectionArgs) {
|
String[] selectionArgs) {
|
||||||
/*
|
/*
|
||||||
SQL Injection warnings: First, note that we're not exposing this to the outside world (exported="false")
|
SQL Injection warnings: First, note that we're not exposing this to the
|
||||||
Even then, we should make sure to sanitize all user input appropriately. Input that passes through ContentValues
|
outside world (exported="false"). Even then, we should make sure to sanitize
|
||||||
|
all user input appropriately. Input that passes through ContentValues
|
||||||
should be fine. So only issues are those that pass in via concating.
|
should be fine. So only issues are those that pass in via concating.
|
||||||
|
|
||||||
In here, the only concat created argument is for id. It is cast to an int, and will error out otherwise.
|
In here, the only concat created argument is for id. It is cast to an int,
|
||||||
|
and will error out otherwise.
|
||||||
*/
|
*/
|
||||||
int uriType = uriMatcher.match(uri);
|
int uriType = uriMatcher.match(uri);
|
||||||
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
|
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
|
||||||
|
|
|
||||||
|
|
@ -154,10 +154,12 @@ public class ContributionsContentProvider extends ContentProvider {
|
||||||
public int update(@NonNull Uri uri, ContentValues contentValues, String selection, String[] selectionArgs) {
|
public int update(@NonNull Uri uri, ContentValues contentValues, String selection, String[] selectionArgs) {
|
||||||
/*
|
/*
|
||||||
SQL Injection warnings: First, note that we're not exposing this to the outside world (exported="false")
|
SQL Injection warnings: First, note that we're not exposing this to the outside world (exported="false")
|
||||||
Even then, we should make sure to sanitize all user input appropriately. Input that passes through ContentValues
|
Even then, we should make sure to sanitize all user input appropriately.
|
||||||
should be fine. So only issues are those that pass in via concating.
|
Input that passes through ContentValuesshould be fine. So only issues are those that pass
|
||||||
|
in via concating.
|
||||||
|
|
||||||
In here, the only concat created argument is for id. It is cast to an int, and will error out otherwise.
|
In here, the only concat created argument is for id. It is cast to an int, and will
|
||||||
|
error out otherwise.
|
||||||
*/
|
*/
|
||||||
int uriType = uriMatcher.match(uri);
|
int uriType = uriMatcher.match(uri);
|
||||||
CommonsApplication app = (CommonsApplication) getContext().getApplicationContext();
|
CommonsApplication app = (CommonsApplication) getContext().getApplicationContext();
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,8 @@ public class ModifierSequence {
|
||||||
// Hardcoding column positions!
|
// Hardcoding column positions!
|
||||||
ModifierSequence ms = null;
|
ModifierSequence ms = null;
|
||||||
try {
|
try {
|
||||||
ms = new ModifierSequence(Uri.parse(cursor.getString(1)), new JSONObject(cursor.getString(2)));
|
ms = new ModifierSequence(Uri.parse(cursor.getString(1)),
|
||||||
|
new JSONObject(cursor.getString(2)));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,8 @@ public class SingleUploadFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
View rootView = inflater.inflate(R.layout.fragment_single_upload, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_single_upload, container, false);
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue