Fix bugs detected by sonar

This commit is contained in:
Benoit Marty 2020-08-27 17:39:09 +02:00
parent cb64f472fe
commit a857d8e306
3 changed files with 11 additions and 7 deletions

View file

@ -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"
}
}
}

View file

@ -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)

View file

@ -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))
}
}
}