refactor: Harden detekt setup, address some issues (#507)
# Detekt setup hardeing; address some issues - Address some detekt findings: missing KDocs, formatting, use `check*` & `orEmpty()`` - Remove unnecessary KDoc comments from deprecated classes in `types.kt` - Add Detekt baseline XML files for all modules - Enforce stricter Detekt rules by setting `failOnSeverity` from `None` to `Error` ## Motivation and Context Detekt is not actually failing the build on violations. This PR is enabling Detekt to fail on errors. Baseline fines added for historical issues. Follow-up for #501 ## How Has This Been Tested? Regressions ## Breaking Changes No breaking changes. ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Refactoring - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed
This commit is contained in:
parent
4501f14b56
commit
ed9ad83290
4 changed files with 478 additions and 122 deletions
9
conformance-test/detekt-baseline.xml
Normal file
9
conformance-test/detekt-baseline.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<SmellBaseline>
|
||||
<ManuallySuppressedIssues/>
|
||||
<CurrentIssues>
|
||||
<ID>BracesOnWhenStatements:ConformanceServer.kt:HttpServerTransport$when</ID>
|
||||
<ID>BracesOnWhenStatements:ConformanceTest.kt:ConformanceTest$when</ID>
|
||||
<ID>ForbiddenComment:ConformanceTest.kt:ConformanceTest.Companion$// TODO: Fix</ID>
|
||||
</CurrentIssues>
|
||||
</SmellBaseline>
|
||||
|
|
@ -73,6 +73,7 @@ private const val MESSAGE_QUEUE_CAPACITY = 256
|
|||
private fun isInitializeRequest(json: JsonElement): Boolean =
|
||||
json is JsonObject && json["method"]?.jsonPrimitive?.contentOrNull == "initialize"
|
||||
|
||||
@Suppress("CyclomaticComplexMethod", "LongMethod")
|
||||
fun main(args: Array<String>) {
|
||||
val port = args.getOrNull(0)?.toIntOrNull() ?: 3000
|
||||
|
||||
|
|
@ -236,6 +237,7 @@ fun main(args: Array<String>) {
|
|||
}.start(wait = true)
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
private fun createConformanceServer(): Server {
|
||||
val server = Server(
|
||||
Implementation(
|
||||
|
|
@ -371,7 +373,9 @@ private class HttpServerTransport(private val sessionId: String) : AbstractTrans
|
|||
}
|
||||
}
|
||||
|
||||
else -> call.respond(HttpStatusCode.Accepted)
|
||||
else -> {
|
||||
call.respond(HttpStatusCode.Accepted)
|
||||
}
|
||||
}
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import java.net.URI
|
|||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.io.path.createTempFile
|
||||
import kotlin.properties.Delegates
|
||||
import kotlin.test.fail
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
|
|
@ -320,7 +321,8 @@ class ConformanceTest {
|
|||
}
|
||||
process.destroyForcibly()
|
||||
throw AssertionError(
|
||||
"❌ $capitalizedType conformance test [$transportType] '$scenario' timed out after $timeoutSeconds seconds",
|
||||
"❌ $capitalizedType conformance test [$transportType] '$scenario' " +
|
||||
"timed out after $timeoutSeconds seconds",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -331,8 +333,9 @@ class ConformanceTest {
|
|||
logger.error {
|
||||
"$capitalizedType conformance test [$transportType] '$scenario' failed with exit code: $exitCode"
|
||||
}
|
||||
throw AssertionError(
|
||||
"❌ $capitalizedType conformance test [$transportType] '$scenario' failed (exit code: $exitCode). Check test output above for details.",
|
||||
fail(
|
||||
"❌ $capitalizedType conformance test [$transportType] '$scenario' " +
|
||||
"failed (exit code: $exitCode). Check test output above for details.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class WebSocketClientTransport(override val session: WebSocketSession) : WebSock
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
fun main(args: Array<String>) {
|
||||
require(args.isNotEmpty()) {
|
||||
"Server WebSocket URL must be provided as an argument"
|
||||
|
|
|
|||
Loading…
Reference in a new issue