code-gauge 4.2.1 → 4.3.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 +12 -3
- package/dist/cliConfig.cjs +1 -1
- package/dist/cliConfig.cjs.map +1 -1
- package/dist/cliConfig.js +1 -1
- package/dist/crossFileDuplication.cjs +1 -1
- package/dist/crossFileDuplication.cjs.map +1 -1
- package/dist/crossFileDuplication.d.ts +3 -1
- package/dist/crossFileDuplication.js +1 -1
- package/dist/crossFileDuplication.js.map +1 -1
- package/dist/diffCommand.cjs +1 -1
- package/dist/diffCommand.cjs.map +1 -1
- package/dist/diffCommand.js +1 -1
- package/dist/diffCommand.js.map +1 -1
- package/dist/duplicateSelection.cjs +1 -1
- package/dist/duplicateSelection.cjs.map +1 -1
- package/dist/duplicateSelection.d.ts +13 -4
- 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.d.ts +16 -7
- package/dist/duplication.js +1 -1
- package/dist/duplication.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/languages.cjs +1 -1
- package/dist/languages.cjs.map +1 -1
- package/dist/languages.d.ts +3 -1
- package/dist/languages.js +1 -1
- package/dist/languages.js.map +1 -1
- package/dist/metrics.cjs +1 -1
- package/dist/metrics.cjs.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/metrics.js.map +1 -1
- package/dist/nativeMetrics.cjs +1 -1
- package/dist/nativeMetrics.cjs.map +1 -1
- package/dist/nativeMetrics.js +1 -1
- package/dist/nativeMetrics.js.map +1 -1
- package/dist/scan.cjs +1 -1
- package/dist/scan.cjs.map +1 -1
- package/dist/scan.js +1 -1
- package/dist/scan.js.map +1 -1
- package/dist/types.d.ts +15 -2
- package/native/src/complexity.rs +134 -42
- package/native/src/cyclomatic.rs +79 -0
- package/native/src/dep_degree.rs +102 -11
- package/native/src/functions.rs +828 -22
- package/native/src/languages.rs +16 -0
- package/native/src/lib.rs +2 -1
- package/native/src/measure.rs +2 -0
- package/native/src/types.rs +2 -0
- package/package.json +14 -14
package/native/src/languages.rs
CHANGED
|
@@ -7,6 +7,9 @@ pub struct LanguageDefinition {
|
|
|
7
7
|
grammar_id: GrammarId,
|
|
8
8
|
pub function_node_types: &'static [&'static str],
|
|
9
9
|
pub decision_node_types: &'static [&'static str],
|
|
10
|
+
/// Whether cyclomatic complexity follows PMD's Java CycloVisitor (see cyclomatic.rs) instead of
|
|
11
|
+
/// the generic one-path-per-decision rule.
|
|
12
|
+
pub pmd_cyclomatic: bool,
|
|
10
13
|
pub nesting_node_types: &'static [&'static str],
|
|
11
14
|
pub ncss_node_types: &'static [&'static str],
|
|
12
15
|
pub ncss_container_node_types: &'static [&'static str],
|
|
@@ -656,6 +659,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
656
659
|
grammar_id: GrammarId::JavaScript,
|
|
657
660
|
function_node_types: COMMON_FUNCTION_NODES,
|
|
658
661
|
decision_node_types: COMMON_DECISION_NODES,
|
|
662
|
+
pmd_cyclomatic: false,
|
|
659
663
|
nesting_node_types: COMMON_NESTING_NODES,
|
|
660
664
|
ncss_node_types: JS_NCSS_NODES,
|
|
661
665
|
ncss_container_node_types: &[],
|
|
@@ -666,6 +670,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
666
670
|
grammar_id: GrammarId::JavaScript,
|
|
667
671
|
function_node_types: COMMON_FUNCTION_NODES,
|
|
668
672
|
decision_node_types: COMMON_DECISION_NODES,
|
|
673
|
+
pmd_cyclomatic: false,
|
|
669
674
|
nesting_node_types: COMMON_NESTING_NODES,
|
|
670
675
|
ncss_node_types: JS_NCSS_NODES,
|
|
671
676
|
ncss_container_node_types: &[],
|
|
@@ -676,6 +681,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
676
681
|
grammar_id: GrammarId::TypeScript,
|
|
677
682
|
function_node_types: COMMON_FUNCTION_NODES,
|
|
678
683
|
decision_node_types: COMMON_DECISION_NODES,
|
|
684
|
+
pmd_cyclomatic: false,
|
|
679
685
|
nesting_node_types: COMMON_NESTING_NODES,
|
|
680
686
|
ncss_node_types: JS_NCSS_NODES,
|
|
681
687
|
ncss_container_node_types: &[],
|
|
@@ -686,6 +692,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
686
692
|
grammar_id: GrammarId::Tsx,
|
|
687
693
|
function_node_types: COMMON_FUNCTION_NODES,
|
|
688
694
|
decision_node_types: COMMON_DECISION_NODES,
|
|
695
|
+
pmd_cyclomatic: false,
|
|
689
696
|
nesting_node_types: COMMON_NESTING_NODES,
|
|
690
697
|
ncss_node_types: JS_NCSS_NODES,
|
|
691
698
|
ncss_container_node_types: &[],
|
|
@@ -696,6 +703,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
696
703
|
grammar_id: GrammarId::Python,
|
|
697
704
|
function_node_types: COMMON_FUNCTION_NODES,
|
|
698
705
|
decision_node_types: COMMON_DECISION_NODES,
|
|
706
|
+
pmd_cyclomatic: false,
|
|
699
707
|
nesting_node_types: COMMON_NESTING_NODES,
|
|
700
708
|
ncss_node_types: PYTHON_NCSS_NODES,
|
|
701
709
|
ncss_container_node_types: &[],
|
|
@@ -706,6 +714,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
706
714
|
grammar_id: GrammarId::Go,
|
|
707
715
|
function_node_types: COMMON_FUNCTION_NODES,
|
|
708
716
|
decision_node_types: GO_DECISION_NODES,
|
|
717
|
+
pmd_cyclomatic: false,
|
|
709
718
|
nesting_node_types: GO_NESTING_NODES,
|
|
710
719
|
ncss_node_types: GO_NCSS_NODES,
|
|
711
720
|
ncss_container_node_types: &[],
|
|
@@ -716,6 +725,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
716
725
|
grammar_id: GrammarId::Rust,
|
|
717
726
|
function_node_types: COMMON_FUNCTION_NODES,
|
|
718
727
|
decision_node_types: COMMON_DECISION_NODES,
|
|
728
|
+
pmd_cyclomatic: false,
|
|
719
729
|
nesting_node_types: COMMON_NESTING_NODES,
|
|
720
730
|
ncss_node_types: RUST_NCSS_NODES,
|
|
721
731
|
ncss_container_node_types: RUST_NCSS_CONTAINERS,
|
|
@@ -726,6 +736,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
726
736
|
grammar_id: GrammarId::Java,
|
|
727
737
|
function_node_types: JAVA_FUNCTION_NODES,
|
|
728
738
|
decision_node_types: JAVA_DECISION_NODES,
|
|
739
|
+
pmd_cyclomatic: true,
|
|
729
740
|
nesting_node_types: JAVA_DECISION_NODES,
|
|
730
741
|
ncss_node_types: JAVA_NCSS_NODES,
|
|
731
742
|
ncss_container_node_types: &[],
|
|
@@ -736,6 +747,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
736
747
|
grammar_id: GrammarId::Ruby,
|
|
737
748
|
function_node_types: RUBY_FUNCTION_NODES,
|
|
738
749
|
decision_node_types: RUBY_DECISION_NODES,
|
|
750
|
+
pmd_cyclomatic: false,
|
|
739
751
|
nesting_node_types: RUBY_DECISION_NODES,
|
|
740
752
|
ncss_node_types: RUBY_NCSS_NODES,
|
|
741
753
|
ncss_container_node_types: RUBY_NCSS_CONTAINERS,
|
|
@@ -746,6 +758,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
746
758
|
grammar_id: GrammarId::C,
|
|
747
759
|
function_node_types: C_FUNCTION_NODES,
|
|
748
760
|
decision_node_types: C_DECISION_NODES,
|
|
761
|
+
pmd_cyclomatic: false,
|
|
749
762
|
nesting_node_types: C_DECISION_NODES,
|
|
750
763
|
ncss_node_types: C_NCSS_NODES,
|
|
751
764
|
ncss_container_node_types: &[],
|
|
@@ -756,6 +769,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
756
769
|
grammar_id: GrammarId::Cpp,
|
|
757
770
|
function_node_types: C_FUNCTION_NODES,
|
|
758
771
|
decision_node_types: CPP_DECISION_NODES,
|
|
772
|
+
pmd_cyclomatic: false,
|
|
759
773
|
nesting_node_types: CPP_DECISION_NODES,
|
|
760
774
|
ncss_node_types: CPP_NCSS_NODES,
|
|
761
775
|
ncss_container_node_types: &[],
|
|
@@ -766,6 +780,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
766
780
|
grammar_id: GrammarId::CSharp,
|
|
767
781
|
function_node_types: CSHARP_FUNCTION_NODES,
|
|
768
782
|
decision_node_types: CSHARP_DECISION_NODES,
|
|
783
|
+
pmd_cyclomatic: false,
|
|
769
784
|
nesting_node_types: CSHARP_DECISION_NODES,
|
|
770
785
|
ncss_node_types: CSHARP_NCSS_NODES,
|
|
771
786
|
ncss_container_node_types: &[],
|
|
@@ -776,6 +791,7 @@ pub const LANGUAGES: &[LanguageDefinition] = &[
|
|
|
776
791
|
grammar_id: GrammarId::Kotlin,
|
|
777
792
|
function_node_types: KOTLIN_FUNCTION_NODES,
|
|
778
793
|
decision_node_types: KOTLIN_DECISION_NODES,
|
|
794
|
+
pmd_cyclomatic: false,
|
|
779
795
|
nesting_node_types: KOTLIN_DECISION_NODES,
|
|
780
796
|
ncss_node_types: KOTLIN_NCSS_NODES,
|
|
781
797
|
ncss_container_node_types: KOTLIN_NCSS_CONTAINERS,
|
package/native/src/lib.rs
CHANGED
|
@@ -6,6 +6,7 @@ use napi_derive::napi;
|
|
|
6
6
|
use crate::duplication::DuplicationSettings;
|
|
7
7
|
|
|
8
8
|
mod complexity;
|
|
9
|
+
mod cyclomatic;
|
|
9
10
|
mod dep_degree;
|
|
10
11
|
mod duplication;
|
|
11
12
|
mod functions;
|
|
@@ -21,7 +22,7 @@ mod util;
|
|
|
21
22
|
/// together with `expectedPayloadVersion` in src/nativeMetrics.ts.
|
|
22
23
|
#[napi]
|
|
23
24
|
pub fn payload_version() -> u32 {
|
|
24
|
-
|
|
25
|
+
5
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/// Measures code metrics for the given source, returning the NativeMetrics payload as JSON.
|
package/native/src/measure.rs
CHANGED
|
@@ -53,6 +53,8 @@ pub fn measure(
|
|
|
53
53
|
// yields the JavaScript string (UTF-16 code unit) column.
|
|
54
54
|
start_column: node.start_position().column / 2,
|
|
55
55
|
end_line: node.end_position().row + 1,
|
|
56
|
+
end_column: node.end_position().column / 2,
|
|
57
|
+
cyclomatic_complexity: body_metrics.cyclomatic_complexity,
|
|
56
58
|
// Sonar's written spec adds +1 cognitive complexity per function in a recursion
|
|
57
59
|
// cycle, but this is intentionally not implemented (issue #22): mainstream
|
|
58
60
|
// implementations (PMD, SonarQube analyzers) omit it.
|
package/native/src/types.rs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-gauge",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Measure code metrics with tree-sitter.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -65,16 +65,16 @@
|
|
|
65
65
|
"@tsconfig/bun": "1.0.10",
|
|
66
66
|
"@tsconfig/node-lts": "24.0.0",
|
|
67
67
|
"@tsconfig/node-ts": "23.6.4",
|
|
68
|
-
"@types/bun": "1.4.
|
|
68
|
+
"@types/bun": "1.4.2",
|
|
69
69
|
"@types/node": "25.9.4",
|
|
70
70
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
71
71
|
"@willbooster/oxlint-config": "1.4.8",
|
|
72
|
-
"@willbooster/wb": "22.
|
|
73
|
-
"build-ts": "21.0.
|
|
72
|
+
"@willbooster/wb": "22.7.0",
|
|
73
|
+
"build-ts": "21.0.16",
|
|
74
74
|
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
75
|
-
"lefthook": "2.1.
|
|
76
|
-
"oxfmt": "0.
|
|
77
|
-
"oxlint": "1.
|
|
75
|
+
"lefthook": "2.1.14",
|
|
76
|
+
"oxfmt": "0.68.0",
|
|
77
|
+
"oxlint": "1.83.0",
|
|
78
78
|
"oxlint-tsgolint": "7.0.2001",
|
|
79
79
|
"semantic-release": "25.0.5",
|
|
80
80
|
"sort-package-json": "4.0.0",
|
|
@@ -89,12 +89,12 @@
|
|
|
89
89
|
"registry": "https://registry.npmjs.org/"
|
|
90
90
|
},
|
|
91
91
|
"optionalDependencies": {
|
|
92
|
-
"code-gauge-linux-x64-gnu": "4.
|
|
93
|
-
"code-gauge-linux-arm64-gnu": "4.
|
|
94
|
-
"code-gauge-linux-x64-musl": "4.
|
|
95
|
-
"code-gauge-linux-arm64-musl": "4.
|
|
96
|
-
"code-gauge-darwin-x64": "4.
|
|
97
|
-
"code-gauge-darwin-arm64": "4.
|
|
98
|
-
"code-gauge-win32-x64-msvc": "4.
|
|
92
|
+
"code-gauge-linux-x64-gnu": "4.3.0",
|
|
93
|
+
"code-gauge-linux-arm64-gnu": "4.3.0",
|
|
94
|
+
"code-gauge-linux-x64-musl": "4.3.0",
|
|
95
|
+
"code-gauge-linux-arm64-musl": "4.3.0",
|
|
96
|
+
"code-gauge-darwin-x64": "4.3.0",
|
|
97
|
+
"code-gauge-darwin-arm64": "4.3.0",
|
|
98
|
+
"code-gauge-win32-x64-msvc": "4.3.0"
|
|
99
99
|
}
|
|
100
100
|
}
|