Conversation
…fig` and remove related suppressions in codebase
There was a problem hiding this comment.
Pull request overview
This PR centralizes Detekt configuration by generating a comprehensive detekt.yml configuration file and updating the project to use Detekt 2 configuration format. The changes include enabling several detekt rules, disabling the ktlint backing-property-naming rule, and removing various @Suppress annotations from the codebase that are now either allowed by the configuration or handled differently.
Changes:
- Moved detekt configuration from root
detekt.ymltoconfig/detekt/detekt.ymlwith a comprehensive Detekt 2 configuration including 853 lines of rule definitions - Disabled ktlint backing-property-naming rule in
.editorconfig - Removed
@Suppressannotations for TooManyFunctions, backing-property-naming, LongParameterList, TooGenericExceptionCaught, and LongMethod throughout the codebase
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| config/detekt/detekt.yml | New comprehensive Detekt 2 configuration with detailed rule definitions for complexity, naming, style, and other code quality checks |
| detekt.yml | Removed old minimal configuration file from repository root |
| build.gradle.kts | Updated config path to point to new location at config/detekt/detekt.yml |
| .editorconfig | Added configuration to disable ktlint backing-property-naming rule |
| kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/ServerSession.kt | Removed @Suppress annotations for TooManyFunctions and backing-property-naming rules |
| kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/Server.kt | Removed @Suppress annotations for TooManyFunctions, backing-property-naming, LongParameterList, and TooGenericExceptionCaught rules |
| kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/StreamableHttpClientTest.kt | Removed @Suppress annotation for LongMethod rule on test class |
| kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/OldStreamableHttpClientTest.kt | Removed @Suppress annotation for LongMethod rule on test class |
| kotlin-sdk-client/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/MockMcp.kt | Removed @Suppress annotations for LongParameterList rule on multiple functions |
| kotlin-sdk-client/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/client/StdioClientTransport.kt | Removed @Suppress annotations for TooGenericExceptionCaught rule while retaining SwallowedException suppressions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -74,7 +74,6 @@ public class ServerOptions(public val capabilities: ServerCapabilities, enforceS | |||
| * this server. The provider is called each time a new session is started to support dynamic instructions. | |||
| * @param block A block to configure the mcp server. | |||
| */ | |||
There was a problem hiding this comment.
The Server class has approximately 41 functions (20+ public, 6+ private, and several suspend functions), which exceeds the TooManyFunctions limit of 20 functions per class configured on line 156. Removing the @Suppress("TooManyFunctions") annotation will cause detekt to report this violation. Consider either increasing the allowedFunctionsPerClass threshold or keeping the suppression annotation.
| */ | |
| */ | |
| @Suppress("TooManyFunctions") |
| @@ -109,7 +108,6 @@ internal class MockMcp(verbose: Boolean = false) { | |||
| } | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
The handleWithResult function has 9 parameters (8 named parameters plus a vararg parameter), which exceeds the LongParameterList limit of 8 configured in detekt.yml line 119. Removing the @Suppress("LongParameterList") annotation will cause detekt to report this violation. Consider either reducing the number of parameters, combining related parameters into a configuration object, or keeping the suppression annotation.
| @Suppress("LongParameterList") |
| @@ -170,7 +167,6 @@ internal class MockMcp(verbose: Boolean = false) { | |||
| ) | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
The handleJSONRPCRequest function has 9 parameters (8 named parameters plus a vararg parameter), which exceeds the LongParameterList limit of 8 configured in detekt.yml line 119. Removing the @Suppress("LongParameterList") annotation will cause detekt to report this violation. Consider either reducing the number of parameters, combining related parameters into a configuration object, or keeping the suppression annotation.
| @Suppress("LongParameterList") |
| @@ -0,0 +1,853 @@ | |||
| config: | |||
| validation: true | |||
| warningsAsErrors: false | |||
There was a problem hiding this comment.
The configuration now sets warningsAsErrors to false, which is a significant change from the original detekt.yml that had warningsAsErrors: true. This means detekt violations will no longer fail the build, potentially allowing code quality issues to accumulate. Consider whether this is intentional and aligns with the project's quality standards. If warnings should still fail the build, set this value back to true.
| value: 'STOPSHIP:' | ||
| - reason: 'Forbidden TODO todo marker in comment, please do the changes.' | ||
| value: 'TODO:' | ||
| allowedPatterns: '' |
There was a problem hiding this comment.
The ForbiddenComment rule is now active and forbids TODO: comments. However, there are existing TODO: comments in the codebase (e.g., in StreamableHttpClientTest.kt line 136 and OldStreamableHttpClientTest.kt line 84). This will cause detekt violations unless these TODO comments are either removed or the allowedPatterns is updated to permit them. Consider either removing the existing TODO comments or adjusting the allowedPatterns to exclude test files or allow specific TODO patterns.
| allowedPatterns: '' | |
| allowedPatterns: 'TODO:' |
kpavlov
left a comment
There was a problem hiding this comment.
Thank you, @devcrocod,
I have only 2 comments, everything else is fine
There was a problem hiding this comment.
Let's keep the default rules and override only where necessary. There's already a flag in the configuration: buildUponDefaultConfig = true. The current config is very hard to reason about
|
|
||
| detekt { | ||
| config = files("$rootDir/detekt.yml") | ||
| config = files("$rootDir/config/detekt/detekt.yml") |
# 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
Motivation and Context
Centralized control of detekt rules. Using detekt 2 configuration
How Has This Been Tested?
locally
Breaking Changes
Types of changes
Checklist