Skip to content

False positive for unneeded_override #5886

@ppamorim

Description

@ppamorim

New Issue Checklist

Bug Description

If you have the code below present:

class BaseViewController: UIViewController {
  func loadView(_ addViews: () -> Void) {
    super.loadView()
    addViews()
    view.setNeedsUpdateConstraints()
  }
}

class FooViewController: BaseViewController {
  override func loadView() {
    super.loadView {
      self.configViews()
      self.configTargets()
    }
  }
  //...
}

When running the command below, the whole FooViewController.loadView is removed, crashing the app.

$ swiftlint --fix

I caught this while doing code review, usually I use swiftlint --fix before commiting the code:

Screenshot 2024-12-05 at 19 52 03

Environment

  • SwiftLint version: 0.57.1
  • Xcode version: Xcode 15.4
  • Installation method used: Homebrew
  • Configuration file:
disabled_rules:
  - identifier_name
  - line_length
  - todo
  - cyclomatic_complexity
  - type_body_length
  - file_length
  - function_body_length
  - function_parameter_count
  - nesting
  - block_based_kvo
  
  # Remove:
  - unused_closure_parameter
  - explicit_type_interface
  - large_tuple
  - inclusive_language

opt_in_rules: # some rules are only opt-in
  - explicit_type_interface
  - force_unwrapping
  - implicit_return
  - attributes
  - closure_end_indentation
  - closure_spacing
  - conditional_returns_on_newline
  - empty_string
  - contains_over_first_not_nil

excluded:
  - Carthage
  - Pods
  - UnitTests
  - UITests

force_cast: warning
force_try: warning

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions