Skip to content
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

Upgrade ktlint to 0.40.0 #3281

Merged
merged 3 commits into from
Dec 28, 2020
Merged

Upgrade ktlint to 0.40.0 #3281

merged 3 commits into from
Dec 28, 2020

Conversation

chao2zhang
Copy link
Member

Motivation

Indentation and ParameterListWrapping have had a regression since ktlint 0.37.0. ParameterListWrapping was fixed in 0.39.0 and Indentation was fixed in 0.40.0. Therefore, bumping the versions will benefit the users who have either of these rules active.

Issue

pinterest/ktlint#874 and pinterest/ktlint#935 changed the implementation of ImportOrdering and FinalNewLine to use the new EDITOR_CONFIG_PROPERTIES_USER_DATA_KEY.

Some of the data structures are qualified with internal, but since those rules are set back to alpha state, I put comments next to the hack so that we can reevaluate detekt code when those ktlint rules become stable.

In addition, I refactored overrideEditorConfig() and overrideEditorConfigProperties() to simplify the code

Testing

Most of the testing is done by running detekt task in detekt repo itself.

  • If there are detekt issues reported for Indentation or ImportOrdering which are not active in default-detekt-config.yml, the code is working.
  • If there is any exception printed with stack trace, the code is breaking.

ImportOrdering and FinalNewLine also have sufficient test coverage, so no new tests are added.

@codecov
Copy link

codecov bot commented Dec 12, 2020

Codecov Report

Merging #3281 (d3b07ee) into master (3fa8f37) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3281      +/-   ##
============================================
+ Coverage     80.32%   80.34%   +0.02%     
- Complexity     2721     2724       +3     
============================================
  Files           445      445              
  Lines          8168     8177       +9     
  Branches       1553     1555       +2     
============================================
+ Hits           6561     6570       +9     
  Misses          774      774              
  Partials        833      833              
Impacted Files Coverage Δ Complexity Δ
.../arturbosch/detekt/formatting/EditorConfigMerge.kt 80.00% <100.00%> (-3.34%) 0.00 <0.00> (ø)
...lab/arturbosch/detekt/formatting/FormattingRule.kt 97.14% <100.00%> (+0.71%) 14.00 <2.00> (+3.00)
...urbosch/detekt/formatting/wrappers/FinalNewline.kt 100.00% <100.00%> (ø) 4.00 <1.00> (ø)
...bosch/detekt/formatting/wrappers/ImportOrdering.kt 100.00% <100.00%> (ø) 7.00 <1.00> (ø)
...turbosch/detekt/formatting/wrappers/Indentation.kt 100.00% <100.00%> (ø) 4.00 <1.00> (ø)
...ch/detekt/formatting/wrappers/MaximumLineLength.kt 87.50% <100.00%> (-1.39%) 5.00 <1.00> (ø)
...etekt/formatting/wrappers/ParameterListWrapping.kt 100.00% <100.00%> (ø) 4.00 <1.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3fa8f37...d3b07ee. Read the comment docs.

Copy link
Member

@arturbosch arturbosch left a comment

Choose a reason for hiding this comment

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

Cool, I like the simplification a lot!

@arturbosch
Copy link
Member

I'm not sure how bad the regressions in pinterest/ktlint#997 and pinterest/ktlint#995 really are.
I'm tagging this for 1.16.0 so 1.15.0 can be finally closed soon.
We can have a faster 1.16.0-RC1 with this one if there is demand :)

@arturbosch arturbosch added this to the 1.16.0 milestone Dec 14, 2020
@chao2zhang
Copy link
Member Author

I can test against my company's repo and give back the result. I am in no rush for this so 1.16 looks good to me.

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Great cleanup :)

@chao2zhang
Copy link
Member Author

chao2zhang commented Dec 16, 2020

I'm not sure how bad the regressions in pinterest/ktlint#997 and pinterest/ktlint#995 really are.
I'm tagging this for 1.16.0 so 1.15.0 can be finally closed soon.
We can have a faster 1.16.0-RC1 with this one if there is demand :)

I did some testing on my company's repo:

  • Kotlin LoC: 43k
  • Detekt 1.9.1 / Ktlint 0.36.0: 0 violations, which is the current versions in the repo
  • Detekt 1.15.0-RC2 / Ktlint 0.39: 944 violations
  • This PR / Ktlint 0.40: 942 violations

Most of the issues remained the same: The majority are Indentation, there are a few SpacingBetweenDeclarationsWithAnnotations and SpacingBetweenDeclarationsWithComments
The conclusion is that bumping Ktlint from 0.39 to 0.40 does not cause a significant regression.

@BraisGabin
Copy link
Member

@chao2zhang can you fix the conflicts in this branch? This is ready to merge.

Chao Zhang and others added 2 commits December 28, 2020 13:03
…formatting/wrappers/ImportOrdering.kt

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
@schalkms schalkms merged commit d3a3734 into detekt:master Dec 28, 2020
@chao2zhang chao2zhang deleted the ktlint branch December 28, 2020 22:05
chao2zhang pushed a commit to chao2zhang/detekt that referenced this pull request Dec 30, 2020
* Upgrade ktlint to 0.40.0

* Update detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ImportOrdering.kt

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>

* Fix merge conflict

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
arturbosch pushed a commit that referenced this pull request Jan 16, 2021
* Upgrade ktlint to 0.40.0

* Update detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ImportOrdering.kt

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>

* Fix merge conflict

Co-authored-by: M Schalk <30376729+schalkms@users.noreply.github.com>
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.

None yet

5 participants