get_complexity_metrics
Calculate cyclomatic and cognitive complexity metrics for code members, filtering by threshold and project to identify overly complex code.
Instructions
Calculate complexity for members (methods, constructors, properties, indexers, operators). Reports both 'complexity' (cyclomatic - the number of paths, starts at 1) and 'cognitive' (how hard the code is to follow, starts at 0 - a 0 is not a bug), plus 'maxNesting'. The 'metric' parameter selects which of the two the threshold filters on and the sort uses. Returns an envelope with items sorted worst-first, totalCount, truncated, limit (default 100), and a summary with max/avg/overThreshold plus maxCognitive.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of items to return (default: 100). Items are sorted by the selected metric desc (worst first). | |
| metric | No | Which metric drives the threshold and the sort: 'cyclomatic' (default) or 'cognitive'. Both are always reported. | cyclomatic |
| project | No | Optional project name filter | |
| threshold | No | Minimum complexity threshold, applied to the selected metric (default: 10) |