code-gauge 4.7.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -10
- package/THIRD-PARTY-NOTICES.txt +595 -29
- package/dist/cli.cjs +3 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/cliConfig.cjs +1 -1
- package/dist/cliConfig.cjs.map +1 -1
- package/dist/cliConfig.d.ts +13 -3
- package/dist/cliConfig.js +1 -1
- package/dist/cliConfig.js.map +1 -1
- package/dist/crossFileDuplication.cjs +1 -1
- package/dist/crossFileDuplication.cjs.map +1 -1
- package/dist/crossFileDuplication.js +1 -1
- package/dist/crossFileDuplication.js.map +1 -1
- package/dist/crossFileNearMiss.cjs +1 -1
- package/dist/crossFileNearMiss.cjs.map +1 -1
- package/dist/crossFileNearMiss.js +1 -1
- package/dist/crossFileNearMiss.js.map +1 -1
- package/dist/diffCommand.cjs +3 -3
- package/dist/diffCommand.cjs.map +1 -1
- package/dist/diffCommand.js +3 -3
- package/dist/diffCommand.js.map +1 -1
- package/dist/duplicateSelection.cjs +1 -1
- package/dist/duplicateSelection.cjs.map +1 -1
- package/dist/duplicateSelection.js +1 -1
- package/dist/duplicateSelection.js.map +1 -1
- package/dist/duplication.cjs +1 -1
- package/dist/duplication.cjs.map +1 -1
- package/dist/duplication.js +1 -1
- package/dist/duplication.js.map +1 -1
- package/dist/exclusion.cjs +2 -0
- package/dist/exclusion.cjs.map +1 -0
- package/dist/exclusion.d.ts +30 -0
- package/dist/exclusion.js +2 -0
- package/dist/exclusion.js.map +1 -0
- package/dist/git.cjs +1 -1
- package/dist/git.cjs.map +1 -1
- package/dist/git.d.ts +16 -0
- package/dist/git.js +1 -1
- package/dist/git.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/languages.cjs +1 -1
- package/dist/languages.cjs.map +1 -1
- package/dist/languages.js +1 -1
- package/dist/languages.js.map +1 -1
- package/dist/newDuplication.cjs +2 -0
- package/dist/newDuplication.cjs.map +1 -0
- package/dist/newDuplication.d.ts +40 -0
- package/dist/newDuplication.js +2 -0
- package/dist/newDuplication.js.map +1 -0
- package/dist/regressionGate.cjs +1 -1
- package/dist/regressionGate.cjs.map +1 -1
- package/dist/regressionGate.d.ts +8 -6
- package/dist/regressionGate.js +1 -1
- package/dist/regressionGate.js.map +1 -1
- package/dist/scan.cjs +1 -1
- package/dist/scan.cjs.map +1 -1
- package/dist/scan.d.ts +12 -3
- package/dist/scan.js +1 -1
- package/dist/scan.js.map +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/native/Cargo.lock +47 -15
- package/native/Cargo.toml +9 -9
- package/native/code-gauge.wasm +0 -0
- package/native/src/complexity.rs +26 -33
- package/native/src/dep_degree.rs +43 -32
- package/native/src/duplication.rs +158 -40
- package/native/src/functions.rs +20 -62
- package/native/src/languages.rs +28 -7
- package/native/src/measure.rs +16 -27
- package/native/src/ncss.rs +32 -23
- package/native/src/tree_index.rs +9 -0
- package/native/src/util.rs +12 -57
- package/package.json +10 -10
package/native/src/util.rs
CHANGED
|
@@ -53,30 +53,12 @@ pub fn node_text<'a>(node: Node<'_>, code: &Source<'a>) -> &'a str {
|
|
|
53
53
|
&code.code[code.utf8_offset(node.start_byte())..code.utf8_offset(node.end_byte())]
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/// Kotlin spells
|
|
57
|
-
///
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
&& node
|
|
62
|
-
parent.kind_name() == "callable_reference"
|
|
63
|
-
&& parent
|
|
64
|
-
.named_child(0)
|
|
65
|
-
.is_some_and(|first| first.id() == node.id())
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/// Whether the node is a leaf for token-level walks. Kotlin soft keywords used as names (`value`,
|
|
70
|
-
/// `data`, `get`, ...) parse as a `simple_identifier` — or its aliases `interpolated_identifier`
|
|
71
|
-
/// (`"$value"`) and `type_identifier` (`value::size`) — wrapping an anonymous keyword token, so a
|
|
72
|
-
/// plain leaf check would see the keyword instead of the identifier. Every other grammar's
|
|
73
|
-
/// identifier kinds are already leaves.
|
|
74
|
-
pub fn is_identifier_leaf(node: Node<'_>) -> bool {
|
|
75
|
-
node.child_count() == 0
|
|
76
|
-
|| matches!(
|
|
77
|
-
node.kind_name(),
|
|
78
|
-
"simple_identifier" | "interpolated_identifier" | "type_identifier"
|
|
79
|
-
)
|
|
56
|
+
/// Kotlin spells `true`, `false`, and `null` as plain identifiers, which the other grammars give
|
|
57
|
+
/// literal node kinds of their own (an identifier with that text, e.g. Go's `null`, is a variable).
|
|
58
|
+
pub fn is_kotlin_keyword_literal(node: Node<'_>, code: &Source<'_>) -> bool {
|
|
59
|
+
crate::tree_index::language_name() == "kotlin"
|
|
60
|
+
&& node.kind_name() == "identifier"
|
|
61
|
+
&& matches!(node_text(node, code), "true" | "false" | "null")
|
|
80
62
|
}
|
|
81
63
|
|
|
82
64
|
pub fn named_children<'t>(node: Node<'t>) -> Vec<Node<'t>> {
|
|
@@ -91,8 +73,8 @@ pub fn all_children<'t>(node: Node<'t>) -> Vec<Node<'t>> {
|
|
|
91
73
|
|
|
92
74
|
/// Children carrying the field, with node-tree-sitter's vendored-core semantics: extra children
|
|
93
75
|
/// (error-recovery nodes, comments) inherit the field of the preceding structural sibling.
|
|
94
|
-
///
|
|
95
|
-
///
|
|
76
|
+
/// The core instead reports no field for extras (ts_node_field_name_for_child returns early for
|
|
77
|
+
/// them), which would desynchronize field-based extraction on malformed source.
|
|
96
78
|
pub fn find_children_by_field_name<'t>(node: Node<'t>, field_name: &str) -> Vec<Node<'t>> {
|
|
97
79
|
let mut children = Vec::new();
|
|
98
80
|
let mut preceding_structural_field: Option<&'static str> = None;
|
|
@@ -166,38 +148,11 @@ pub fn to_int32(value: i64) -> i32 {
|
|
|
166
148
|
value as i32
|
|
167
149
|
}
|
|
168
150
|
|
|
169
|
-
/// The body following a Kotlin `if_expression`'s bare `else` keyword (the grammar has no else
|
|
170
|
-
/// clause node and no fields), or None for other languages' if nodes and else-less ifs.
|
|
171
|
-
pub fn kotlin_else_body(if_node: Node<'_>) -> Option<Node<'_>> {
|
|
172
|
-
if if_node.kind_name() != "if_expression" {
|
|
173
|
-
return None;
|
|
174
|
-
}
|
|
175
|
-
let children = all_children(if_node);
|
|
176
|
-
let else_index = children
|
|
177
|
-
.iter()
|
|
178
|
-
.position(|child| !child.is_named() && child.kind_name() == "else")?;
|
|
179
|
-
children[else_index + 1..]
|
|
180
|
-
.iter()
|
|
181
|
-
.copied()
|
|
182
|
-
.find(|child| child.kind_name() == "control_structure_body")
|
|
183
|
-
}
|
|
184
|
-
|
|
185
151
|
/// Kotlin's `try { } catch { }` shares its node kind with Rust's `?` operator; only the Kotlin form
|
|
186
|
-
///
|
|
152
|
+
/// starts with the `try` keyword.
|
|
187
153
|
pub fn is_kotlin_try_expression(node: Node<'_>) -> bool {
|
|
188
154
|
node.kind_name() == "try_expression"
|
|
189
|
-
&&
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"statements" | "catch_block" | "finally_block"
|
|
193
|
-
)
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/// Whether a Kotlin else body is a braceless `else if`: the nested if sits directly in the
|
|
198
|
-
/// control_structure_body, whereas a braced `else { if ... }` wraps it in `statements`.
|
|
199
|
-
pub fn is_kotlin_else_if_body(else_body: Node<'_>) -> bool {
|
|
200
|
-
named_children(else_body)
|
|
201
|
-
.iter()
|
|
202
|
-
.any(|child| child.kind_name() == "if_expression")
|
|
155
|
+
&& node
|
|
156
|
+
.child(0)
|
|
157
|
+
.is_some_and(|keyword| !keyword.is_named() && keyword.kind_name() == "try")
|
|
203
158
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-gauge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Measure code metrics with tree-sitter.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@types/node": "25.9.4",
|
|
74
74
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
75
75
|
"@willbooster/oxlint-config": "1.4.8",
|
|
76
|
-
"@willbooster/wb": "22.
|
|
77
|
-
"build-ts": "21.0.
|
|
76
|
+
"@willbooster/wb": "22.8.0",
|
|
77
|
+
"build-ts": "21.0.19",
|
|
78
78
|
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
79
79
|
"lefthook": "2.1.14",
|
|
80
80
|
"oxfmt": "0.68.0",
|
|
@@ -94,12 +94,12 @@
|
|
|
94
94
|
"registry": "https://registry.npmjs.org/"
|
|
95
95
|
},
|
|
96
96
|
"optionalDependencies": {
|
|
97
|
-
"code-gauge-linux-x64-gnu": "
|
|
98
|
-
"code-gauge-linux-arm64-gnu": "
|
|
99
|
-
"code-gauge-linux-x64-musl": "
|
|
100
|
-
"code-gauge-linux-arm64-musl": "
|
|
101
|
-
"code-gauge-darwin-x64": "
|
|
102
|
-
"code-gauge-darwin-arm64": "
|
|
103
|
-
"code-gauge-win32-x64-msvc": "
|
|
97
|
+
"code-gauge-linux-x64-gnu": "5.0.0",
|
|
98
|
+
"code-gauge-linux-arm64-gnu": "5.0.0",
|
|
99
|
+
"code-gauge-linux-x64-musl": "5.0.0",
|
|
100
|
+
"code-gauge-linux-arm64-musl": "5.0.0",
|
|
101
|
+
"code-gauge-darwin-x64": "5.0.0",
|
|
102
|
+
"code-gauge-darwin-arm64": "5.0.0",
|
|
103
|
+
"code-gauge-win32-x64-msvc": "5.0.0"
|
|
104
104
|
}
|
|
105
105
|
}
|