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

False positive for attributes rule when using @MainActor #4599

Closed
2 tasks done
marcomasser opened this issue Nov 28, 2022 · 0 comments · Fixed by #4616
Closed
2 tasks done

False positive for attributes rule when using @MainActor #4599

marcomasser opened this issue Nov 28, 2022 · 0 comments · Fixed by #4616
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@marcomasser
Copy link

New Issue Checklist

Describe the bug

It seems using @MainActor triggers a false positive depending on where @MainActor is exactly. See example below.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Linting Swift files in current working directory
Linting 'test.swift' (1/1)
/Users/marco/Desktop/test/test.swift:5:7: warning: Attributes Violation: Attributes should be on their own lines in functions and types, but on the same line as variables and imports. (attributes)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version 0.50.1
  • Installation method used: Homebrew
  • Paste your configuration file:
opt_in_rules: 
  - attributes
  • Are you using nested configurations?

    No

  • Which Xcode version are you using (check xcodebuild -version)?

    Xcode 14.1
    Build version 14B47b

// This triggers a violation:
import AppKit

@NSApplicationMain
@MainActor
final class AppDelegate: NSAppDelegate {}

The order of the attributes is important:

// This does NOT trigger a violation:
import AppKit

@MainActor
@NSApplicationMain
final class AppDelegate: NSAppDelegate {}

I also tried using @main instead of @NSApplicationMain with the same result.

Interestingly, using e.g. @main and @NSApplicationMain but without @MainActor does not trigger a warning, regardless of the order. So it seems like the problem is @MainActor.

@SimplyDanny SimplyDanny added the bug Unexpected and reproducible misbehavior. label Dec 3, 2022
@SimplyDanny SimplyDanny self-assigned this Dec 3, 2022
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