Skip to main content

Web Site Lizard

https://badge.fury.io/py/lizard.svg

Lizard is an extensible Cyclomatic Complexity Analyzer for many programming languages including C/C++ (doesn’t require all the header files or Java imports). It also does copy-paste detection (code clone detection/code duplicate detection) and many other forms of static code analysis.

A list of supported languages:

  • C# (C Sharp)

  • C/C++ (works with C++14)

  • Erlang

  • Fortran

  • GDScript

  • Golang

  • Java

  • JavaScript (With ES6 and JSX)

  • Kotlin

  • Lua

  • Objective-C

  • Perl

  • PHP

  • PL/SQL

  • Python

  • R

  • Ruby

  • Rust

  • Scala

  • Solidity

  • Structured Text (St)

  • Swift

  • TTCN-3

  • TypeScript (With TSX)

  • VueJS

  • Zig

By default lizard will search for any source code that it knows and mix all the results together. This might not be what you want. You can use the “-l” option to select language(s).

It counts

  • the nloc (lines of code without comments),

  • CCN (cyclomatic complexity number),

  • token count of functions.

  • parameter count of functions.

You can set limits for CCN (-C) and the number of parameters (-a). Functions that exceed these limits will generate warnings. The exit code of lizard will be non-zero if there are warnings.

This tool actually calculates how complex the code ‘looks’ rather than how complex the code really ‘is’. People will need this tool because it’s often very hard to get all the included folders and files right when they are complicated. But we don’t really need that kind of accuracy for cyclomatic complexity.

It requires python3.8 or above (early versions are not verified).

JavaScript and TypeScript defaults

Each default parameter or destructuring initializer adds 1 to CCN, because the initializer runs only when the supplied value is undefined. For example, function f(a = 1, b = a + 1) { return a + b; } has CCN 3: the base complexity of 1 plus two defaults. Defaults in object and array destructuring also count, including nested defaults and destructuring inside a function body. Explicit decisions within an initializer, such as a ternary expression or && / ||, contribute separately.

This also applies to JSX and TSX. Existing CCN scores can increase for functions that use defaults, which may cause them to exceed a configured CCN threshold.

Installation

lizard.py can be used as a standalone Python script, most functionalities are there. You can always use it without any installation. To acquire all the functionalities of lizard, you will need a proper install.

python lizard.py

If you want a proper install:

[sudo] pip install lizard

Or if you’ve got the source:

[sudo] python setup.py install --prefix=/path/to/installation/directory/

Usage

lizard [options] [PATH or FILE] [PATH] ...

Run for the code under current folder (recursively):

lizard

Exclude anything in the tests folder:

lizard mySource/ -x"./tests/*"

Use .gitignore file:

lizard mySource/

If there is a .gitignore file in the given path, lizard will automatically use it as an additional filter to exclude files that match the gitignore patterns. This is useful when you want to analyze only the tracked files in your git repository. To analyze all discovered source files regardless of .gitignore, use –no-gitignore:

lizard --no-gitignore mySource/

Command-line reference

See the command-line reference for all options, sample reports, and threshold examples.

Using lizard as Python module

You can also use lizard as a Python module in your code:

>>> import lizard
>>> i = lizard.analyze_file("../cpputest/tests/AllTests.cpp")
>>> print(i.__dict__)
{'nloc': 9, 'function_list': [<lizard.FunctionInfo object at 0x10bf7af10>], 'filename': '../cpputest/tests/AllTests.cpp'}
>>> print(i.function_list[0].__dict__)
{'cyclomatic_complexity': 1, 'token_count': 22, 'name': 'main', 'parameter_count': 2, 'nloc': 3, 'long_name': 'main( int ac , const char ** av )', 'start_line': 30}

You can also use source code string instead of file. But you need to provide a file name (to identify the language).

>>> i = lizard.analyze_file.analyze_source_code("AllTests.cpp", "int foo(){}")

Extensions and warning controls

See extensions and warning controls for duplicate detection, word counts, Cognitive Complexity, generated code, whitelists, and forgiveness comments.

Limitations

Lizard requires syntactically correct code. Upon processing input with incorrect or unknown syntax:

  • Lizard guarantees to terminate eventually (i.e., no forever loops, hangs) without hard failures (e.g., exit, crash, exceptions).

  • There is a chance of a combination of the following soft failures:

    • omission

    • misinterpretation

    • improper analysis / tally

    • success (the code under consideration is not relevant, e.g., global macros in C)

This approach makes the Lizard implementation simpler and more focused with partial parsers for various languages. Developers of Lizard attempt to minimize the possibility of soft failures. Hard failures are bugs in Lizard code, while soft failures are trade-offs or potential bugs.

In addition to asserting the correct code, Lizard may choose not to deal with some advanced or complicated language features:

  • C/C++ digraphs and trigraphs are not recognized.

  • C/C++ preprocessing or macro expansion is not performed. For example, using macro instead of parentheses (or partial statements in macros) can confuse Lizard’s bracket stacks.

  • Some C++ complicated templates may cause confusion with matching angle brackets and processing less-than < or more-than > operators inside of template arguments.

Literature Referring to Lizard

Lizard is often used in software-related research. If you used it to support your work, you may contact the lizard author to add your work in the following list.

Lizard is also used as a plugin for fastlane to help check code complexity and submit xml report to sonar.

How To Contribute

Contributions are welcome. Project-specific development rules are in AGENTS.md. Adding a language reader uses .agents/skills/lizard-language-support/.

AI lifecycle guidance is installed under .agents/skills/ and .claude/skills/.

Metadata

Release files for lizard 1.24.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lizard 1.24.2
File Size Uploaded Provenance
lizard-1.24.2.tar.gz 120.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lizard 1.24.2
File Interpreter ABI Platform
lizard-1.24.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 255.6 kB

Release files / lizard-1.24.2.tar.gz

Download URL lizard-1.24.2.tar.gz
Size 120.1 kB
Tags Source
SHA-256 checksum
How to use checksums
84ac9c687bf38e9dd7a7fc179ab4113858bd0fa125cef328812f88be5cd13d30
BLAKE2b-256 checksum
How to use checksums
f885323734da1a70492b432a04bd2665a012eade1378c2ea913c960cfe138b1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / lizard-1.24.2-py2.py3-none-any.whl

Download URL lizard-1.24.2-py2.py3-none-any.whl
Size 135.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
dc89ae0a6048e89efbb77e1bf21c0d34c23cbc80116a8fe969baaeb6255c90d0
BLAKE2b-256 checksum
How to use checksums
17322dc39eb80cd4c43ea12a3115b1847579bc3b852881725e2bbb669427888d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for lizard 1.24.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lizard-1.24.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.24.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page