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

Multiple error #764

Merged
merged 2 commits into from
Feb 10, 2021
Merged

Multiple error #764

merged 2 commits into from
Feb 10, 2021

Conversation

kentr0w
Copy link
Collaborator

@kentr0w kentr0w commented Feb 9, 2021

What's done:

Added atomic counter
closes #751

### What's done:
   Added atomic counter
@kentr0w kentr0w added the bug Something isn't working label Feb 9, 2021
@kentr0w kentr0w requested a review from petertrr February 9, 2021 14:49
@kentr0w kentr0w requested a review from aktsay6 February 9, 2021 14:49
@@ -122,7 +123,9 @@ data class CommonConfiguration(private val configuration: Map<String, String>?)
*/
val kotlinVersion: KotlinVersion by lazy {
configuration?.get("kotlinVersion")?.kotlinVersion() ?: run {
Copy link
Member

Choose a reason for hiding this comment

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

Did you figure out why it was possible? Body of lazy should have been executed only once, even with parallel execution. Counter fixes this behavior, of course, but it's always better to find a root cause. Did you try to reproduce it in maven, for example?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was due to our List<RulesConfig>.getCommonConfiguration() function. To fix, I can make an atomic counter (as already done) or make a lazy extension property.

Copy link
Member

Choose a reason for hiding this comment

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

I suggest to use lazy extension property, I think using a function there was by mistake.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately, a lazy property requires storing state, and there is no way to add state to an existing object from an extension property.

@codecov
Copy link

codecov bot commented Feb 9, 2021

Codecov Report

Merging #764 (b183c77) into master (208c1ed) will decrease coverage by 0.01%.
The diff coverage is 72.72%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #764      +/-   ##
============================================
- Coverage     79.79%   79.78%   -0.02%     
- Complexity     2025     2032       +7     
============================================
  Files            97       97              
  Lines          5089     5090       +1     
  Branches       1626     1627       +1     
============================================
  Hits           4061     4061              
- Misses          246      247       +1     
  Partials        782      782              
Flag Coverage Δ Complexity Δ
unittests 79.78% <72.72%> (-0.02%) 0.00 <18.00> (ø)

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

Impacted Files Coverage Δ Complexity Δ
.../ruleset/rules/chapter3/files/FileStructureRule.kt 80.51% <ø> (ø) 77.00 <0.00> (ø)
...fn/diktat/common/config/rules/RulesConfigReader.kt 40.47% <25.00%> (-0.99%) 4.00 <0.00> (ø)
...tlin/org/cqfn/diktat/ruleset/constants/Chapters.kt 60.86% <100.00%> (ø) 2.00 <0.00> (ø)
...qfn/diktat/ruleset/rules/chapter1/PackageNaming.kt 91.76% <100.00%> (ø) 35.00 <4.00> (ø)
...diktat/ruleset/rules/chapter2/kdoc/KdocComments.kt 78.90% <100.00%> (ø) 70.00 <6.00> (ø)
.../diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt 84.31% <100.00%> (ø) 70.00 <0.00> (ø)
...diktat/ruleset/rules/chapter3/TrailingCommaRule.kt 92.50% <100.00%> (ø) 26.00 <0.00> (ø)
...diktat/ruleset/rules/chapter6/AvoidUtilityClass.kt 68.42% <100.00%> (ø) 15.00 <5.00> (ø)
...uleset/rules/chapter6/classes/InlineClassesRule.kt 72.72% <100.00%> (ø) 23.00 <3.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 208c1ed...b183c77. Read the comment docs.

### What's done:
   Simplified and fixed code according to new logic
@kentr0w kentr0w merged commit 5140a50 into master Feb 10, 2021
@kentr0w kentr0w deleted the bugfix/multiple-error-ktversion branch February 10, 2021 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diktat should not be printing the same error again when the Kotlin version is not specified
2 participants