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

Convert the model module to Kotlin #1465

Merged
merged 27 commits into from
Dec 11, 2024
Merged

Conversation

JPercival
Copy link
Contributor

No description provided.

Copy link

Formatting check succeeded!

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 31.66667% with 697 lines in your changes missing coverage. Please review.

Project coverage is 66.00%. Comparing base (f30c08a) to head (b9464ad).
Report is 4 commits behind head on feature-kotlin.

Files with missing lines Patch % Lines
...model/src/main/java/org/hl7/cql/model/ClassType.kt 22.22% 88 Missing and 3 partials ⚠️
...java/org/cqframework/cql/cql2elm/Cql2ElmVisitor.kt 31.96% 80 Missing and 3 partials ⚠️
...java/org/cqframework/cql/cql2elm/LibraryBuilder.kt 49.10% 50 Missing and 7 partials ⚠️
...a/org/hl7/cql/model/GenericClassSignatureParser.kt 65.41% 29 Missing and 17 partials ⚠️
...model/src/main/java/org/hl7/cql/model/TupleType.kt 0.00% 46 Missing ⚠️
...rc/main/java/org/hl7/cql/model/NamespaceManager.kt 0.00% 37 Missing ⚠️
.../cqframework/cql/cql2elm/SystemFunctionResolver.kt 27.50% 25 Missing and 4 partials ⚠️
...org/cqframework/cql/cql2elm/model/ModelImporter.kt 45.09% 26 Missing and 2 partials ⚠️
...el/src/main/java/org/hl7/cql/model/IntervalType.kt 0.00% 25 Missing ⚠️
.../model/src/main/java/org/hl7/cql/model/ListType.kt 0.00% 25 Missing ⚠️
... and 31 more
Additional details and impacted files
@@                 Coverage Diff                  @@
##             feature-kotlin    #1465      +/-   ##
====================================================
+ Coverage             65.35%   66.00%   +0.65%     
+ Complexity             4315     4304      -11     
====================================================
  Files                   486      487       +1     
  Lines                 29234    28918     -316     
  Branches               5507     5430      -77     
====================================================
- Hits                  19105    19087      -18     
+ Misses                 7904     7623     -281     
+ Partials               2225     2208      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -33,7 +33,7 @@ open class Model(val modelInfo: ModelInfo, modelManager: ModelManager?) {

for (t in index.values) {
if (t is ClassType && t.label != null) {
classIndex[casify(t.label)] = t
classIndex[casify(t.label!!)] = t
Copy link
Contributor

@lukedegruchy lukedegruchy Dec 11, 2024

Choose a reason for hiding this comment

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

Are we sure we want to throw an NPE here or anywhere else in this PR we use !! ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally, no. I've been fixing the cases of these where it's reasonably straight forward to do so. In this case, the label property is mutable, meaning that it could change values between the null check (t.label != null) and the usage (t.label!!) if, for instance, the Model was shared between different threads. I looked at changing label to be immutable, but it requires a re-work of how the ClassTypes are initialized. I just decided it was a bigger change than I wanted do. I've mostly kept the APIs and usages of the classes the same, only grabbing low-hanging fruit.


override fun isInstantiable(callType: DataType, context: InstantiationContext): Boolean {
return if (callType is ClassType && callType.elements.size == elements.size) {
sortedElements.zip(callType.sortedElements).all { (thisElement, thatElement) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

We really need zip in Java

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
73.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

throw RuntimeException(
java.lang.String.join(
" ",
"Multiple ModelInfoReaderProviders found on the classpath.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does Kotlin have multi-line Strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I’ve not tried them though. I’ll give the a shot.

@JPercival JPercival merged commit 31160ea into feature-kotlin Dec 11, 2024
6 of 7 checks passed
@JPercival JPercival deleted the feature-kotlin-model branch December 11, 2024 17:40
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.

2 participants