Skip to main content

get_complexity_metrics

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.

Parameters

ParameterTypeRequiredDescription
projectstringOptional project name filter
thresholdintMinimum complexity threshold, applied to the selected metric (default: 10)
metricstringWhich metric drives the threshold and the sort: 'cyclomatic' (default) or 'cognitive'. Both are always reported.
limitint?Maximum number of items to return (default: 100). Items are sorted by the selected metric desc (worst first).