feat(kotlin): Implement complete metrics support for Kotlin language#1226
Open
marlon-costa-dc wants to merge 2 commits intomozilla:masterfrom
Open
feat(kotlin): Implement complete metrics support for Kotlin language#1226marlon-costa-dc wants to merge 2 commits intomozilla:masterfrom
marlon-costa-dc wants to merge 2 commits intomozilla:masterfrom
Conversation
3 tasks
619514c to
eef03f9
Compare
eef03f9 to
1a7cbe0
Compare
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
Implements all 11 metric modules for Kotlin, replacing the stub implementations generated by
implement_metric_trait!.Depends on #1225 (tree-sitter 0.26.5 update — provides the
tree-sitter-kotlin-codannagrammar).Metrics implemented
Key implementation details
checker.rs): Maps tree-sitter-kotlin-codanna node types tois_comment,is_func_space,is_func,is_closure,is_string,is_call,is_non_arggetter.rs): Full Halstead classification — 34 operators (including?.,?:,!!,as?,!is,!in,..<) and all operand typeselse ifchain handlingtraverse_childrento navigateproperty_declaration → modifiers → visibility_modifierpathscompute_wmchelper for cross-language reuseFiles changed
src/checker.rs— KotlinCode Checker implementationsrc/getter.rs— KotlinCode Getter with Halstead classificationsrc/metrics/abc.rs— ABC metric with 3 Kotlin helper functionssrc/metrics/cognitive.rs— Cognitive complexitysrc/metrics/cyclomatic.rs— Cyclomatic complexitysrc/metrics/exit.rs— Exit/return detectionsrc/metrics/halstead.rs— Halstead metricsrc/metrics/loc.rs— Lines of codesrc/metrics/nargs.rs— Number of argumentssrc/metrics/npa.rs— Number of public attributessrc/metrics/npm.rs— Number of public methodssrc/metrics/wmc.rs— Weighted method complexitynode.rs+asttools.rsextensions needed by metricsReplaces
Replaces #1215 (closed due to messy branch history). Clean version rebased on
feature/tree-sitter-0.26.5.Test Plan
cargo checkpassescargo test --workspace)