Skip to content

Add allow_underscore_prefixed_names option to unused_parameter#6509

Merged
SimplyDanny merged 1 commit intorealm:mainfrom
theamodhshetty:codex/unused-parameter-underscored-names
Mar 5, 2026
Merged

Add allow_underscore_prefixed_names option to unused_parameter#6509
SimplyDanny merged 1 commit intorealm:mainfrom
theamodhshetty:codex/unused-parameter-underscored-names

Conversation

@theamodhshetty
Copy link
Contributor

Summary

This adds a new unused_parameter configuration option:

  • allow_underscore_prefixed_names (default: false)

When enabled, unused parameters whose names start with _ are treated as intentionally unused and won't trigger violations.

Changes

  • Added UnusedParameterConfiguration with:
    • severity
    • allow_underscore_prefixed_names
  • Updated UnusedParameterRule to use the new config and skip violations for _-prefixed names when enabled.
  • Added rule examples for default and configured behavior.
  • Added configuration parsing test.
  • Added default config entry in integration fixtures.
  • Added changelog entry under Main > Enhancements.

Testing

  • SWIFTPM_ENABLE_KEYCHAIN=0 swift run swiftlint lint Source/SwiftLintBuiltInRules/Rules/Lint/UnusedParameterRule.swift Source/SwiftLintBuiltInRules/Rules/RuleConfigurations/UnusedParameterConfiguration.swift Tests/FrameworkTests/RuleConfigurationTests.swift
  • SWIFTPM_ENABLE_KEYCHAIN=0 swift test --filter UnusedParameterRuleGeneratedTests
  • SWIFTPM_ENABLE_KEYCHAIN=0 swift test --filter RuleConfigurationTests

Closes #5741

@theamodhshetty
Copy link
Contributor Author

Aligned this with discussion in #5741 by keeping behavior unchanged by default and making underscore-prefixed names opt-in via allow_underscore_prefixed_names.

Happy to adjust naming or scope if maintainers prefer a different config shape.

@SwiftLintBot
Copy link

SwiftLintBot commented Feb 24, 2026

19 Messages
📖 Building this branch resulted in a binary size of 27299.04 KiB vs 27277.54 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.81 s vs 0.83 s on main (2% faster).
📖 Linting Alamofire with this PR took 1.06 s vs 1.08 s on main (1% faster).
📖 Linting Brave with this PR took 7.18 s vs 7.25 s on main (0% faster).
📖 Linting DuckDuckGo with this PR took 26.1 s vs 26.22 s on main (0% faster).
📖 Linting Firefox with this PR took 11.85 s vs 11.95 s on main (0% faster).
📖 Linting Kickstarter with this PR took 8.12 s vs 8.18 s on main (0% faster).
📖 Linting Moya with this PR took 0.48 s vs 0.47 s on main (2% slower).
📖 Linting NetNewsWire with this PR took 2.49 s vs 2.5 s on main (0% faster).
📖 Linting Nimble with this PR took 0.66 s vs 0.71 s on main (7% faster).
📖 Linting PocketCasts with this PR took 7.67 s vs 7.79 s on main (1% faster).
📖 Linting Quick with this PR took 0.46 s vs 0.48 s on main (4% faster).
📖 Linting Realm with this PR took 3.07 s vs 3.04 s on main (0% slower).
📖 Linting Sourcery with this PR took 1.88 s vs 1.87 s on main (0% slower).
📖 Linting Swift with this PR took 4.66 s vs 4.66 s on main (0% slower).
📖 Linting SwiftLintPerformanceTests with this PR took 0.36 s vs 0.34 s on main (5% slower).
📖 Linting VLC with this PR took 1.14 s vs 1.18 s on main (3% faster).
📖 Linting Wire with this PR took 18.66 s vs 18.67 s on main (0% faster).
📖 Linting WordPress with this PR took 12.69 s vs 12.71 s on main (0% faster).

Generated by 🚫 Danger

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!

@SimplyDanny SimplyDanny enabled auto-merge (squash) March 5, 2026 21:01
@SimplyDanny SimplyDanny force-pushed the codex/unused-parameter-underscored-names branch from 105ea39 to ae011ad Compare March 5, 2026 21:19
@SimplyDanny SimplyDanny merged commit 6dc566b into realm:main Mar 5, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unused-parameter: Support configuring parameter names to ignore

3 participants