Move certain ignores from the baseline to the specified files. This makes refactoring much less fragile.

This commit is contained in:
tzugen 2021-05-19 19:24:30 +02:00
parent 689b704bc5
commit b559f6420e
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
15 changed files with 35 additions and 99 deletions

View File

@ -42,6 +42,7 @@ import retrofit2.Call
* Special wrapper for [SubsonicAPIDefinition] that checks if [currentApiVersion] is suitable * Special wrapper for [SubsonicAPIDefinition] that checks if [currentApiVersion] is suitable
* for this call. * for this call.
*/ */
@Suppress("TooManyFunctions")
internal class ApiVersionCheckWrapper( internal class ApiVersionCheckWrapper(
val api: SubsonicAPIDefinition, val api: SubsonicAPIDefinition,
var currentApiVersion: SubsonicAPIVersions var currentApiVersion: SubsonicAPIVersions

View File

@ -183,7 +183,7 @@ class SubsonicAPIClient(
this.addInterceptor(loggingInterceptor) this.addInterceptor(loggingInterceptor)
} }
@SuppressWarnings("TrustAllX509TrustManager") @SuppressWarnings("TrustAllX509TrustManager", "EmptyFunctionBlock")
private fun OkHttpClient.Builder.allowSelfSignedCertificates() { private fun OkHttpClient.Builder.allowSelfSignedCertificates() {
val trustManager = object : X509TrustManager { val trustManager = object : X509TrustManager {
override fun checkClientTrusted(p0: Array<out X509Certificate>?, p1: String?) {} override fun checkClientTrusted(p0: Array<out X509Certificate>?, p1: String?) {}

View File

@ -10,6 +10,7 @@ import java.lang.NumberFormatException
/** /**
* Subsonic REST API versions. * Subsonic REST API versions.
*/ */
@Suppress("MagicNumber", "ComplexMethod", "ReturnCount", "ThrowsCount")
@JsonDeserialize(using = SubsonicAPIVersions.Companion.SubsonicAPIVersionsDeserializer::class) @JsonDeserialize(using = SubsonicAPIVersions.Companion.SubsonicAPIVersionsDeserializer::class)
enum class SubsonicAPIVersions(val subsonicVersions: String, val restApiVersion: String) { enum class SubsonicAPIVersions(val subsonicVersions: String, val restApiVersion: String) {
V1_1_0("3.8", "1.1.0"), V1_1_0("3.8", "1.1.0"),

View File

@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
/** /**
* Common API errors. * Common API errors.
*/ */
@Suppress("MagicNumber")
@JsonDeserialize(using = SubsonicError.Companion.SubsonicErrorDeserializer::class) @JsonDeserialize(using = SubsonicError.Companion.SubsonicErrorDeserializer::class)
sealed class SubsonicError(val code: Int) { sealed class SubsonicError(val code: Int) {
data class Generic(val message: String) : SubsonicError(0) data class Generic(val message: String) : SubsonicError(0)

View File

@ -63,6 +63,7 @@ class VersionAwareJacksonConverterFactory(
} }
} }
@Suppress("SwallowedException")
class VersionAwareResponseBodyConverter<T> ( class VersionAwareResponseBodyConverter<T> (
private val notifier: (SubsonicAPIVersions) -> Unit = {}, private val notifier: (SubsonicAPIVersions) -> Unit = {},
private val adapter: ObjectReader private val adapter: ObjectReader

View File

@ -11,6 +11,7 @@ fun String.toHexBytes(): String = this.toByteArray().toHexBytes()
/** /**
* Converts given [ByteArray] to corresponding hex chars representation. * Converts given [ByteArray] to corresponding hex chars representation.
*/ */
@Suppress("MagicNumber")
fun ByteArray.toHexBytes(): String { fun ByteArray.toHexBytes(): String {
val hexChars = CharArray(this.size * 2) val hexChars = CharArray(this.size * 2)
for (j in 0..this.lastIndex) { for (j in 0..this.lastIndex) {

View File

@ -38,6 +38,7 @@ enum class AlbumListType(val typeName: String) {
else -> throw IllegalArgumentException("Unknown type: $typeName") else -> throw IllegalArgumentException("Unknown type: $typeName")
} }
@Suppress("UnusedPrivateMember") // Used in the tests
private operator fun String.contains(other: String) = this.equals(other, true) private operator fun String.contains(other: String) = this.equals(other, true)
} }
} }

View File

@ -9,6 +9,7 @@ import org.moire.ultrasonic.api.subsonic.SubsonicError
* *
* [responseHttpCode] will be there always. * [responseHttpCode] will be there always.
*/ */
@Suppress("MagicNumber")
class StreamResponse( class StreamResponse(
val stream: InputStream? = null, val stream: InputStream? = null,
val apiError: SubsonicError? = null, val apiError: SubsonicError? = null,

View File

@ -2,66 +2,6 @@
<SmellBaseline> <SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues> <ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues> <CurrentIssues>
<ID>ComplexMethod:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$@JvmStatic @Throws(IllegalArgumentException::class) fun getClosestKnownClientApiVersion(apiVersion: String): SubsonicAPIVersions</ID>
<ID>EmptyFunctionBlock:SubsonicAPIClient.kt$SubsonicAPIClient.&lt;no name provided&gt;${}</ID>
<ID>MagicNumber:PasswordExt.kt$0xFF</ID>
<ID>MagicNumber:PasswordExt.kt$4</ID>
<ID>MagicNumber:PasswordMD5Interceptor.kt$PasswordMD5Interceptor$16</ID>
<ID>MagicNumber:StreamResponse.kt$StreamResponse$200</ID>
<ID>MagicNumber:StreamResponse.kt$StreamResponse$300</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$10</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$11</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$12</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$13</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$14</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$15</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$16</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$3</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$4</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$5</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$6</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$7</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$8</ID>
<ID>MagicNumber:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$9</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.Companion$10</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.Companion$20</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.Companion$30</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.Companion$40</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.Companion$41</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.Companion$50</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.Companion$60</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.Companion$70</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.IncompatibleClientProtocolVersion$20</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.IncompatibleServerProtocolVersion$30</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.RequestedDataWasNotFound$70</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.RequiredParamMissing$10</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.TokenAuthNotSupportedForLDAP$41</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.TrialPeriodIsOver$60</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.UserNotAuthorizedForOperation$50</ID>
<ID>MagicNumber:SubsonicError.kt$SubsonicError.WrongUsernameOrPassword$40</ID>
<ID>ReturnCount:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$@JvmStatic @Throws(IllegalArgumentException::class) fun getClosestKnownClientApiVersion(apiVersion: String): SubsonicAPIVersions</ID>
<ID>SwallowedException:VersionAwareJacksonConverterFactory.kt$VersionAwareJacksonConverterFactory.VersionAwareResponseBodyConverter$catch (e: IllegalArgumentException) { // no-op }</ID>
<ID>ThrowsCount:SubsonicAPIVersions.kt$SubsonicAPIVersions.Companion$@JvmStatic @Throws(IllegalArgumentException::class) fun getClosestKnownClientApiVersion(apiVersion: String): SubsonicAPIVersions</ID>
<ID>TooManyFunctions:ApiVersionCheckWrapper.kt$ApiVersionCheckWrapper : SubsonicAPIDefinition</ID>
<ID>UnusedPrivateMember:AlbumListType.kt$AlbumListType.Companion$private operator fun String.contains(other: String)</ID>
<ID>CommentOverPrivateFunction:EditServerFragment.kt$EditServerFragment$ private fun areFieldsChanged(): Boolean</ID>
<ID>CommentOverPrivateFunction:EditServerFragment.kt$EditServerFragment$ private fun finishActivity()</ID>
<ID>CommentOverPrivateFunction:EditServerFragment.kt$EditServerFragment$ private fun getFields(): Boolean</ID>
<ID>CommentOverPrivateFunction:EditServerFragment.kt$EditServerFragment$ private fun setFields()</ID>
<ID>CommentOverPrivateFunction:EditServerFragment.kt$EditServerFragment$ private fun testConnection()</ID>
<ID>CommentOverPrivateFunction:FileLoggerTree.kt$FileLoggerTree$ private fun getNextLogFile()</ID>
<ID>CommentOverPrivateFunction:FileLoggerTree.kt$FileLoggerTree$ private fun getNumberedFile(next: Boolean)</ID>
<ID>CommentOverPrivateFunction:MediaPlayerService.kt$MediaPlayerService$ private fun buildForegroundNotification( playerState: PlayerState, currentPlaying: DownloadFile? ): Notification</ID>
<ID>CommentOverPrivateFunction:RESTMusicService.kt$RESTMusicService$ @Throws(Exception::class) private fun search2( criteria: SearchCriteria ): SearchResult</ID>
<ID>CommentOverPrivateFunction:RESTMusicService.kt$RESTMusicService$ @Throws(Exception::class) private fun searchOld( criteria: SearchCriteria ): SearchResult</ID>
<ID>CommentOverPrivateFunction:ServerRowAdapter.kt$ServerRowAdapter$ private fun popupMenuItemClick(menuItem: MenuItem, position: Int): Boolean</ID>
<ID>CommentOverPrivateFunction:ServerRowAdapter.kt$ServerRowAdapter$ private fun serverMenuClick(view: View, position: Int)</ID>
<ID>CommentOverPrivateFunction:ServerSelectorFragment.kt$ServerSelectorFragment$ private fun editServer(index: Int)</ID>
<ID>CommentOverPrivateFunction:ServerSelectorFragment.kt$ServerSelectorFragment$ private fun onServerDeleted(index: Int)</ID>
<ID>CommentOverPrivateFunction:ServerSelectorFragment.kt$ServerSelectorFragment$ private fun setActiveServer(index: Int)</ID>
<ID>CommentOverPrivateFunction:ServerSettingsModel.kt$ServerSettingsModel$ private fun loadServerSettingFromPreferences( preferenceId: Int, serverId: Int, settings: SharedPreferences ): ServerSetting?</ID>
<ID>CommentOverPrivateFunction:ServerSettingsModel.kt$ServerSettingsModel$ private suspend fun areIndexesMissing(): Boolean</ID>
<ID>CommentOverPrivateFunction:ServerSettingsModel.kt$ServerSettingsModel$ private suspend fun reindexSettings()</ID>
<ID>ComplexCondition:DownloadHandler.kt$DownloadHandler.&lt;no name provided&gt;$!append &amp;&amp; !playNext &amp;&amp; !unpin &amp;&amp; !background</ID> <ID>ComplexCondition:DownloadHandler.kt$DownloadHandler.&lt;no name provided&gt;$!append &amp;&amp; !playNext &amp;&amp; !unpin &amp;&amp; !background</ID>
<ID>ComplexCondition:FilePickerAdapter.kt$FilePickerAdapter$currentDirectory.absolutePath == "/" || currentDirectory.absolutePath == "/storage" || currentDirectory.absolutePath == "/storage/emulated" || currentDirectory.absolutePath == "/mnt"</ID> <ID>ComplexCondition:FilePickerAdapter.kt$FilePickerAdapter$currentDirectory.absolutePath == "/" || currentDirectory.absolutePath == "/storage" || currentDirectory.absolutePath == "/storage/emulated" || currentDirectory.absolutePath == "/mnt"</ID>
<ID>ComplexCondition:LocalMediaPlayer.kt$LocalMediaPlayer$Util.getGaplessPlaybackPreference() &amp;&amp; Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN &amp;&amp; ( playerState === PlayerState.STARTED || playerState === PlayerState.PAUSED )</ID> <ID>ComplexCondition:LocalMediaPlayer.kt$LocalMediaPlayer$Util.getGaplessPlaybackPreference() &amp;&amp; Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN &amp;&amp; ( playerState === PlayerState.STARTED || playerState === PlayerState.PAUSED )</ID>
@ -89,7 +29,6 @@
<ID>ImplicitDefaultLocale:SongView.kt$SongView$String.format("%02d.", trackNumber)</ID> <ID>ImplicitDefaultLocale:SongView.kt$SongView$String.format("%02d.", trackNumber)</ID>
<ID>ImplicitDefaultLocale:SongView.kt$SongView$String.format("%s ", bitRate)</ID> <ID>ImplicitDefaultLocale:SongView.kt$SongView$String.format("%s ", bitRate)</ID>
<ID>ImplicitDefaultLocale:SongView.kt$SongView$String.format("%s &gt; %s", suffix, transcodedSuffix)</ID> <ID>ImplicitDefaultLocale:SongView.kt$SongView$String.format("%s &gt; %s", suffix, transcodedSuffix)</ID>
<ID>LargeClass:MediaPlayerService.kt$MediaPlayerService : Service</ID>
<ID>LargeClass:RESTMusicService.kt$RESTMusicService : MusicService</ID> <ID>LargeClass:RESTMusicService.kt$RESTMusicService : MusicService</ID>
<ID>LargeClass:TrackCollectionFragment.kt$TrackCollectionFragment : Fragment</ID> <ID>LargeClass:TrackCollectionFragment.kt$TrackCollectionFragment : Fragment</ID>
<ID>LongMethod:DownloadFile.kt$DownloadFile.DownloadTask$override fun execute()</ID> <ID>LongMethod:DownloadFile.kt$DownloadFile.DownloadTask$override fun execute()</ID>
@ -104,25 +43,11 @@
<ID>LongMethod:TrackCollectionFragment.kt$TrackCollectionFragment$override fun onViewCreated(view: View, savedInstanceState: Bundle?)</ID> <ID>LongMethod:TrackCollectionFragment.kt$TrackCollectionFragment$override fun onViewCreated(view: View, savedInstanceState: Bundle?)</ID>
<ID>LongMethod:TrackCollectionFragment.kt$TrackCollectionFragment$private fun updateDisplay(refresh: Boolean)</ID> <ID>LongMethod:TrackCollectionFragment.kt$TrackCollectionFragment$private fun updateDisplay(refresh: Boolean)</ID>
<ID>LongMethod:TrackCollectionFragment.kt$TrackCollectionFragment$private fun updateInterfaceWithEntries(musicDirectory: MusicDirectory)</ID> <ID>LongMethod:TrackCollectionFragment.kt$TrackCollectionFragment$private fun updateInterfaceWithEntries(musicDirectory: MusicDirectory)</ID>
<ID>LongParameterList:DownloadHandler.kt$DownloadHandler$( fragment: Fragment, append: Boolean, save: Boolean, autoPlay: Boolean, playNext: Boolean, shuffle: Boolean, songs: List&lt;MusicDirectory.Entry?&gt; )</ID>
<ID>LongParameterList:DownloadHandler.kt$DownloadHandler$( fragment: Fragment, id: String, name: String?, isShare: Boolean, isDirectory: Boolean, save: Boolean, append: Boolean, autoPlay: Boolean, shuffle: Boolean, background: Boolean, playNext: Boolean, unpin: Boolean, isArtist: Boolean )</ID>
<ID>LongParameterList:DownloadHandler.kt$DownloadHandler$( fragment: Fragment, id: String, name: String?, save: Boolean, append: Boolean, autoplay: Boolean, shuffle: Boolean, background: Boolean, playNext: Boolean, unpin: Boolean )</ID>
<ID>LongParameterList:DownloadHandler.kt$DownloadHandler$( fragment: Fragment, id: String?, save: Boolean, append: Boolean, autoPlay: Boolean, shuffle: Boolean, background: Boolean, playNext: Boolean, unpin: Boolean, isArtist: Boolean )</ID>
<ID>LongParameterList:ServerRowAdapter.kt$ServerRowAdapter$( private var context: Context, private var data: Array&lt;ServerSetting&gt;, private val model: ServerSettingsModel, private val activeServerProvider: ActiveServerProvider, private val manageMode: Boolean, private val serverDeletedCallback: ((Int) -&gt; Unit), private val serverEditRequestedCallback: ((Int) -&gt; Unit) )</ID> <ID>LongParameterList:ServerRowAdapter.kt$ServerRowAdapter$( private var context: Context, private var data: Array&lt;ServerSetting&gt;, private val model: ServerSettingsModel, private val activeServerProvider: ActiveServerProvider, private val manageMode: Boolean, private val serverDeletedCallback: ((Int) -&gt; Unit), private val serverEditRequestedCallback: ((Int) -&gt; Unit) )</ID>
<ID>MagicNumber:ActiveServerProvider.kt$ActiveServerProvider$8192</ID> <ID>MagicNumber:ActiveServerProvider.kt$ActiveServerProvider$8192</ID>
<ID>MagicNumber:AudioFocusHandler.kt$AudioFocusHandler$0.1f</ID>
<ID>MagicNumber:DownloadFile.kt$DownloadFile$100</ID>
<ID>MagicNumber:DownloadFile.kt$DownloadFile.DownloadTask$10</ID> <ID>MagicNumber:DownloadFile.kt$DownloadFile.DownloadTask$10</ID>
<ID>MagicNumber:DownloadFile.kt$DownloadFile.DownloadTask$1000L</ID> <ID>MagicNumber:DownloadFile.kt$DownloadFile.DownloadTask$1000L</ID>
<ID>MagicNumber:DownloadFile.kt$DownloadFile.DownloadTask$60</ID> <ID>MagicNumber:DownloadFile.kt$DownloadFile.DownloadTask$60</ID>
<ID>MagicNumber:DownloadHandler.kt$DownloadHandler$500</ID>
<ID>MagicNumber:FileLoggerTree.kt$FileLoggerTree$100</ID>
<ID>MagicNumber:FileLoggerTree.kt$FileLoggerTree$3</ID>
<ID>MagicNumber:FileLoggerTree.kt$FileLoggerTree$4</ID>
<ID>MagicNumber:FileLoggerTree.kt$FileLoggerTree$5</ID>
<ID>MagicNumber:FileLoggerTree.kt$FileLoggerTree$6</ID>
<ID>MagicNumber:FileLoggerTree.kt$FileLoggerTree$7</ID>
<ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer$100</ID>
<ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer$1000</ID> <ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer$1000</ID>
<ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.&lt;no name provided&gt;$1000</ID> <ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.&lt;no name provided&gt;$1000</ID>
<ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.&lt;no name provided&gt;$60000</ID> <ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.&lt;no name provided&gt;$60000</ID>
@ -134,13 +59,10 @@
<ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.BufferTask$8L</ID> <ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.BufferTask$8L</ID>
<ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.CheckCompletionTask$5000L</ID> <ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.CheckCompletionTask$5000L</ID>
<ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.PositionCache$50L</ID> <ID>MagicNumber:LocalMediaPlayer.kt$LocalMediaPlayer.PositionCache$50L</ID>
<ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$100</ID>
<ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$1000</ID> <ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$1000</ID>
<ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$256</ID> <ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$256</ID>
<ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$3</ID> <ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$3</ID>
<ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$4</ID> <ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService$4</ID>
<ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService.Companion$19</ID>
<ID>MagicNumber:MediaPlayerService.kt$MediaPlayerService.Companion$50L</ID>
<ID>MagicNumber:RESTMusicService.kt$RESTMusicService$206</ID> <ID>MagicNumber:RESTMusicService.kt$RESTMusicService$206</ID>
<ID>MagicNumber:RESTMusicService.kt$RESTMusicService$5</ID> <ID>MagicNumber:RESTMusicService.kt$RESTMusicService$5</ID>
<ID>MagicNumber:SongView.kt$SongView$3</ID> <ID>MagicNumber:SongView.kt$SongView$3</ID>
@ -159,16 +81,12 @@
<ID>ReturnCount:ServerRowAdapter.kt$ServerRowAdapter$ private fun popupMenuItemClick(menuItem: MenuItem, position: Int): Boolean</ID> <ID>ReturnCount:ServerRowAdapter.kt$ServerRowAdapter$ private fun popupMenuItemClick(menuItem: MenuItem, position: Int): Boolean</ID>
<ID>ReturnCount:TrackCollectionFragment.kt$TrackCollectionFragment$override fun onContextItemSelected(menuItem: MenuItem): Boolean</ID> <ID>ReturnCount:TrackCollectionFragment.kt$TrackCollectionFragment$override fun onContextItemSelected(menuItem: MenuItem): Boolean</ID>
<ID>ReturnCount:TrackCollectionFragment.kt$TrackCollectionFragment$override fun onOptionsItemSelected(item: MenuItem): Boolean</ID> <ID>ReturnCount:TrackCollectionFragment.kt$TrackCollectionFragment$override fun onOptionsItemSelected(item: MenuItem): Boolean</ID>
<ID>SpreadOperator:MediaPlayerService.kt$MediaPlayerService$(*compactActions)</ID>
<ID>SwallowedException:DownloadFile.kt$DownloadFile$catch (e: Exception) { Timber.w("Failed to set last-modified date on %s", file) }</ID>
<ID>SwallowedException:DownloadFile.kt$DownloadFile$catch (ex: IOException) { Timber.w("Failed to rename file %s to %s", completeFile, saveFile) }</ID>
<ID>SwallowedException:LocalMediaPlayer.kt$LocalMediaPlayer$catch (e: Throwable) { // Froyo or lower }</ID> <ID>SwallowedException:LocalMediaPlayer.kt$LocalMediaPlayer$catch (e: Throwable) { // Froyo or lower }</ID>
<ID>SwallowedException:LocalMediaPlayer.kt$LocalMediaPlayer$catch (e: Throwable) { }</ID> <ID>SwallowedException:LocalMediaPlayer.kt$LocalMediaPlayer$catch (e: Throwable) { }</ID>
<ID>SwallowedException:MediaPlayerService.kt$MediaPlayerService$catch (x: IndexOutOfBoundsException) { // Ignored }</ID> <ID>SwallowedException:MediaPlayerService.kt$MediaPlayerService$catch (x: IndexOutOfBoundsException) { // Ignored }</ID>
<ID>SwallowedException:NavigationActivity.kt$NavigationActivity$catch (e: Resources.NotFoundException) { destination.id.toString() }</ID> <ID>SwallowedException:NavigationActivity.kt$NavigationActivity$catch (e: Resources.NotFoundException) { destination.id.toString() }</ID>
<ID>ThrowsCount:ApiCallResponseChecker.kt$ApiCallResponseChecker.Companion$@Throws(SubsonicRESTException::class, IOException::class) fun checkResponseSuccessful(response: Response&lt;out SubsonicResponse&gt;)</ID> <ID>ThrowsCount:ApiCallResponseChecker.kt$ApiCallResponseChecker.Companion$@Throws(SubsonicRESTException::class, IOException::class) fun checkResponseSuccessful(response: Response&lt;out SubsonicResponse&gt;)</ID>
<ID>TooGenericExceptionCaught:DownloadFile.kt$DownloadFile$e: Exception</ID> <ID>TooGenericExceptionCaught:DownloadFile.kt$DownloadFile$e: Exception</ID>
<ID>TooGenericExceptionCaught:DownloadFile.kt$DownloadFile.DownloadTask$x: Exception</ID>
<ID>TooGenericExceptionCaught:FileLoggerTree.kt$FileLoggerTree$x: Throwable</ID> <ID>TooGenericExceptionCaught:FileLoggerTree.kt$FileLoggerTree$x: Throwable</ID>
<ID>TooGenericExceptionCaught:LocalMediaPlayer.kt$LocalMediaPlayer$e: Throwable</ID> <ID>TooGenericExceptionCaught:LocalMediaPlayer.kt$LocalMediaPlayer$e: Throwable</ID>
<ID>TooGenericExceptionCaught:LocalMediaPlayer.kt$LocalMediaPlayer$ex: Exception</ID> <ID>TooGenericExceptionCaught:LocalMediaPlayer.kt$LocalMediaPlayer$ex: Exception</ID>
@ -185,10 +103,8 @@
<ID>TooManyFunctions:MediaPlayerService.kt$MediaPlayerService : Service</ID> <ID>TooManyFunctions:MediaPlayerService.kt$MediaPlayerService : Service</ID>
<ID>TooManyFunctions:RESTMusicService.kt$RESTMusicService : MusicService</ID> <ID>TooManyFunctions:RESTMusicService.kt$RESTMusicService : MusicService</ID>
<ID>TooManyFunctions:TrackCollectionFragment.kt$TrackCollectionFragment : Fragment</ID> <ID>TooManyFunctions:TrackCollectionFragment.kt$TrackCollectionFragment : Fragment</ID>
<ID>TopLevelPropertyNaming:SubsonicUncaughtExceptionHandler.kt$private const val filename = "ultrasonic-stacktrace.txt"</ID>
<ID>UnusedPrivateMember:RESTMusicService.kt$RESTMusicService.Companion$private const val INDEXES_FOLDER_STORAGE_NAME = "indexes_folder"</ID> <ID>UnusedPrivateMember:RESTMusicService.kt$RESTMusicService.Companion$private const val INDEXES_FOLDER_STORAGE_NAME = "indexes_folder"</ID>
<ID>UtilityClassWithPublicConstructor:CommunicationErrorHandler.kt$CommunicationErrorHandler</ID> <ID>UtilityClassWithPublicConstructor:CommunicationErrorHandler.kt$CommunicationErrorHandler</ID>
<ID>UtilityClassWithPublicConstructor:FragmentTitle.kt$FragmentTitle</ID> <ID>UtilityClassWithPublicConstructor:FragmentTitle.kt$FragmentTitle</ID>
<ID>UnnecessaryAbstractClass:BaseStorageTest.kt$BaseStorageTest</ID>
</CurrentIssues> </CurrentIssues>
</SmellBaseline> </SmellBaseline>

View File

@ -62,13 +62,15 @@ style:
maxLineLength: 120 maxLineLength: 120
excludePackageStatements: false excludePackageStatements: false
excludeImportStatements: false excludeImportStatements: false
MagicNumber:
ignoreNumbers: ['-1', '0', '1', '2', '100']
ignoreEnums: true
ignorePropertyDeclaration: true
UnnecessaryAbstractClass:
active: false
comments: comments:
active: true active: true
CommentOverPrivateFunction:
active: true
CommentOverPrivateProperty:
active: true
UndocumentedPublicClass: UndocumentedPublicClass:
active: false active: false
searchInNestedClass: true searchInNestedClass: true

View File

@ -13,6 +13,7 @@ import timber.log.Timber
* A Timber Tree which can be used to log to a file * A Timber Tree which can be used to log to a file
* Subclass of the DebugTree so it inherits the Tag handling * Subclass of the DebugTree so it inherits the Tag handling
*/ */
@Suppress("MagicNumber")
class FileLoggerTree : Timber.DebugTree() { class FileLoggerTree : Timber.DebugTree() {
private val dateFormat = SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault()) private val dateFormat = SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault())

View File

@ -19,6 +19,7 @@ import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.io.OutputStream import java.io.OutputStream
import java.io.RandomAccessFile import java.io.RandomAccessFile
import org.koin.core.component.KoinApiExtension
import org.koin.java.KoinJavaComponent.inject import org.koin.java.KoinJavaComponent.inject
import org.moire.ultrasonic.domain.MusicDirectory import org.moire.ultrasonic.domain.MusicDirectory
import org.moire.ultrasonic.service.MusicServiceFactory.getMusicService import org.moire.ultrasonic.service.MusicServiceFactory.getMusicService
@ -34,6 +35,7 @@ import timber.log.Timber
* @author Sindre Mehus * @author Sindre Mehus
* @version $Id$ * @version $Id$
*/ */
@KoinApiExtension
class DownloadFile( class DownloadFile(
private val context: Context, private val context: Context,
val song: MusicDirectory.Entry, val song: MusicDirectory.Entry,
@ -190,8 +192,8 @@ class DownloadFile(
} }
completeWhenDone = false completeWhenDone = false
} }
} catch (ex: IOException) { } catch (e: IOException) {
Timber.w("Failed to rename file %s to %s", completeFile, saveFile) Timber.w(e, "Failed to rename file %s to %s", completeFile, saveFile)
} }
} }
@ -199,6 +201,8 @@ class DownloadFile(
return String.format("DownloadFile (%s)", song) return String.format("DownloadFile (%s)", song)
} }
@KoinApiExtension
@Suppress("TooGenericExceptionCaught")
private inner class DownloadTask : CancellableTask() { private inner class DownloadTask : CancellableTask() {
override fun execute() { override fun execute() {
var inputStream: InputStream? = null var inputStream: InputStream? = null
@ -286,7 +290,7 @@ class DownloadFile(
Util.renameFile(partialFile, completeFile) Util.renameFile(partialFile, completeFile)
} }
} }
} catch (x: Exception) { } catch (e: Exception) {
Util.close(outputStream) Util.close(outputStream)
Util.delete(completeFile) Util.delete(completeFile)
Util.delete(saveFile) Util.delete(saveFile)
@ -295,7 +299,7 @@ class DownloadFile(
if (retryCount > 0) { if (retryCount > 0) {
--retryCount --retryCount
} }
Timber.w(x, "Failed to download '%s'.", song) Timber.w(e, "Failed to download '%s'.", song)
} }
} finally { } finally {
Util.close(inputStream) Util.close(inputStream)
@ -332,8 +336,8 @@ class DownloadFile(
val size = Util.getMinDisplayMetric(context) val size = Util.getMinDisplayMetric(context)
musicService.getCoverArt(song, size, true, true) musicService.getCoverArt(song, size, true, true)
} }
} catch (x: Exception) { } catch (e: Exception) {
Timber.e(x, "Failed to get cover art.") Timber.e(e, "Failed to get cover art.")
} }
} }
@ -376,7 +380,7 @@ class DownloadFile(
raf.setLength(length) raf.setLength(length)
raf.close() raf.close()
} catch (e: Exception) { } catch (e: Exception) {
Timber.w("Failed to set last-modified date on %s", file) Timber.w(e, "Failed to set last-modified date on %s", file)
} }
} }
} }

View File

@ -47,6 +47,7 @@ import timber.log.Timber
* Android Foreground Service for playing music * Android Foreground Service for playing music
* while the rest of the Ultrasonic App is in the background. * while the rest of the Ultrasonic App is in the background.
*/ */
@Suppress("LargeClass")
class MediaPlayerService : Service() { class MediaPlayerService : Service() {
private val binder: IBinder = SimpleServiceBinder(this) private val binder: IBinder = SimpleServiceBinder(this)
private val scrobbler = Scrobbler() private val scrobbler = Scrobbler()
@ -596,6 +597,7 @@ class MediaPlayerService : Service() {
/** /**
* This method builds a notification, reusing the Notification Builder if possible * This method builds a notification, reusing the Notification Builder if possible
*/ */
@Suppress("SpreadOperator")
private fun buildForegroundNotification( private fun buildForegroundNotification(
playerState: PlayerState, playerState: PlayerState,
currentPlaying: DownloadFile? currentPlaying: DownloadFile?
@ -893,6 +895,7 @@ class MediaPlayerService : Service() {
mediaSession?.setMediaButtonReceiver(null) mediaSession?.setMediaButtonReceiver(null)
} }
@Suppress("MagicNumber")
companion object { companion object {
private const val NOTIFICATION_CHANNEL_ID = "org.moire.ultrasonic" private const val NOTIFICATION_CHANNEL_ID = "org.moire.ultrasonic"
private const val NOTIFICATION_CHANNEL_NAME = "Ultrasonic background service" private const val NOTIFICATION_CHANNEL_NAME = "Ultrasonic background service"

View File

@ -19,6 +19,7 @@ import org.moire.ultrasonic.util.Util
/** /**
* Retrieves a list of songs and adds them to the now playing list * Retrieves a list of songs and adds them to the now playing list
*/ */
@Suppress("LongParameterList")
@KoinApiExtension @KoinApiExtension
class DownloadHandler( class DownloadHandler(
val mediaPlayerController: MediaPlayerController, val mediaPlayerController: MediaPlayerController,

View File

@ -6,8 +6,6 @@ import java.io.File
import java.io.PrintWriter import java.io.PrintWriter
import timber.log.Timber import timber.log.Timber
private const val filename = "ultrasonic-stacktrace.txt"
/** /**
* Logs the stack trace of uncaught exceptions to a file on the SD card. * Logs the stack trace of uncaught exceptions to a file on the SD card.
*/ */
@ -22,7 +20,7 @@ class SubsonicUncaughtExceptionHandler(
var printWriter: PrintWriter? = null var printWriter: PrintWriter? = null
try { try {
file = File(FileUtil.getUltrasonicDirectory(), filename) file = File(FileUtil.getUltrasonicDirectory(), STACKTRACE_NAME)
printWriter = PrintWriter(file) printWriter = PrintWriter(file)
val logMessage = String.format( val logMessage = String.format(
"Android API level: %s\nUltrasonic version name: %s\n" + "Android API level: %s\nUltrasonic version name: %s\n" +
@ -40,4 +38,8 @@ class SubsonicUncaughtExceptionHandler(
defaultHandler?.uncaughtException(thread, throwable) defaultHandler?.uncaughtException(thread, throwable)
} }
} }
companion object {
private const val STACKTRACE_NAME = "ultrasonic-stacktrace.txt"
}
} }