PSComplexity

0.7.0

Cyclomatic and cognitive complexity for PowerShell. Cognitive complexity implements the SonarSource metric in full (nesting-aware -- the better signal for "hard to understand"), scoring every reference example exactly as published, and extends it for PowerShell constructs the specification does not cover: ForEach-Object and Where-Object, the .ForEach() and .Where() me
Cyclomatic and cognitive complexity for PowerShell. Cognitive complexity implements the SonarSource metric in full (nesting-aware -- the better signal for "hard to understand"), scoring every reference example exactly as published, and extends it for PowerShell constructs the specification does not cover: ForEach-Object and Where-Object, the .ForEach() and .Where() methods, the && and || pipeline chains, and ?? and ??=. Measures per unit (function/filter, class method/constructor, initialised class property, + script body) via the PowerShell AST; ships a Test-PSComplexity gate for CI.
Show more

Minimum PowerShell version

7.0

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name PSComplexity

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name PSComplexity

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) Fortigi. MIT licensed.

Package Details

Author(s)

  • Fortigi

Tags

complexity cyclomatic cognitive code-quality ast metrics maintainability lint ci

Functions

Measure-PSComplexity Test-PSComplexity

PSEditions

Core

Dependencies

This module has no dependencies.

Release Notes

PSComplexity 0.7.0

- -Detailed reports each unit's lines of code.
- The gate's policy can live in a committed .pscomplexity.json.
- An acceptance can be written in the code.
- A Markdown summary, for a CI step summary or a pull request comment.
- Gate only the functions a change touched.
- A PSScriptAnalyzer rule, for warnings in the editor.

Full release notes: https://github.com/Fortigi/PSComplexity/releases/tag/v0.7.0

FileList

Version History

Version Downloads Last updated
0.7.0 (current version) 8 10/19/2026
0.6.0 26 10/16/2026
0.5.2 15 10/10/2026
0.5.1 943 8/28/2026
0.5.0 32 8/27/2026
0.4.0 8 8/27/2026
0.3.0 24 8/22/2026
0.2.0 12 8/17/2026
0.1.0 704 7/3/2026
Show more