Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79df148a authored by David Luhmer's avatar David Luhmer
Browse files

refactor code to make codacy happy

parent fece49d5
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -130,9 +130,7 @@ public class AccountImporter {
        if (mPrefs.contains(prefKey)) {
            try {
                return SingleSignOnAccount.fromString(mPrefs.getString(prefKey, null));
            } catch (ClassNotFoundException e) {
                Log.e(TAG, "[getSingleSignOnAccount] ClassNotFound", e);
            } catch (IOException e) {
            } catch (ClassNotFoundException | IOException e) {
                Log.e(TAG, "[getSingleSignOnAccount]", e);
            }
        }
+11 −14
Original line number Diff line number Diff line
@@ -44,9 +44,7 @@ import retrofit2.http.Streaming;
public class NextcloudRetrofitServiceMethod<T> {

    private static String TAG = NextcloudRetrofitServiceMethod.class.getCanonicalName();
    private final Annotation[] methodAnnotations;
    private final Annotation[][] parameterAnnotationsArray;
    private final Type[] parameterTypes;


    // Upper and lower characters, digits, underscores, and hyphens, starting with a character.
@@ -67,8 +65,8 @@ public class NextcloudRetrofitServiceMethod<T> {
    public NextcloudRetrofitServiceMethod(String apiEndpoint, Method method) {
        this.method = method;
        this.returnType = method.getGenericReturnType();
        this.methodAnnotations = method.getAnnotations();
        this.parameterTypes = method.getGenericParameterTypes();
        Annotation[] methodAnnotations = method.getAnnotations();
        //Type[] parameterTypes = method.getGenericParameterTypes();
        this.parameterAnnotationsArray = method.getParameterAnnotations();

        for (Annotation annotation : methodAnnotations) {
@@ -91,15 +89,15 @@ public class NextcloudRetrofitServiceMethod<T> {
    }

    public T invoke(NextcloudAPI nextcloudAPI, Object[] args) throws Exception {
        Map<String, String> parameters = new HashMap<>();
        if(parameterAnnotationsArray.length != args.length) {
            throw new InvalidParameterException("Expected: " + parameterAnnotationsArray.length + " params - were: " + args.length);
        }

        //NextcloudRequest.Builder rBuilder = (NextcloudRequest.Builder) requestBuilder.clone();
        NextcloudRequest.Builder rBuilder = cloneSerializable(requestBuilder);


        if(parameterAnnotationsArray.length != args.length) {
            throw new InvalidParameterException("Expected: " + parameterAnnotationsArray.length + " params - were: " + args.length);
        }
        Map<String, String> parameters = new HashMap<>();

        for(int i = 0; i < parameterAnnotationsArray.length; i++) {
            Annotation annotation = parameterAnnotationsArray[i][0];
@@ -211,7 +209,6 @@ public class NextcloudRetrofitServiceMethod<T> {
                    this.httpMethod, httpMethod);
        }
        this.httpMethod = httpMethod;
        boolean hasBody1 = hasBody;

        if (value.isEmpty()) {
            return;
@@ -283,8 +280,8 @@ public class NextcloudRetrofitServiceMethod<T> {

    private static RuntimeException methodError(Method method, @Nullable Throwable cause, String message,
                                        Object... args) {
        message = String.format(message, args);
        return new IllegalArgumentException(message
        String formattedMessage = String.format(message, args);
        return new IllegalArgumentException(formattedMessage
                + "\n    for method "
                + method.getDeclaringClass().getSimpleName()
                + "."
@@ -316,7 +313,7 @@ public class NextcloudRetrofitServiceMethod<T> {
            res = (T) ois.readObject();
        } catch (ClassNotFoundException e) {
            // Can't happen as we just clone an object..
            e.printStackTrace();
            Log.e(TAG, "ClassNotFoundException", e);
        }
        ois.close();

+4 −5
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import com.nextcloud.android.sso.exceptions.NextcloudFilesAppNotInstalledExcepti
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppNotSupportedException;
import com.nextcloud.android.sso.ui.UiExceptionManager;

public class VersionCheckHelper {
public final class VersionCheckHelper {

    private static final String TAG = VersionCheckHelper.class.getCanonicalName();

@@ -24,8 +24,7 @@ public class VersionCheckHelper {
                return false;
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "PackageManager.NameNotFoundException: " + e.getLocalizedMessage());
            //e.printStackTrace();
            Log.e(TAG, "PackageManager.NameNotFoundException", e);
            UiExceptionManager.showDialogForException(activity, new NextcloudFilesAppNotInstalledException());
            return false;
        }
@@ -34,8 +33,8 @@ public class VersionCheckHelper {
    }

    public static int getNextcloudFilesVersionCode(Activity activity) throws PackageManager.NameNotFoundException {
        PackageInfo pinfo = activity.getPackageManager().getPackageInfo("com.nextcloud.client", 0);
        int verCode = pinfo.versionCode;
        PackageInfo pInfo = activity.getPackageManager().getPackageInfo("com.nextcloud.client", 0);
        int verCode = pInfo.versionCode;
        Log.e("VersionCheckHelper", "Version Code: " + verCode);
        return verCode;
    }
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import com.nextcloud.android.sso.exceptions.SSOException;
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class UiExceptionManager {
public final class UiExceptionManager {

    private static final int NOTIFICATION_ID = 0;
    private static final String CHANNEL_ID = "0";
+1 −1
Original line number Diff line number Diff line
package android.util;

// https://stackoverflow.com/questions/36787449/how-to-mock-method-e-in-log
public class Log {
public final class Log {

    private Log() { }