Skip to content

Commit

Permalink
Analysis: Suppress spread operator on page list event listener
Browse files Browse the repository at this point in the history
Detekt Warning: "SpreadOperator: In most cases using a spread
operator causes a full copy of the array to be created before calling a
method. This may result in a performance penalty."

Now that this warning is suppressed close to source, it is no longer
needed to be in the baseline.
  • Loading branch information
ParaskP7 committed Nov 1, 2023
1 parent d2ccda4 commit bc63a42
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class PostListEventListener(
}
}

@Suppress("unused")
@Suppress("unused", "SpreadOperator")
@Subscribe(threadMode = BACKGROUND)
fun onMediaChanged(event: OnMediaChanged) {
if (!event.isError) {
Expand Down Expand Up @@ -283,7 +283,7 @@ class PostListEventListener(
uploadStatusChanged(event.media.localPostId)
}

@Suppress("unused")
@Suppress("unused", "SpreadOperator")
@Subscribe(threadMode = BACKGROUND)
fun onEventBackgroundThread(event: UploadService.UploadMediaRetryEvent) {
if (event.mediaModelList != null && !event.mediaModelList.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class PageListEventListener(
}
}

@Suppress("unused")
@Suppress("unused", "SpreadOperator")
@Subscribe(threadMode = BACKGROUND)
fun onMediaChanged(event: OnMediaChanged) {
uploadStatusChanged(*event.mediaList.map { LocalId(it.localPostId) }.toTypedArray())
Expand Down Expand Up @@ -167,7 +167,7 @@ class PageListEventListener(
}
}

@Suppress("unused")
@Suppress("unused", "SpreadOperator")
@Subscribe(threadMode = BACKGROUND)
fun onEventBackgroundThread(event: UploadService.UploadMediaRetryEvent) {
if (event.mediaModelList != null && event.mediaModelList.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class PageListViewModel @Inject constructor(
pagesViewModel.onImagesChanged()
}

@Suppress("unused")
@Suppress("unused", "SpreadOperator")
@Subscribe(threadMode = ThreadMode.BACKGROUND)
fun onMediaChanged(event: OnMediaChanged) {
if (!event.isError) {
Expand Down
6 changes: 0 additions & 6 deletions config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@
<ID>ReturnCount:UploadActionUseCase.kt$UploadActionUseCase$fun getAutoUploadAction(post: PostImmutableModel, site: SiteModel): UploadAction</ID>
<ID>ReturnCount:WPEditTextWithChipsOutlined.kt$WPEditTextWithChipsOutlined$private fun endsWithDelimiter(string: String): Boolean</ID>
<ID>ReturnCount:WPEditTextWithChipsOutlined.kt$WPEditTextWithChipsOutlined$private fun removeDelimiterFromItemIfPresent(item: String?): String?</ID>
<ID>SpreadOperator:PageListEventListener.kt$PageListEventListener$(*event.mediaList.map { LocalId(it.localPostId) }.toTypedArray())</ID>
<ID>SpreadOperator:PageListEventListener.kt$PageListEventListener$(*postsToRefresh.map { LocalId(it.id) }.toTypedArray())</ID>
<ID>SpreadOperator:PageListViewModel.kt$PageListViewModel$(*event.mediaList.map { it.mediaId }.toLongArray())</ID>
<ID>SpreadOperator:PostListEventListener.kt$PostListEventListener$(*event.mediaList.map { it.localPostId }.toIntArray())</ID>
<ID>SpreadOperator:PostListEventListener.kt$PostListEventListener$(*event.mediaList.map { it.mediaId }.toLongArray())</ID>
<ID>SpreadOperator:PostListEventListener.kt$PostListEventListener$(*postsToRefresh.map { it.id }.toIntArray())</ID>
<ID>SpreadOperator:UiHelpers.kt$UiHelpers$( uiString.stringRes, *uiString.params.map { value -> getTextOfUiString( context, value ) }.toTypedArray() )</ID>
<ID>ThrowsCount:PageListDialogHelper.kt$PageListDialogHelper$fun onNegativeClickedForBasicDialog( instanceTag: String, editPage: (RemoteId, LoadAutoSaveRevision) -> Unit, copyPage: (RemoteId) -> Unit )</ID>
<ID>ThrowsCount:PageListDialogHelper.kt$PageListDialogHelper$fun onPositiveClickedForBasicDialog( instanceTag: String, deletePage: (RemoteId) -> Unit, editPage: (RemoteId, LoadAutoSaveRevision) -> Unit, editPageFirst: (RemoteId) -> Unit )</ID>
Expand Down

0 comments on commit bc63a42

Please sign in to comment.