Skip to content

Erroneous fix for NSIntersectionRect #3703

Description

@J-rg

New Issue Checklist

Describe the bug

When using the legacy_nsgeometry_functions rule, SwiftLint replaces NSIntersectionRect(rect1, rect2) with rect1.intersect(rect2). CGRect does not have an intersect(_:) method, the correct method name would be intersection(_:), however, if two rectangles don’t intersect, the intersection(_:) method produces CGRect.null, while NSIntersectionRect(_:_:) produces CGRect.zero, so replacing it might silently break the code.

Environment

  • SwiftLint version? 0.43.1
  • Installation method used? Homebrew
  • Which Xcode version are you using? Xcode 12.5.1 (12E507)
  • Do you have a sample that shows the issue? echo "NSIntersectionRect(rect1, rect2)" | swiftlint lint --no-cache --use-stdin --enable-all-rules

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected and reproducible misbehavior.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions