PSComplexity

0.2.0

Cyclomatic and cognitive complexity for PowerShell. Cognitive complexity is a faithful port of the SonarSource metric (nesting-aware -- the better signal for "hard to understand"), validated against reference scores. Measures per unit (function/filter, class method/constructor, initialised class property, + script body) via the PowerShell AST; ships a Test-PSComplexit
Cyclomatic and cognitive complexity for PowerShell. Cognitive complexity is a faithful port of the SonarSource metric (nesting-aware -- the better signal for "hard to understand"), validated against reference scores. 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.2

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

0.2.0: PowerShell class members are measured as units. Methods and constructors report as Class.Member (previously a method appeared under its bare name, so two classes with the same method name -- or a class method and a function of that name -- collided in one row and in any per-unit baseline). An initialised class property is now its own unit instead of folding its decisions into the script body, and recursion through $this.Method() or [Class]::Method() counts as it does for functions. 0.1.0: initial release.

FileList

Version History

Version Downloads Last updated
0.2.0 (current version) 4 8/17/2026
0.1.0 666 7/3/2026