-
Notifications
You must be signed in to change notification settings - Fork 455
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
Check if ktlint_code_style is set in .editorconfig before overriding it #2143
Merged
nedtwigg
merged 7 commits into
diffplug:main
from
OlivierGenez:fix/editor-config-ktlint-code-style-overridden
Jun 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cf6c76f
Check if ktlint_code_style is set in .editorconfig before overriding it
OlivierGenez 0be12f5
Default EditorConfig path to ".editorconfig" in plugin-maven ktlint step
OlivierGenez ccf141e
Add ktlint test to plugin-maven
OlivierGenez 1453214
Update CHANGES.md files
OlivierGenez 2effcbd
Fix CHANGES.md files links
OlivierGenez f33f8be
Revert unneeded changes to KtlintTest
OlivierGenez 397a7fd
Apply minor Ktlint implementation refactor
OlivierGenez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2016-2023 DiffPlug | ||
* Copyright 2016-2024 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -127,6 +127,25 @@ void testReadCodeStyleFromEditorConfigFile() throws IOException { | |
checkKtlintOfficialStyle(); | ||
} | ||
|
||
@Test | ||
void testEditorConfigOverrideWithUnsetCodeStyleDoesNotOverrideEditorConfigCodeStyleWithDefault() throws IOException { | ||
setFile(".editorconfig").toResource("kotlin/ktlint/ktlint_official/.editorconfig"); | ||
setFile("build.gradle").toLines( | ||
"plugins {", | ||
" id 'org.jetbrains.kotlin.jvm' version '1.6.21'", | ||
" id 'com.diffplug.spotless'", | ||
"}", | ||
"repositories { mavenCentral() }", | ||
"spotless {", | ||
" kotlin {", | ||
" ktlint().editorConfigOverride([", | ||
" ktlint_test_key: true,", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, can you add a test case like 87537c0 for maven as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! While adding the test I realised that |
||
" ])", | ||
" }", | ||
"}"); | ||
checkKtlintOfficialStyle(); | ||
} | ||
|
||
@Test | ||
void testSetEditorConfigCanOverrideEditorConfigFile() throws IOException { | ||
setFile(".editorconfig").toResource("kotlin/ktlint/intellij_idea/.editorconfig"); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 key point is here, I missed checking EditorConfig file properties in #1808.