Product Overview: Lizard – An Extensible Cyclomatic Complexity Analyzer
Introduction
Lizard is a powerful and versatile tool designed for analyzing the complexity of source code across a wide range of programming languages. Developed by Terry Yin, Lizard is an extensible Cyclomatic Complexity Analyzer that helps developers and researchers assess the maintainability and complexity of software code.
Key Features
Supported Languages
Lizard supports a broad spectrum of programming languages, including but not limited to:
- C/C (up to C 14)
- Java
- C# (C Sharp)
- JavaScript (with ES6 and JSX)
- TypeScript
- Objective-C
- Swift
- Python
- Ruby
- TTCN-3
- PHP
- Scala
- GDScript
- Golang
- Lua
- Rust
- Fortran
- Kotlin
- Solidity
- Erlang
- Zig
Code Complexity Analysis
Lizard calculates several key metrics to evaluate code complexity:
- nloc (Lines of Code without Comments): Measures the number of lines of code excluding comments.
- CCN (Cyclomatic Complexity Number): Assesses the complexity of code based on the number of linearly independent paths through the code.
- Token Count of Functions: Counts the tokens within functions to gauge their complexity.
- Parameter Count of Functions: Analyzes the number of parameters in functions to determine their complexity.
Static Code Analysis
In addition to complexity analysis, Lizard performs various forms of static code analysis, including:
- Copy-Paste Detection (Code Clone Detection/Code Duplicate Detection): Identifies duplicated code segments.
- Customizable Thresholds: Allows setting limits for CCN, function length, and other metrics, generating warnings for functions that exceed these thresholds.
Customization and Output
- Language Selection: Users can specify which programming languages to analyze using the
-l
option. - Output Formats: Supports various output formats such as HTML, XML, and CSV.
- Verbose Mode: Provides detailed output with long function names.
- Extensions: Offers additional features like ignoring code in
#else
branches, counting word frequencies, and including global code as one function.
Warning and Reporting
- Warning Generation: Lizard generates warnings for functions that exceed set thresholds for CCN, function length, and other metrics.
- Whitelist Support: Allows specifying a whitelist file to ignore certain functions or code segments from the analysis.
Functionality
Ease of Use
Lizard is designed to be user-friendly and does not require all included folders and files to be accurately specified, making it particularly useful for complex projects where such accuracy is challenging to achieve.
Flexibility
The tool is highly customizable, allowing users to set specific thresholds and select the languages they want to analyze. This flexibility makes Lizard a valuable tool for both developers and researchers.
Integration
Lizard can be integrated into various development workflows, providing valuable insights into code maintainability and complexity, which is crucial for ensuring the long-term health and efficiency of software projects.
In summary, Lizard is a robust and flexible tool for analyzing code complexity and performing static code analysis, making it an essential asset for any software development team or research project.