Repository navigation
feat: Kotlin support - #18
Merged
Merged
Conversation
Mixed Java and Kotlin projects share one metrics model, so scores, reports, baselines, cache and churn work unchanged; only parsing forks by extension. Top-level functions are keyed by their JVM facade class, so keys match what the JVM and coverage tools report.
JaCoCo names Kotlin facade classes and companions like the analysis keys already do, but mangles internal functions as name$module; match those by their source name. Tested against a report recorded from a compiled fixture.
…d reporter loading Replace the offset comparison of the Kotlin ignore check with a structural one, drop visits of children that name nothing to count, and test the negated type and range checks, the XML entity resolver and the context class loader of reporter constructors.
Editors on Windows write one, and the Java and Kotlin parsers reject it. The cache key still hashes the raw bytes.
… mangling Truncating every name at the first dollar sign let synthetic methods such as run$lambda$0 take the coverage of run. Only a single non-synthetic suffix, the module name of an internal function, now falls back to the source name.
The shaded jar kept one arbitrary LICENSE and NOTICE and nothing for the libraries that ship none. It now merges the NOTICE files, lists every bundled library with its license in META-INF/THIRD-PARTY-LICENSES.txt and keeps the extra license files of Jackson.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The analyser now measures Kotlin (
.kt) as well as Java, including projects that mix both.Only parsing forks by file extension.
The metrics model, scoring, reports, baselines, cache, churn and coverage are shared.
kotlin-compiler-embeddable2.4.21 PSI, without type resolution. The environment is created lazily, once per process, and only when a Kotlin file is found. Compiler messages are suppressed.KotlinMetricsCollectorand visitors for the 8 cognitive metrics, cyclomatic, Halstead and understandability. Their rules mirror the Java visitors.pkg.Outer.Companion). Top-level and extension functions are keyed under the JVM facade class (pkg.FileNameKt, which respects@file:JvmName). Secondary constructors are named after their class. Overloads are keyedname(Type,...), with an extension receiver as the first type.initblocks, accessors, enum entry bodies, anonymous objects and local classes are skipped. Lambdas and local functions belong to their function.@cca-ignoreworks in KDoc and in comments.whencounts likeswitch, and anifexpression likeif. Elvis is +1 cyclomatic only.?.and!!add no cognitive counts. Labeled returns count. Implicititcounts when it is used. Implicitthisproperty reads follow the Java heuristic. The full table is in the README and indocs/Cognitive-Complexity-Analysis.md.FileFinderfinds.javaand.ktfiles..ktsis excluded and documented.Parser failed for file <path>: (line L,col C) <message>and the run continues.CACHE_FORMAT_VERSIONstays the same.audit$module) now match by their source name.Size and startup
--helpanalyse src/main/javaThe shaded jar works without any relocation or transformer.
Test plan
./mvnw -B verify: 847 tests, JaCoCo line 97.7% and branch 94.9%, PIT 99% (1459/1469). The Kotlin classes are covered by the existingdomain.*target.@file:JvmName..ktsskipped, Kotlin parse error, exclusion of.ktfiles, and a Kotlin cache round trip.java -jar target/cognitive-analysis.jaron mixed sources.