Skip to content

Multi-line disabling unused_declaration doesn't apply to the first line #6415

@rgoldberg

Description

@rgoldberg

New Issue Checklist

Bug Description

Multi-line disabling unused_declaration doesn't apply to the first line

struct Xyz { // The next line triggers a violation:
	var x: String? // swiftlint:disable unused_declaration
	var y: String?
	var z: String? // swiftlint:enable unused_declaration
}

// No reported violations:
struct Abc { // swiftlint:disable unused_declaration
	var a: String?
	var b: String?
	var c: String? // swiftlint:enable unused_declaration
}
## zsh
$ swiftlint analyze --compiler-log-path =(xcodebuild -scheme mas -destination "platform=macOS,arch=$(arch),variant=macos" 2>&1)

Environment

SwiftLint version (run swiftlint version to be sure)

0.63.0

Xcode version (run xcodebuild -version to be sure)

Xcode 26.2
Build version 17C52

Installation method used (Homebrew, CocoaPods, building from source, etc)

Homebrew Core

Configuration file:

---
excluded:
- .build/
- .idea/
- .swiftpm/
- .vscode/
opt_in_rules:
- all
analyzer_rules:
- all
disabled_rules:
- closure_body_length
- contrasted_opening_brace
- cyclomatic_complexity
- explicit_acl
- explicit_enum_raw_value
- explicit_self
- explicit_top_level_acl
- explicit_type_interface
- file_header
- function_body_length
- large_tuple
- multiple_closures_with_trailing_closure
- no_extension_access_modifier
- no_grouping_extension
- no_magic_numbers
- prefixed_toplevel_constant
- strict_fileprivate
- type_body_length
attributes:
  always_on_line_above: ['@Flag', '@MainActor', '@OptionGroup']
deployment_target:
  macOS_deployment_target: 13
  macOSApplicationExtension_deployment_target: 13
  iOS_deployment_target: 99
  iOSApplicationExtension_deployment_target: 99
  tvOS_deployment_target: 99
  tvOSApplicationExtension_deployment_target: 99
  watchOS_deployment_target: 99
  watchOSApplicationExtension_deployment_target: 99
explicit_init:
  include_bare_init: true
file_length:
  ignore_comment_only_lines: true
  warning: 500
file_name:
  excluded: [Group.swift, Process.swift, User.swift]
file_types_order:
  order:
  - main_type
  - supporting_type
  - extension
  - preview_provider
  - library_content_provider
function_parameter_count:
  warning: 6
indentation_width:
  indentation_width: 2
  include_multiline_strings: false
line_length:
  ignores_multiline_strings: true
  ignores_regex_literals: true
modifier_order:
  preferred_modifier_order:
  - acl
  - setterACL
  - override
  - isolation
  - dynamic
  - mutators
  - lazy
  - final
  - required
  - convenience
  - typeMethods
  - owned
multiline_arguments:
  first_argument_location: next_line
non_optional_string_data_conversion:
  include_variables: true
number_separator:
  minimum_length: 6
opening_brace:
  ignore_multiline_statement_conditions: true
operator_usage_whitespace:
  skip_aligned_constants: false
prefer_key_path:
  restrict_to_standard_functions: false
private_over_fileprivate:
  validate_extensions: true
redundant_self:
  only_in_closures: false
redundant_type_annotation:
  consider_default_literal_types_redundant: true
trailing_comma:
  mandatory_comma: true
trailing_whitespace:
  ignores_comments: false
type_contents_order:
  order:
  - case
  - associated_type
  - type_alias
  - subtype
  - type_property
  - instance_property
  - ib_inspectable
  - ib_outlet
  - initializer
  - deinitializer
  - type_method
  - view_life_cycle_method
  - ib_action
  - other_method
  - subscript
unneeded_override:
  affect_initializers: true
unused_import:
  require_explicit_imports: true
  allowed_transitive_imports:
  - module: Darwin
    allowed_transitive_imports:
    - _DarwinFoundation1
    - _DarwinFoundation2
    - _DarwinFoundation3
  - module: Swift
    allowed_transitive_imports:
    - _Concurrency
    - _StringProcessing
vertical_whitespace_between_cases:
  separation: never

Are you using nested configurations?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    helpQuestions or user problems that require more explanation rather than code changes.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions