Crate lynx_eye

Crate lynx_eye 

Source
Expand description

§Lynx Eye Library

A Rust library for code analysis similar to Lizard. It analyzes function-level code metrics including NLOC, CCN, token count, and parameter count.

§Supported Languages

  • JavaScript (.js, .jsx, .mjs, .cjs)
  • TypeScript (.ts, .tsx, .mts, .cts)
  • Rust (.rs)

§Quick Start

use lynx_eye::{CodeAnalyzer, FunctionInfo};

let mut analyzer = CodeAnalyzer::new();

// Analyze JavaScript
let js_code = "function test(a, b) { return a + b; }";
let functions = analyzer.analyze(js_code, "example.js").unwrap();

// Analyze Rust
let rs_code = "fn add(a: i32, b: i32) -> i32 { a + b }";
let functions = analyzer.analyze(rs_code, "example.rs").unwrap();

for func in functions {
    println!("Function: {:?}, NLOC: {}, CCN: {}",
             func.name, func.nloc, func.ccn);
}

§Features

  • Multi-language Support: JavaScript, TypeScript, and Rust
  • Comprehensive Metrics: NLOC, CCN, token count, parameter count, complexity score
  • Tree-sitter Based: Robust parsing using concrete syntax trees
  • Extensible: Easy to add new language support via the LanguageConfig trait

Re-exports§

pub use analysis::CodeAnalyzer;
pub use analysis::FunctionInfo;
pub use analysis::calculate_complexity_score;
pub use analysis::is_branch_node;
pub use analysis::is_empty_function;
pub use analysis::is_function_node;
pub use languages::Language;
pub use trace::TraceData;
pub use trace::FunctionTraceInfo;

Modules§

analysis
languages
Language configuration module
parser
trace
Dynamic Analysis Module