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

Ktlint 0.44.0, Kotlin 1.6.10 #1215

Merged
merged 24 commits into from
Apr 13, 2022
Merged

Ktlint 0.44.0, Kotlin 1.6.10 #1215

merged 24 commits into from
Apr 13, 2022

Conversation

petertrr
Copy link
Member

@petertrr petertrr commented Feb 16, 2022

  • Update Kotlin to 1.6.10
    • Use explicit ListSerializer in DiktatSmokeTest
  • Update ktlint to 0.44.0
    • Rename all rule ids to work around breaking change in rule execution order
    • Set isUnitTestContext = false in tests, because otherwise it breaks smoke test

This pull request closes #1105

@petertrr
Copy link
Member Author

petertrr commented Feb 16, 2022

java.lang.ClassCastException: class kotlin.reflect.jvm.internal.KTypeImpl cannot be cast to class kotlin.jvm.internal.TypeReference (kotlin.reflect.jvm.internal.KTypeImpl and kotlin.jvm.internal.TypeReference are in unnamed module of loader 'app')
	at org.cqfn.diktat.ruleset.smoke.DiktatSmokeTest.overrideRulesConfig(DiktatSmokeTest.kt:300)
	at org.cqfn.diktat.ruleset.smoke.DiktatSmokeTest.overrideRulesConfig$default(DiktatSmokeTest.kt:53)
	at org.cqfn.diktat.ruleset.smoke.DiktatSmokeTest.regression - should not fail if package is not set(DiktatSmokeTest.kt:96)

#1152 (comment)

That's actually funny, that diktat-snapshot workflow passes. I.e., the project can build and run at least via maven plugin, but the error is simply in our tests infrastructure.

@petertrr
Copy link
Member Author

Ktlint 0.44 also has (finally) a proper logging framework integration. We should check it in our plugins, where for both maven and gradle a slf4j-compatible logger is already available.

### What's done:
* Experiment: change serialization invocation
### What's done:
* Experiment: change serialization invocation
…patch-1

# Conflicts:
#	diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt
### What's done:
* Experiment: new kotlin, old ktlint
@petertrr petertrr marked this pull request as draft March 1, 2022 15:39
@codecov
Copy link

codecov bot commented Mar 1, 2022

Codecov Report

Merging #1215 (1da5c61) into master (41c161a) will decrease coverage by 1.48%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #1215      +/-   ##
============================================
- Coverage     83.88%   82.40%   -1.49%     
+ Complexity     2551     2550       -1     
============================================
  Files           105      105              
  Lines          7198     7205       +7     
  Branches       1951     2018      +67     
============================================
- Hits           6038     5937     -101     
+ Misses          352      351       -1     
- Partials        808      917     +109     
Flag Coverage Δ
unittests 82.40% <100.00%> (-1.49%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...tlin/org/cqfn/diktat/ruleset/utils/AstNodeUtils.kt 81.62% <ø> (-1.21%) ⬇️
...kotlin/org/cqfn/diktat/ruleset/rules/DiktatRule.kt 66.66% <100.00%> (+3.03%) ⬆️
...g/cqfn/diktat/ruleset/rules/chapter1/FileNaming.kt 75.00% <100.00%> (ø)
.../diktat/ruleset/rules/chapter1/IdentifierNaming.kt 82.23% <100.00%> (-1.02%) ⬇️
...qfn/diktat/ruleset/rules/chapter1/PackageNaming.kt 89.83% <100.00%> (+0.84%) ⬆️
...at/ruleset/rules/chapter2/comments/CommentsRule.kt 88.63% <100.00%> (ø)
...leset/rules/chapter2/comments/HeaderCommentRule.kt 88.00% <100.00%> (-0.80%) ⬇️
.../ruleset/rules/chapter2/kdoc/CommentsFormatting.kt 72.10% <100.00%> (-1.58%) ⬇️
...diktat/ruleset/rules/chapter2/kdoc/KdocComments.kt 87.77% <100.00%> (-0.50%) ⬇️
...ktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt 84.11% <100.00%> (-0.94%) ⬇️
... and 113 more

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 41c161a...1da5c61. Read the comment docs.

### What's done:
* Kltint 0.44.0, exclude logback
@petertrr
Copy link
Member Author

petertrr commented Mar 1, 2022

Build passes with kotlin 1.6.10 and ktlint 0.43.2 and explicit ListSerializer.
In ktlint 0.44.0 they must've changed something important.
Also, they now have rule modifiers: RunAfterRule to establish order without the need to constantly change ruleset provider.

@petertrr
Copy link
Member Author

petertrr commented Mar 2, 2022

There was a breaking change in pinterest/ktlint#1230: now rule execution order is determined not by order from RuleSetProvider (which we heavily relied on), but rather rules are sorted alphabetically by IDs with ability to tweak order with modifiers. I managed to make our smoke tests pass by copying part of our rules order using modifiers, but it probably needs more testing.

petertrr and others added 3 commits March 2, 2022 10:39
### What's done:
* Kltint 0.44.0, rules execution order
### What's done:
* Kltint 0.44.0, rules execution order
@orchestr7
Copy link
Member

There was a breaking change in pinterest/ktlint#1230: now rule execution order is determined not by order from RuleSetProvider (which we heavily relied on), but rather rules are sorted alphabetically by IDs with ability to tweak order with modifiers. I managed to make our smoke tests pass by copying part of our rules order using modifiers, but it probably needs more testing.

very serious change, as we depend on the rule order…

@orchestr7
Copy link
Member

May be we should assign proper IDs (aka 1,2,3) for rules to save the order?

@petertrr
Copy link
Member Author

May be we should assign proper IDs (aka 1,2,3) for rules to save the order?

We should prepend all rule IDs with padded indices 001, 002, ..., 137 to preserve the original order

@petertrr petertrr added this to the 1.1.0 milestone Mar 23, 2022
@petertrr
Copy link
Member Author

petertrr commented Apr 4, 2022

May be we should assign proper IDs (aka 1,2,3) for rules to save the order?

We should prepend all rule IDs with padded indices 001, 002, ..., 137 to preserve the original order

@Arrgentum could you please help with this change? You can commit directly into this branch. Rules should have IDs like 001-comments, 002-single-constructor etc. Basically, we want them to be sortable lexicographically into the same order that we currently have in DiktatRuleSetProvider. This way we won't need things like RunAfterRule

@orchestr7 orchestr7 marked this pull request as ready for review April 12, 2022 15:25
@petertrr petertrr merged commit cbeaa96 into master Apr 13, 2022
@petertrr petertrr deleted the petertrr-patch-1 branch April 13, 2022 09:21
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.

ktlint 0.43.0 logs a warning in diktat-gradle-plugin
2 participants