Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
# (lint is OS-agnostic and already runs on Linux via test:coverage)
- run: npm run compile
if: runner.os != 'Linux'
- run: npm run test:unit
if: runner.os != 'Linux'
- run: npm run test:vscode
if: runner.os != 'Linux'
- name: Upload coverage to Codecov
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A Visual Studio Code extension that calculates and displays **Cognitive Complexi
- **Real-time Analysis**: Analyzes code metrics as you write code
- **CodeLens Integration**: Shows complexity scores directly above functions
- **Color-coded Indicators**: Visual feedback with green/yellow/red status based on configurable thresholds
- **Multi-language Support**: Currently supports C#, Go, Java, JavaScript, JSX, Python, TypeScript, and TSX
- **Multi-language Support**: Currently supports C#, Go, Java, JavaScript, JSX, Python, Rust, TypeScript, and TSX
- **Configurable Thresholds**: Customize warning and error complexity thresholds
- **Smart Exclusions**: Automatically excludes test files, build artifacts, and other specified patterns

Expand All @@ -23,6 +23,7 @@ A Visual Studio Code extension that calculates and displays **Cognitive Complexi
| JavaScript | ✅ Supported | Full support including functions, methods, arrow functions, closures |
| JSX | ✅ Supported | Full support for JavaScript with JSX syntax (React components) |
| Python | ✅ Supported | Full support including functions, methods, lambdas, comprehensions, match statements |
| Rust | ✅ Supported | Full support including fn items, impl methods, if/for/while/loop/match expressions |
| TypeScript | ✅ Supported | Full support including functions, methods, arrow functions, closures |
| TSX | ✅ Supported | Full support for TypeScript with JSX syntax (React components) |

Expand Down
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"golang",
"metrics",
"python",
"java"
"java",
"rust"
],
"categories": [
"Other"
Expand All @@ -44,7 +45,8 @@
"onLanguage:python",
"onLanguage:typescript",
"onLanguage:typescriptreact",
"onLanguage:java"
"onLanguage:java",
"onLanguage:rust"
],
"main": "./out/extension.js",
"contributes": {
Expand Down Expand Up @@ -131,6 +133,7 @@
"tree-sitter-java": "0.23.5",
"tree-sitter-javascript": "0.21.4",
"tree-sitter-python": "0.21.0",
"tree-sitter-rust": "0.21.0",
"tree-sitter-typescript": "0.21.2"
}
}
80 changes: 80 additions & 0 deletions samples/Test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Sample Rust file for testing Code Metrics extension
// This file demonstrates various Rust constructs that affect cognitive complexity.

fn simple_function(x: i32) -> i32 {
x + 1
}

fn function_with_if(x: i32) -> i32 {
if x > 0 {
x
} else {
0
}
}

fn function_with_loop(n: i32) -> i32 {
let mut sum = 0;
for i in 0..n {
sum += i;
}
sum
}

fn function_with_match(x: i32) -> &'static str {
match x {
0 => "zero",
1..=9 => "single digit",
_ => "large",
}
}

fn complex_function(x: i32, y: i32) -> i32 {
if x > 0 && y > 0 {
for i in 0..x {
if i % 2 == 0 || i == y {
return i;
}
}
} else if x < 0 {
let mut n = x;
while n < 0 {
n += 1;
}
return n;
}
0
}

struct Calculator {
value: i32,
}

impl Calculator {
fn new(value: i32) -> Self {
Calculator { value }
}

fn apply(&self, op: &str, operand: i32) -> i32 {
match op {
"add" => self.value + operand,
"sub" => self.value - operand,
"mul" => self.value * operand,
_ => self.value,
}
}

fn compute_series(&self, n: i32) -> i32 {
let mut result = self.value;
for i in 1..=n {
if i % 3 == 0 && i % 5 == 0 {
result += 15;
} else if i % 3 == 0 {
result += 3;
} else if i % 5 == 0 {
result += 5;
}
}
result
}
}
Loading
Loading