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 { properties {
property "sonar.sources", project(":vector").android.sourceSets.main.java.srcDirs property "sonar.sources", project(":vector").android.sourceSets.main.java.srcDirs
// exclude source code from analyses separated by a colon (:) // 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.roomdirectory.PublicRoom
import org.matrix.android.sdk.api.session.room.model.thirdparty.RoomDirectoryData import org.matrix.android.sdk.api.session.room.model.thirdparty.RoomDirectoryData
import org.matrix.android.sdk.api.util.MatrixItem import org.matrix.android.sdk.api.util.MatrixItem
import timber.log.Timber
@Parcelize @Parcelize
data class RoomPreviewData( data class RoomPreviewData(
@ -83,6 +84,7 @@ class RoomPreviewActivity : VectorBaseActivity(), ToolbarConfigurable {
if (args?.worldReadable == true) { 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 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 // 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) addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args)
} else { } else {
addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args) addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args)

View File

@ -48,7 +48,8 @@ class VectorSettingsDevicesFragment @Inject constructor(
) : VectorBaseFragment(), DevicesController.Callback { ) : VectorBaseFragment(), DevicesController.Callback {
// used to avoid requesting to enter the password for each deletion // 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 override fun getLayoutResId() = R.layout.fragment_generic_recycler
@ -91,7 +92,7 @@ class VectorSettingsDevicesFragment @Inject constructor(
super.showFailure(throwable) super.showFailure(throwable)
// Password is maybe not good, for safety measure, reset it here // Password is maybe not good, for safety measure, reset it here
mAccountPassword = "" mAccountPass = ""
} }
override fun onDestroyView() { 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. * Show a dialog to ask for user password, or use a previously entered password.
*/ */
private fun maybeShowDeleteDeviceWithPasswordDialog() { private fun maybeShowDeleteDeviceWithPasswordDialog() {
if (mAccountPassword.isNotEmpty()) { if (mAccountPass.isNotEmpty()) {
viewModel.handle(DevicesAction.Password(mAccountPassword)) viewModel.handle(DevicesAction.Password(mAccountPass))
} else { } else {
PromptPasswordDialog().show(requireActivity()) { password -> PromptPasswordDialog().show(requireActivity()) { password ->
mAccountPassword = password mAccountPass = password
viewModel.handle(DevicesAction.Password(mAccountPassword)) viewModel.handle(DevicesAction.Password(mAccountPass))
} }
} }
} }