Fix CodeAnalytics

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-12-25 11:47:56 +01:00 committed by Jonas Mayer
parent 50b0a24b5d
commit c6a480b919
5 changed files with 18 additions and 13 deletions

View file

@ -166,7 +166,7 @@ abstract class FileUploaderIT : AbstractOnServerIT() {
user,
arrayOf(ocFile2),
FilesUploadWorker.LOCAL_BEHAVIOUR_COPY,
NameCollisionPolicy.OVERWRITE,
NameCollisionPolicy.OVERWRITE
)
shortSleep()

View file

@ -67,6 +67,7 @@ class UploadNotificationManager(private val context: Context, private val viewTh
notification = notificationBuilder.build()
}
@Suppress("MagicNumber")
fun notifyForStart(upload: UploadFileOperation, pendingIntent: PendingIntent) {
notificationBuilder = NotificationUtils.newNotificationBuilder(context, viewThemeUtils)
@ -90,7 +91,6 @@ class UploadNotificationManager(private val context: Context, private val viewTh
pendingIntent
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD)
}
@ -117,7 +117,7 @@ class UploadNotificationManager(private val context: Context, private val viewTh
}
fun notifyForResult(tickerId: Int) {
notificationBuilder
notificationBuilder
.setTicker(context.getString(tickerId))
.setContentTitle(context.getString(tickerId))
.setAutoCancel(true)
@ -158,6 +158,7 @@ class UploadNotificationManager(private val context: Context, private val viewTh
notificationManager.notify(WORKER_ID, notificationBuilder.build())
}
@Suppress("MagicNumber")
fun updateUploadProgressNotification(filePath: String, percent: Int, currentOperation: UploadFileOperation?) {
notificationBuilder.setProgress(100, percent, false)

View file

@ -339,9 +339,7 @@ class FilesUploadWorker(
FilesUploadHelper().retryUpload(upload, user)
}
/**
* Retry a subset of all the stored failed uploads.
*/
@Suppress("ComplexCondition")
fun retryFailedUploads(
context: Context,
uploadsStorageManager: UploadsStorageManager,
@ -351,7 +349,7 @@ class FilesUploadWorker(
) {
val failedUploads = uploadsStorageManager.failedUploads
if (failedUploads == null || failedUploads.size == 0) {
return //nothing to do
return // nothing to do
}
val (gotNetwork, _, gotWifi) = connectivityService.connectivity
val batteryStatus = powerManagementService.battery
@ -402,6 +400,7 @@ class FilesUploadWorker(
return accountName + remotePath
}
@Suppress("EmptyIfBlock")
class UploadNotificationActionReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val accountName = intent.getStringExtra(EXTRA_ACCOUNT_NAME)
@ -418,7 +417,6 @@ class FilesUploadWorker(
val uploadHelper = FilesUploadHelper()
uploadHelper.cancel(accountName, remotePath, null)
} else if (ACTION_PAUSE_BROADCAST == action) {
} else {
Log_OC.d(TAG, "Unknown action to perform as UploadNotificationActionReceiver.")
}

View file

@ -287,7 +287,7 @@ class SetupEncryptionDialogFragment : DialogFragment(), Injectable {
mWeakContext = WeakReference(context)
}
@Suppress("ReturnCount")
@Suppress("ReturnCount", "LongMethod")
@Deprecated("Deprecated in Java")
override fun doInBackground(vararg params: Void?): String? {
// fetch private/public key

View file

@ -46,6 +46,7 @@ import com.owncloud.android.lib.resources.files.model.ServerFileInterface
import java.util.concurrent.ExecutionException
import javax.inject.Inject
@Suppress("TooManyFunctions")
class FilesUploadHelper {
@Inject
lateinit var backgroundJobManager: BackgroundJobManager
@ -114,7 +115,7 @@ class FilesUploadHelper {
createdBy: Int,
requiresWifi: Boolean,
requiresCharging: Boolean,
nameCollisionPolicy: NameCollisionPolicy,
nameCollisionPolicy: NameCollisionPolicy
) {
val uploads = localPaths.mapIndexed { index, localPath ->
OCUpload(localPath, remotePaths[index], user.accountName).apply {
@ -144,6 +145,7 @@ class FilesUploadHelper {
backgroundJobManager.startFilesUploadJob(user)
}
@Suppress("ReturnCount")
fun isUploading(user: User?, file: OCFile?): Boolean {
if (user == null || file == null || !isWorkScheduled(BackgroundJobManagerImpl.JOB_FILES_UPLOAD)) {
return false
@ -153,15 +155,19 @@ class FilesUploadHelper {
return upload.uploadStatus == UploadStatus.UPLOAD_IN_PROGRESS
}
@Suppress("ReturnCount")
fun isUploadingNow(upload: OCUpload?): Boolean {
val currentUploadFileOperation = currentUploadFileOperation
if (currentUploadFileOperation == null || currentUploadFileOperation.user == null) return false
if (upload == null || upload.accountName != currentUploadFileOperation.user.accountName) return false
return if (currentUploadFileOperation.oldFile != null) {
// For file conflicts check old file remote path
upload.remotePath == currentUploadFileOperation.remotePath || upload.remotePath == currentUploadFileOperation.oldFile!!
.remotePath
} else upload.remotePath == currentUploadFileOperation.remotePath
upload.remotePath == currentUploadFileOperation.remotePath ||
upload.remotePath == currentUploadFileOperation.oldFile!!
.remotePath
} else {
upload.remotePath == currentUploadFileOperation.remotePath
}
}
fun uploadUpdatedFile(