Skip to content

v1.6.0

Latest

Choose a tag to compare

@github-actions github-actions released this 09 Oct 16:52
· 1 commit to main since this release
fc21cf6

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 in if,
    else if, guard and while (if let a, b adds 2), and the where
    clause of a for loop. 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 / #else contribute only their most complex clause
    instead of the sum of all clauses. (#59)

Bug fixes

  • --cyclomatic-only and --cognitive-only now gate on the selected metric
    only: the threshold filter, exit code, Xcode diagnostics, SARIF results,
    hotspot ranking and the MCP cyclomatic_only / cognitive_only parameters
    ignore the other metric. Previously the flags only changed the displayed
    column, so --cognitive-only --threshold 9 failed on a function with
    cyclomatic 9 and cognitive 1. (#53, #61)

Documentation

  • docs/user-guide/complexity-metrics.md now matches the implementation:
    switch itself and default do not add to cyclomatic complexity (only
    case labels 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.sh

MCP 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.sh

Artifact Bundle (nest)

nest install fummicc1/swift-complexity

Or 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 IndexStore

Verification

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.sha256

What's Changed

Breaking Changes

  • Count ternary, ??, and comma conditions; stop double-counting nested code by @ysa23 in #59

Bug Fixes

  • Make --cyclomatic-only / --cognitive-only restrict the threshold gate by @fummicc1 in #61

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

  • @ysa23 made their first contribution in #59

Full Changelog: v1.5.0...v1.6.0