realm / realm/SwiftLint

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

Open
#5,269 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

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")
        }
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the empty_enum_arguments rule and reproduce the report using the Swift switch sample and swiftlint lint on SwiftLint 0.53.0. Check how HealthKit-style static functions are detected and how --fix removes parentheses. Done means valid function calls are not reported or modified, with the requested allow-list or ignore-list customization addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.