Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty_enum_arguments false positive, --fix command breaks code preventing successful compile #5269

Open
2 tasks done
edorphy opened this issue Oct 9, 2023 · 1 comment
Open
2 tasks done
Labels
bug Unexpected and reproducible misbehavior.

Comments

@edorphy
Copy link

edorphy commented Oct 9, 2023

New Issue Checklist

Describe the bug

The empty_enum_arguments has false positives when using HealthKit types. HealthKit still has a number of types using static functions instead of static vars. The --fix command will remove the required parenthesis and make the code not compile.

Screenshot 2023-10-09 at 7 46 11 AM

https://developer.apple.com/documentation/healthkit/hkunit

Since there are system APIs in the health space and probably other built-in sdks outside of the developers control, this rule should allow a customization to provide an allow list or ignore list.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint

Environment

0.53.0
pkg install

  • SwiftLint version (run swiftlint version to be sure)?
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
  • Paste your configuration file:
# insert yaml contents here

empty_enum_arguments is on by default

  • Are you using nested configurations?
    No
  • Which Xcode version are you using (check xcodebuild -version)?
    Version 15.0 (15A240d)
  • Do you have a sample that shows the issue?
    See screenshot above or sample code below
    static func swiftLintFalsePositive(for unit: HKUnit) {
        switch unit {
        case .foot(), .inch():
            print("foot or inch")
            
        case .meter(), .meterUnit(with: .kilo):
            print("metric units")
            
        default:
            print("Something else")
        }
    }
@SimplyDanny SimplyDanny added the bug Unexpected and reproducible misbehavior. label Oct 15, 2023
@SimplyDanny
Copy link
Collaborator

The Swift compiler now complains about empty parentheses on enum cases if the they don't have associated values. Therefore, empty_enum_arguments should just ignore them and only remove argument lists containing only placeholders. Doing so also fixes this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants