Skip to content

unused_import not taking into account @_exported declarations. #2877

Closed

Description

@rz-robsn

New Issue Checklist

Describe the bug

Running the analyzer with the unused_import rule enabled sometimes wrongfully deletes an import if the imported Module contains a @_exported declaration.

Consider the following example :

/// Module A
@_exported import B

/// Module B
public class MyBClass {}

/// Module C
import A

let bClass = MyBClass()

Running the analyzer would currently remove the import A declaration from Module C, leading to a compile error.

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    0.35.0

  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    Downloaded binary from the github release page

  • Paste your configuration file:

whitelist_rules:
  - closure_spacing
  - colon
  - empty_enum_arguments
  - fatal_error_message
  - force_cast
  - force_try
  - force_unwrapping
  - implicitly_unwrapped_optional
  - legacy_cggeometry_functions
  - legacy_constant
  - legacy_constructor
  - legacy_nsgeometry_functions
  - operator_usage_whitespace
  - redundant_string_enum_value
  - redundant_void_return
  - return_arrow_whitespace
  - trailing_newline
  - type_name
  - unused_closure_parameter
  - unused_optional_binding
  - vertical_whitespace
  - void_return
  - custom_rules

analyzer_rules:
  - unused_import

excluded:
  - Carthage
  - Pods

colon:
  apply_to_dictionaries: false

indentation: 2

custom_rules:
  no_objcMembers:
    name: "@objcMembers"
    regex: "@objcMembers"
    message: "Explicitly use @objc on each member you want to expose to Objective-C"
    severity: error
  • Are you using nested configurations?
    No

  • Which Xcode version are you using (check xcode-select -p)?
    10.3

Activity

  1. jpsim commented on Dec 18, 2019

    @jpsim
    Collaborator

    Fixed in #2993.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions