Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Detekt on every source set #422

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ allprojects {
// Tutorial : https://medium.com/@nagendran.p/integrating-detekt-in-the-android-studio-442128e971f8
detekt {
config.setFrom(files("../config/detekt/detekt.yml"))
source.setFrom(files("src/main/java", "src/main/kotlin"))
// preconfigure defaults
buildUponDefaultConfig = false
ignoredBuildTypes = listOf("release")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ class MediaEventTypeTest {
assertEquals("pos", MediaEventType.Pos.toString())
assertEquals("uptime", MediaEventType.Uptime.toString())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class ImageScalingServiceTest {
val baseUrl = IlHost.PROD
val imageUrl = "https://www.rts.ch/2020/05/18/14/20/11333286.image/16x9"


val imageScalingService = ImageScalingService(baseUrl)
val scaledImageUrl = imageScalingService.getScaledImageUrl(imageUrl)
val encodedImageUrl = URLEncoder.encode(imageUrl, Charsets.UTF_8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ class ResourceSelectorTest {

fun createSupportedDrmResource(): Resource {
return Resource(
"", Resource.Type.DASH, drmList = listOf(
url = "",
type = Resource.Type.DASH,
drmList = listOf(
Drm(Drm.Type.WIDEVINE, "https://widevine.license.co"),
Drm(Drm.Type.PLAYREADY, "https://playready.license.co")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,18 @@ class TestJsonSerialization {

@Test
fun testMediaCompositionValidJson() {
val json =
"{\"chapterUrn\":\"urn:srf:video:12343\" ,\"chapterList\": [{\"urn\":\"urn:srf:video:12343\",\"title\":\"Chapter title\",\"imageUrl\":\"https://image.png\"}]}"
val json = """
{
"chapterUrn": "urn:srf:video:12343",
"chapterList": [
{
"urn": "urn:srf:video:12343",
"title": "Chapter title",
"imageUrl": "https://image.png"
}
]
}
"""
val mediaComposition = jsonSerializer.decodeFromString<MediaComposition>(json)
Assert.assertNotNull(mediaComposition)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package ch.srgssr.pillarbox.player

import android.net.Uri
import androidx.media3.common.MediaItem
import androidx.media3.common.Timeline
import androidx.media3.exoplayer.ExoPlayer
import ch.srgssr.pillarbox.player.test.utils.AnalyticsListenerCommander
import ch.srgssr.pillarbox.player.tracker.CurrentMediaItemTracker
Expand Down Expand Up @@ -34,13 +33,19 @@ class TestCurrentMediaItemTracker {
every { analyticsCommander.currentMediaItem } returns null
every { analyticsCommander.currentPosition } returns 1000L
tracker = TestTracker()
currentItemTracker = CurrentMediaItemTracker(analyticsCommander, MediaItemTrackerRepository().apply {
registerFactory(TestTracker::class.java, object : MediaItemTracker.Factory {
override fun create(): MediaItemTracker {
return tracker
}
})
})
currentItemTracker = CurrentMediaItemTracker(
player = analyticsCommander,
mediaItemTrackerProvider = MediaItemTrackerRepository().apply {
registerFactory(
TestTracker::class.java,
object : MediaItemTracker.Factory {
override fun create(): MediaItemTracker {
return tracker
}
}
)
}
)
}

@After
Expand Down Expand Up @@ -348,33 +353,4 @@ class TestCurrentMediaItemTracker {
}
}
}

private class DummyTimeline(private val mediaItem: MediaItem) : Timeline() {

override fun getWindowCount(): Int {
return 1
}

override fun getWindow(windowIndex: Int, window: Window, defaultPositionProjectionUs: Long): Window {
window.mediaItem = mediaItem
return window
}

override fun getPeriodCount(): Int {
return 0
}

override fun getPeriod(periodIndex: Int, period: Period, setIds: Boolean): Period {
return Period()
}

override fun getIndexOfPeriod(uid: Any): Int {
return 0
}

override fun getUidOfPeriod(periodIndex: Int): Any {
return Any()
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ class TestFormatExtension {
Assert.assertTrue(format.hasSelection(C.SELECTION_FLAG_AUTOSELECT or C.SELECTION_FLAG_DEFAULT))
Assert.assertFalse(format.hasSelection(C.SELECTION_FLAG_FORCED))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class TestMediaItemTrackerRepository {
}

override fun start(player: ExoPlayer, initialData: Any?) {

// Nothing
}

override fun stop(player: ExoPlayer, reason: MediaItemTracker.StopReason, positionMs: Long) {

// Nothing
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class TestSeekIncrement {
Assert.assertEquals(seekForward, increment.forward)
}


companion object {
private val NegativeIncrement = (-10).seconds
private val PositiveIncrement = 5.seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TestTracksExtension {
):
Format {
return Format.Builder()
.setId("id:${label}")
.setId("id:$label")
.setLabel(label)
.setLanguage("fr")
.setSelectionFlags(selectionFlags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TestUnsupportedTracks {

private fun createSampleFormat(label: String): Format {
return Format.Builder()
.setId("id:${label}")
.setId("id:$label")
.setLabel(label)
.setContainerMimeType(MimeTypes.AUDIO_MP4)
.build()
Expand All @@ -120,5 +120,4 @@ class TestUnsupportedTracks {
}
}
}

}
Loading