Skip to content

Commit

Permalink
Don't hide null issues (#4313)
Browse files Browse the repository at this point in the history
* Don't hide null checks

* Simplify code
  • Loading branch information
BraisGabin committed Nov 20, 2021
1 parent 7c2d93c commit 5f9e4a5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal object DefaultConfig {
const val RESOURCE_NAME = "default-detekt-config.yml"

fun newInstance(): Config {
val configUrl = javaClass.getResource("/$RESOURCE_NAME")
val configUrl = javaClass.getResource("/$RESOURCE_NAME")!!
return YamlConfig.loadResource(configUrl)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DefaultConfigProvider : DefaultConfigurationProvider {
override fun get(): Config = DefaultConfig.newInstance()

override fun copy(targetLocation: Path) {
val configUrl = javaClass.getResource("/${DefaultConfig.RESOURCE_NAME}")
val configUrl = javaClass.getResource("/${DefaultConfig.RESOURCE_NAME}")!!
Files.copy(configUrl.openStream(), targetLocation, StandardCopyOption.REPLACE_EXISTING)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ const val CONFIGURATION_DETEKT = "detekt"
const val CONFIGURATION_DETEKT_PLUGINS = "detektPlugins"

internal fun loadDetektVersion(classLoader: ClassLoader): String = Properties().run {
load(classLoader.getResourceAsStream("versions.properties"))
load(classLoader.getResourceAsStream("versions.properties")!!)
getProperty("detektVersion")
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HtmlOutputReport : OutputReport() {
override val name = "HTML report"

override fun render(detektion: Detektion) =
javaClass.getResource("/$DEFAULT_TEMPLATE")
javaClass.getResource("/$DEFAULT_TEMPLATE")!!
.openStream()
.bufferedReader()
.use { it.readText() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ internal object Resources

fun resourceUrl(name: String): URL {
val explicitName = if (name.startsWith("/")) name else "/$name"
val resource = Resources::class.java.getResource(explicitName)
requireNotNull(resource) { "Make sure the resource '$name' exists!" }
return resource
return requireNotNull(Resources::class.java.getResource(explicitName)) { "Make sure the resource '$name' exists!" }
}

fun resource(name: String): URI = resourceUrl(name).toURI()
Expand Down

0 comments on commit 5f9e4a5

Please sign in to comment.