From a857d8e3063ab4e36d659869554c575d30c9dd29 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 27 Aug 2020 17:39:09 +0200 Subject: [PATCH] Fix bugs detected by sonar --- build.gradle | 3 ++- .../roompreview/RoomPreviewActivity.kt | 2 ++ .../devices/VectorSettingsDevicesFragment.kt | 13 +++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 93ea529163..aa941e1445 100644 --- a/build.gradle +++ b/build.gradle @@ -100,7 +100,8 @@ project(":vector") { properties { property "sonar.sources", project(":vector").android.sourceSets.main.java.srcDirs // exclude source code from analyses separated by a colon (:) - // property "sonar.exclusions", "**/*.*" + // Exclude Java source + property "sonar.exclusions", "**/BugReporterMultipartBody.java" } } } diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt index 8bbaa14ab0..4876bd7f98 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt @@ -28,6 +28,7 @@ import kotlinx.android.parcel.Parcelize import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom import org.matrix.android.sdk.api.session.room.model.thirdparty.RoomDirectoryData import org.matrix.android.sdk.api.util.MatrixItem +import timber.log.Timber @Parcelize data class RoomPreviewData( @@ -83,6 +84,7 @@ class RoomPreviewActivity : VectorBaseActivity(), ToolbarConfigurable { if (args?.worldReadable == true) { // TODO Room preview: Note: M does not recommend to use /events anymore, so for now we just display the room preview // TODO the same way if it was not world readable + Timber.d("just display the room preview the same way if it was not world readable") addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args) } else { addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/VectorSettingsDevicesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/VectorSettingsDevicesFragment.kt index b33a0cb5d8..bc72f812ff 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/VectorSettingsDevicesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/VectorSettingsDevicesFragment.kt @@ -48,7 +48,8 @@ class VectorSettingsDevicesFragment @Inject constructor( ) : VectorBaseFragment(), DevicesController.Callback { // used to avoid requesting to enter the password for each deletion - private var mAccountPassword: String = "" + // Note: Sonar does not like to use password for member name. + private var mAccountPass: String = "" override fun getLayoutResId() = R.layout.fragment_generic_recycler @@ -91,7 +92,7 @@ class VectorSettingsDevicesFragment @Inject constructor( super.showFailure(throwable) // Password is maybe not good, for safety measure, reset it here - mAccountPassword = "" + mAccountPass = "" } override fun onDestroyView() { @@ -153,12 +154,12 @@ class VectorSettingsDevicesFragment @Inject constructor( * Show a dialog to ask for user password, or use a previously entered password. */ private fun maybeShowDeleteDeviceWithPasswordDialog() { - if (mAccountPassword.isNotEmpty()) { - viewModel.handle(DevicesAction.Password(mAccountPassword)) + if (mAccountPass.isNotEmpty()) { + viewModel.handle(DevicesAction.Password(mAccountPass)) } else { PromptPasswordDialog().show(requireActivity()) { password -> - mAccountPassword = password - viewModel.handle(DevicesAction.Password(mAccountPassword)) + mAccountPass = password + viewModel.handle(DevicesAction.Password(mAccountPass)) } } }