realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.59k stars 2.22k forks source link

Swiftlint --fix adding weak to a non protocol value #3805

Closed ppamorim closed 2 years ago

ppamorim commented 2 years ago

New Issue Checklist

Similar to https://github.com/realm/SwiftLint/issues/3611 but https://github.com/realm/SwiftLint/pull/3599 won't fix.

Describe the bug

For the given variable:

private var fooDelegate: Bool = false

When running:

$ swiftlint --fix

Swiftlint is transforming var to weak var probably because it has delegate on the name, this is causing the compilation to fail.

Environment

disabled_rules:
  - identifier_name
  - line_length
  - todo
  - cyclomatic_complexity
  - type_body_length
  - file_length
  - function_body_length
  - function_parameter_count
  - nesting
  - block_based_kvo

  - 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
  # - empty_count //Disabled due Realm conflict
  # - first_where //Disabled due Realm conflict

excluded:
  - Carthage
  - Pods

force_cast: warning
force_try: warning
jpsim commented 2 years ago

I'm removing the rule here: https://github.com/realm/SwiftLint/pull/3809

It's extremely prone to false positives.