Skip to content

Conversation

@devcrocod
Copy link
Contributor

  • generate detekt config
  • enable several rules
  • disable ktlint backing property check

Motivation and Context

Centralized control of detekt rules. Using detekt 2 configuration

How Has This Been Tested?

locally

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml to config/detekt/detekt.yml with a comprehensive Detekt 2 configuration including 853 lines of rule definitions
  • Disabled ktlint backing-property-naming rule in .editorconfig
  • Removed @Suppress annotations 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.
*/
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
*/
*/
@Suppress("TooManyFunctions")

Copilot uses AI. Check for mistakes.
@@ -109,7 +108,6 @@ internal class MockMcp(verbose: Boolean = false) {
}
}

Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
@Suppress("LongParameterList")

Copilot uses AI. Check for mistakes.
@@ -170,7 +167,6 @@ internal class MockMcp(verbose: Boolean = false) {
)
}

Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
@Suppress("LongParameterList")

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,853 @@
config:
validation: true
warningsAsErrors: false
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
value: 'STOPSHIP:'
- reason: 'Forbidden TODO todo marker in comment, please do the changes.'
value: 'TODO:'
allowedPatterns: ''
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
allowedPatterns: ''
allowedPatterns: 'TODO:'

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@kpavlov kpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @devcrocod,
I have only 2 comments, everything else is fine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update this line too, for consistency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants