Repository navigation
Highlights
Behavior changes
Complexity scores change for some code, so a threshold gate that passed with
1.5.0 can fail after upgrading. Raise the threshold or add a
// swift-complexity:disable comment above declarations whose complexity is
accepted.
- Cyclomatic complexity now counts the ternary operator (
a ? b : c),
nil-coalescing (??), each additional comma-separated condition inif,
else if,guardandwhile(if let a, badds 2), and thewhere
clause of aforloop. The syntax tree is operator-folded before analysis;
previously?:and??were never counted. (#59) - Cognitive complexity now counts the ternary operator.
??stays uncounted,
following the SonarSource definition. (#59) - Nested functions, local types and local computed properties are no longer
counted twice: each is reported on its own and no longer adds to the
enclosing function. (#59) #if/#elseif/#elsecontribute only their most complex clause
instead of the sum of all clauses. (#59)
Bug fixes
--cyclomatic-onlyand--cognitive-onlynow gate on the selected metric
only: the threshold filter, exit code, Xcode diagnostics, SARIF results,
hotspot ranking and the MCPcyclomatic_only/cognitive_onlyparameters
ignore the other metric. Previously the flags only changed the displayed
column, so--cognitive-only --threshold 9failed on a function with
cyclomatic 9 and cognitive 1. (#53, #61)
Documentation
docs/user-guide/complexity-metrics.mdnow matches the implementation:
switchitself anddefaultdo not add to cyclomatic complexity (only
caselabels do), and closures count toward the enclosing function. (#59)
Installation
CLI Tool (SwiftComplexityCLI)
Download the appropriate binary for your platform:
- macOS Apple Silicon (M1/M2/M3):
SwiftComplexityCLI-1.6.0-macos-arm64.tar.gz - macOS Intel:
SwiftComplexityCLI-1.6.0-macos-x86_64.tar.gz - Linux x86_64:
SwiftComplexityCLI-1.6.0-linux-x86_64.tar.gz - Linux arm64:
SwiftComplexityCLI-1.6.0-linux-aarch64.tar.gz
tar -xzf SwiftComplexityCLI-1.6.0-*.tar.gz
cd SwiftComplexityCLI-1.6.0-*
./install.shMCP Server (SwiftComplexityMCP)
Download the MCP server for LLM agent integration:
- macOS Apple Silicon (M1/M2/M3):
SwiftComplexityMCP-1.6.0-macos-arm64.tar.gz - macOS Intel:
SwiftComplexityMCP-1.6.0-macos-x86_64.tar.gz - Linux x86_64:
SwiftComplexityMCP-1.6.0-linux-x86_64.tar.gz - Linux arm64:
SwiftComplexityMCP-1.6.0-linux-aarch64.tar.gz
tar -xzf SwiftComplexityMCP-1.6.0-*.tar.gz
cd SwiftComplexityMCP-1.6.0-*
./install.shArtifact Bundle (nest)
nest install fummicc1/swift-complexityOr download the artifact bundle directly:
- SwiftComplexityCLI:
swift-complexity.artifactbundle.zip - SwiftComplexityMCP:
swift-complexity-mcp.artifactbundle.zip
Build from Source
git clone https://github.com/fummicc1/swift-complexity.git
cd swift-complexity
git checkout v1.6.0
# --traits IndexStore enables LCOM4 and coupling (off by default)
swift build -c release --traits IndexStoreVerification
shasum -a 256 -c SwiftComplexityCLI-1.6.0-*.tar.gz.sha256
shasum -a 256 -c SwiftComplexityMCP-1.6.0-*.tar.gz.sha256
shasum -a 256 -c swift-complexity.artifactbundle.zip.sha256
shasum -a 256 -c swift-complexity-mcp.artifactbundle.zip.sha256What's Changed
Breaking Changes
Bug Fixes
Other Changes
- Guard the release workflow against stale versions and reused tags by @fummicc1 in #62
- Smoke-test release binaries, add a dry run, and ship Linux arm64 by @fummicc1 in #64
New Contributors
Full Changelog: v1.5.0...v1.6.0