Skip to main content

Viper - a code complexity metrics reporter

Input

all kinds of source code files

Output

For each file, list of functiton information. For a function, analyze to get following data: - scope (namespace, class or function as ancester nodes of this function)

  • fqdn (fully qualified domain name: scope + name)
  • name (the identifier)
  • signature (normalized function signature, keep unchanged when compiled function name is not changed)
  • line (line number of identifier)
  • start (start line number of function definition)
  • end (end line number of function definition)
  • ccm (mccabe-style cyclomatic complexity metric, Traditional: each case statement counts +1)
  • modified_ccm (mccabe-style cyclomatic complexity metric, Modified: switch statement counts +1)
  • statements (number of statements in the function body)

Supported Languages

  • C (.c, .h)
  • C++ (.cpp, .cxx, .cc, .hpp, .hxx, .hh)
  • Python (.py, .pyw)
  • SystemVerilog (.sv, .svh)

Output Formats

Viper supports multiple output formats out of the box. Use the --format option:

  • default: Human-readable list of functions (default)
  • pmccabe: pmccabe-compatible tab-separated format (Modified CCM, Traditional CCM, Statements, First line, # Lines, filename(line): function_name)

Implementation Idea

  • use python 3.14.2
  • utilize tree_sitter module and tree_sitter_xxx language packs to parse source code to get AST, then analyze AST to get function information
  • support inputs of multiple files, enumeration of files in directories.

project and module management

  • use tool uv as package/project management tool
  • use uv run <script> to run scripts
  • put code under src file

Metadata

Release files for viper-ccm 0.1.4

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

Source distribution (sdist)

Source distribution for viper-ccm 0.1.4
File Size Uploaded
viper_ccm-0.1.4.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for viper-ccm 0.1.4
File Interpreter ABI Platform
viper_ccm-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 26.5 kB

Release files / viper_ccm-0.1.4.tar.gz

Download URL viper_ccm-0.1.4.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6bc102af4bd40de3f3ac391226d52e94bfc3e9900836c8de9e6561325d910b4f
BLAKE2b-256 checksum
How to use checksums
3b95187903f6619f940c4667c1feeaff141d2a410fe4d0f8d58395e0d825e0c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / viper_ccm-0.1.4-py3-none-any.whl

Download URL viper_ccm-0.1.4-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78fc498936ad50bafd69b944eae29210365e418ec084d8a62cc8f54362b9b282
BLAKE2b-256 checksum
How to use checksums
2af32f780b54c2df0ca42f74a1f7ace442b399cb86cce83fc27cf46264f3aea9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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