-
Notifications
You must be signed in to change notification settings - Fork 187
Detekt configuration #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Detekt configuration #501
Conversation
…fig` and remove related suppressions in codebase
There was a problem hiding this 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.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. | |||
| */ | |||
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
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.
| */ | |
| */ | |
| @Suppress("TooManyFunctions") |
| @@ -109,7 +108,6 @@ internal class MockMcp(verbose: Boolean = false) { | |||
| } | |||
| } | |||
|
|
|||
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
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.
| @Suppress("LongParameterList") |
| @@ -170,7 +167,6 @@ internal class MockMcp(verbose: Boolean = false) { | |||
| ) | |||
| } | |||
|
|
|||
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
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.
| @Suppress("LongParameterList") |
| @@ -0,0 +1,853 @@ | |||
| config: | |||
| validation: true | |||
| warningsAsErrors: false | |||
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
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.
| value: 'STOPSHIP:' | ||
| - reason: 'Forbidden TODO todo marker in comment, please do the changes.' | ||
| value: 'TODO:' | ||
| allowedPatterns: '' |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
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.
| allowedPatterns: '' | |
| allowedPatterns: 'TODO:' |
kpavlov
left a comment
There was a problem hiding this 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
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
Motivation and Context
Centralized control of detekt rules. Using detekt 2 configuration
How Has This Been Tested?
locally
Breaking Changes
Types of changes
Checklist