Skip to content

Commit

Permalink
Tidy/remove unnecessary imports and suppressions (#2975)
Browse files Browse the repository at this point in the history
  • Loading branch information
aSemy authored Apr 25, 2023
1 parent 609c546 commit fcb2f4a
Show file tree
Hide file tree
Showing 26 changed files with 26 additions and 60 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.jetbrains.ValidatePublications
import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.publicationChannels

@Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1 https://github.com/gradle/gradle/pull/23639
Expand Down
1 change: 0 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.jetbrains.dokkaVersion
import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.registerDokkaArtifactPublication

plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package matchers.content
import assertk.assertThat
import assertk.assertions.contains
import assertk.assertions.isEqualTo
import assertk.assertions.isNotNull
import org.jetbrains.dokka.model.withDescendants
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.test.tools.matchers.content.*
Expand Down
15 changes: 8 additions & 7 deletions core/src/main/kotlin/configuration.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka

import org.jetbrains.dokka.utilities.cast
Expand Down Expand Up @@ -108,11 +106,13 @@ data class GlobalDokkaConfiguration(

fun DokkaConfiguration.apply(globals: GlobalDokkaConfiguration): DokkaConfiguration = this.apply {
sourceSets.forEach {
it.perPackageOptions.cast<MutableList<DokkaConfiguration.PackageOptions>>().addAll(globals.perPackageOptions ?: emptyList())
it.perPackageOptions.cast<MutableList<DokkaConfiguration.PackageOptions>>()
.addAll(globals.perPackageOptions ?: emptyList())
}

sourceSets.forEach {
it.externalDocumentationLinks.cast<MutableSet<DokkaConfiguration.ExternalDocumentationLink>>().addAll(globals.externalDocumentationLinks ?: emptyList())
it.externalDocumentationLinks.cast<MutableSet<DokkaConfiguration.ExternalDocumentationLink>>()
.addAll(globals.externalDocumentationLinks ?: emptyList())
}

sourceSets.forEach {
Expand Down Expand Up @@ -173,6 +173,7 @@ interface DokkaConfiguration : Serializable {
val dependentSourceSets: Set<DokkaSourceSetID>
val samples: Set<File>
val includes: Set<File>

@Deprecated(message = "Use [documentedVisibilities] property for a more flexible control over documented visibilities")
val includeNonPublic: Boolean
val reportUndocumented: Boolean
Expand Down Expand Up @@ -237,6 +238,7 @@ interface DokkaConfiguration : Serializable {

interface PackageOptions : Serializable {
val matchingRegex: String

@Deprecated("Use [documentedVisibilities] property for a more flexible control over documented visibilities")
val includeNonPublic: Boolean
val reportUndocumented: Boolean?
Expand All @@ -253,6 +255,7 @@ interface DokkaConfiguration : Serializable {
}
}

@Suppress("FunctionName")
fun ExternalDocumentationLink(
url: URL? = null,
packageListUrl: URL? = null
Expand All @@ -265,10 +268,8 @@ fun ExternalDocumentationLink(
throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link")
}


@Suppress("FunctionName")
fun ExternalDocumentationLink(
url: String, packageListUrl: String? = null
): ExternalDocumentationLinkImpl =
ExternalDocumentationLink(url.let(::URL), packageListUrl?.let(::URL))


1 change: 0 additions & 1 deletion core/src/main/kotlin/defaultExternalLinks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ fun ExternalDocumentationLink.Companion.androidX(): ExternalDocumentationLinkImp
url = URL("https://developer.android.com/reference/kotlin/"),
packageListUrl = URL("https://developer.android.com/reference/kotlin/androidx/package-list")
)

1 change: 0 additions & 1 deletion core/src/main/kotlin/links/DRI.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jetbrains.dokka.links

import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.CLASS
import com.fasterxml.jackson.databind.ObjectMapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka.it.gradle

import org.gradle.testkit.runner.TaskOutcome
Expand Down Expand Up @@ -43,6 +41,7 @@ class ConfigurationTest(override val versions: BuildVersions) : AbstractGradleIn
* and `failOnWarning` are enabled - it should fail
*/
@Test
@Suppress("FunctionName")
fun `should fail with DokkaException and readable message if failOnWarning is triggered`() {
val result = createGradleRunner(
"-info",
Expand All @@ -58,7 +57,7 @@ class ConfigurationTest(override val versions: BuildVersions) : AbstractGradleIn
result.output.contains(
"""
FAILURE: Build failed with an exception\\.
\* What went wrong:
Execution failed for task ':dokkaHtml'\\.
> Failed with warningCount=\d and errorCount=\d
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka.analysis

import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
Expand All @@ -9,6 +7,7 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.utilities.DokkaLogger
import java.io.Closeable

@Suppress("FunctionName")
fun ProjectKotlinAnalysis(
sourceSets: List<DokkaSourceSet>,
logger: DokkaLogger,
Expand All @@ -30,6 +29,7 @@ fun ProjectKotlinAnalysis(
* Usually the analysis created for samples is short-lived and can be closed right after
* it's been used, there's no need to wait for [projectKotlinAnalysis] to be closed as it must be handled separately.
*/
@Suppress("FunctionName")
fun SamplesKotlinAnalysis(
sourceSets: List<DokkaSourceSet>,
logger: DokkaLogger,
Expand All @@ -46,7 +46,7 @@ fun SamplesKotlinAnalysis(
sourceSet = sourceSet,
analysisConfiguration = analysisConfiguration
)
}
}

return EnvironmentKotlinAnalysis(environments, projectKotlinAnalysis)
}
Expand All @@ -59,13 +59,15 @@ class DokkaAnalysisConfiguration(
val ignoreCommonBuiltIns: Boolean = false
)

@Deprecated(message = "Construct using list of DokkaSourceSets and logger",
@Deprecated(
message = "Construct using list of DokkaSourceSets and logger",
replaceWith = ReplaceWith("KotlinAnalysis(context.configuration.sourceSets, context.logger)")
)
fun KotlinAnalysis(context: DokkaContext): KotlinAnalysis =
ProjectKotlinAnalysis(context.configuration.sourceSets, context.logger)

@Deprecated(message = "It was renamed to `ProjectKotlinAnalysis`",
@Deprecated(
message = "It was renamed to `ProjectKotlinAnalysis`",
replaceWith = ReplaceWith("ProjectKotlinAnalysis(sourceSets, logger, analysisConfiguration)")
)
fun KotlinAnalysis(
Expand All @@ -85,11 +87,13 @@ abstract class KotlinAnalysis(
operator fun get(key: DokkaSourceSet): AnalysisContext {
return get(key.sourceSetID)
}

operator fun get(key: DokkaSourceSetID): AnalysisContext {
return find(key)
?: parent?.get(key)
?: throw IllegalStateException("Missing EnvironmentAndFacade for sourceSet ${key}")
?: throw IllegalStateException("Missing EnvironmentAndFacade for sourceSet $key")
}

protected abstract fun find(sourceSetID: DokkaSourceSetID): AnalysisContext?
}

Expand All @@ -105,5 +109,3 @@ internal open class EnvironmentKotlinAnalysis(
environments.values.forEach(AnalysisContext::close)
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
import org.jetbrains.dokka.base.resolvers.shared.PackageList
import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.PACKAGE_LIST_NAME
import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.jetbrains.dokka.base.parsers.moduleAndPackage.ModuleAndPackageDocumen
import org.jetbrains.dokka.base.parsers.moduleAndPackage.parseModuleAndPackageDocumentation
import org.jetbrains.dokka.base.parsers.moduleAndPackage.parseModuleAndPackageDocumentationFragments
import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.base.templating.InsertTemplateExtra
import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.links.DRI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka.base.parsers.moduleAndPackage

import org.jetbrains.dokka.analysis.DokkaResolutionFacade
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka.base.parsers.moduleAndPackage

fun parseModuleAndPackageDocumentation(
Expand All @@ -12,4 +10,3 @@ fun parseModuleAndPackageDocumentation(
documentation = context.parse(fragment)
)
}

1 change: 0 additions & 1 deletion plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.renderers.PostAction
import org.jetbrains.dokka.renderers.Renderer
import org.jetbrains.dokka.transformers.pages.PageTransformer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka.base.transformers.documentables

import org.jetbrains.dokka.DokkaConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.jetbrains.dokka.model.orEmpty
import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentStyle
import org.jetbrains.dokka.pages.SimpleAttr
import org.jetbrains.dokka.pages.TextStyle
import org.jetbrains.dokka.utilities.DokkaLogger
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
Expand Down Expand Up @@ -340,5 +339,3 @@ private fun PageContentBuilder.DocumentableContentBuilder.tableSectionContentBlo
private fun DRI.friendlyClassName() = classNames?.substringAfterLast(".")

private fun <T> Map<String, SourceSetDependent<T>>.availableSourceSets() = values.flatMap { it.keys }.toSet()


Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import com.intellij.psi.PsiMethod
import com.intellij.psi.javadoc.PsiDocComment
import com.intellij.psi.javadoc.PsiDocTag
import org.jetbrains.dokka.utilities.DokkaLogger
import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull

internal data class CommentResolutionContext(
val comment: PsiDocComment,
Expand Down Expand Up @@ -129,4 +126,4 @@ internal class InheritDocResolver(
baseMethod.findSuperMethods().filter { findClosestDocComment(it, logger)?.hasTag(javadocTag) == true }

private fun List<PsiElement>.withoutReferenceLink(): List<PsiElement> = drop(1)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.templates

import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.plugability.DokkaContext
import java.io.File

class FallbackTemplateProcessingStrategy : TemplateProcessingStrategy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.jetbrains.dokka.allModulesPage.templates

import org.jetbrains.dokka.DokkaConfiguration.DokkaModuleDescription
import org.jetbrains.dokka.base.renderers.PackageListService
import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider
import org.jetbrains.dokka.base.resolvers.shared.PackageList
import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.PACKAGE_LIST_NAME
import org.jetbrains.dokka.plugability.DokkaContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.jetbrains.dokka.versioning
import kotlinx.html.a
import kotlinx.html.div
import kotlinx.html.stream.appendHTML
import org.jetbrains.dokka.base.renderers.html.strike
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.configuration
import org.jetbrains.dokka.plugability.plugin
Expand Down Expand Up @@ -83,4 +82,4 @@ class HtmlVersionsNavigationCreator(private val context: DokkaContext) : Version
versions.minByOrNull { (_, versionLocation) ->
versionLocation.let { position.toRelativeString(it).length }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package org.jetbrains.dokka.versioning
import org.apache.maven.artifact.versioning.ComparableVersion
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.configuration
import org.jetbrains.dokka.versioning.VersionId
import org.jetbrains.dokka.versioning.VersioningConfiguration
import org.jetbrains.dokka.versioning.VersioningPlugin

fun interface VersionsOrdering {
fun order(records: List<VersionId>): List<VersionId>
Expand All @@ -20,4 +17,4 @@ class ByConfigurationVersionOrdering(val dokkaContext: DokkaContext) : VersionsO
class SemVerVersionOrdering : VersionsOrdering {
override fun order(records: List<VersionId>): List<VersionId> =
records.map { it to ComparableVersion(it) }.sortedByDescending { it.second }.map { it.first }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.jetbrains.dokka
import kotlinx.cli.ArgParser
import kotlinx.cli.ArgType
import kotlinx.cli.CLIEntity
import org.jetbrains.dokka.utilities.LoggingLevel
import java.io.File
import java.nio.file.Paths

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka.gradle

import org.gradle.api.Project
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka.gradle

import org.gradle.api.artifacts.Configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("FunctionName")

package org.jetbrains.dokka.gradle

import org.gradle.api.NamedDomainObjectFactory
Expand All @@ -10,6 +8,7 @@ internal fun DokkaSourceSetID(task: Task, sourceSetName: String): DokkaSourceSet
return DokkaSourceSetID(task.path, sourceSetName)
}

@Suppress("FunctionName")
internal fun Task.DokkaSourceSetIdFactory() = NamedDomainObjectFactory<DokkaSourceSetID> { name ->
DokkaSourceSetID(this@DokkaSourceSetIdFactory, name)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
@file:Suppress("TestFunctionName")

package org.jetbrains.dokka.gradle

import org.gradle.api.Project
import org.jetbrains.dokka.DokkaSourceSetID

@Suppress("TestFunctionName")
fun GradleDokkaSourceSetBuilder(name: String, project: Project, sourceSetScopeId: String = "${project.path}:test"):
GradleDokkaSourceSetBuilder {
return GradleDokkaSourceSetBuilder(name, project) { DokkaSourceSetID(sourceSetScopeId, it) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("TestFunctionName")

package org.jetbrains.dokka.gradle

import com.android.build.gradle.internal.api.DefaultAndroidSourceSet
Expand All @@ -13,7 +11,6 @@ import kotlin.test.*

class GradleDokkaSourceSetBuilderTest {


private val project = ProjectBuilder.builder().withName("root").build()

@Test
Expand Down Expand Up @@ -488,5 +485,6 @@ class GradleDokkaSourceSetBuilderTest {
}
}

@Suppress("TestFunctionName")
private fun GradleDokkaSourceSetBuilder(name: String, project: Project) =
GradleDokkaSourceSetBuilder(name, project, project.path)

0 comments on commit fcb2f4a

Please sign in to comment.