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

The attributes rule incorrectly identifies property wrappers with parentheses #5129

Closed
2 tasks done
trozware opened this issue Jul 17, 2023 · 1 comment
Closed
2 tasks done

Comments

@trozware
Copy link

New Issue Checklist

Describe the bug

The 'attributes' rule states "Attributes should be on their own lines in functions and types, but on the same line as variables and imports"

But it flags property wrapper lines like these even though they are not functions or types:

@AppStorage("editorFontSize") var editorFontSize: Double = 14
@SceneStorage("windowTheme") var windowTheme = "dark"
@Environment(\.dismiss) var dismiss
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint --no-cache --config ~/com.raywenderlich.swiftlint.yml

Linting Swift files in current working directory
Linting 'LintingApp.swift' (2/2)
Linting 'ContentView.swift' (1/2)
/Users/sarah/Desktop/Linting/Linting/ContentView.swift:11:33: warning: Attributes Violation: Attributes should be on their own lines in functions and types, but on the same line as variables and imports (attributes)
/Users/sarah/Desktop/Linting/Linting/ContentView.swift:12:32: warning: Attributes Violation: Attributes should be on their own lines in functions and types, but on the same line as variables and imports (attributes)
/Users/sarah/Desktop/Linting/Linting/ContentView.swift:13:27: 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 3 violations, 0 serious in 2 files.

Environment

  • SwiftLint version: 0.52.4
  • Installation method used: Homebrew
  • Paste your configuration file:

Using the Kodeco / Ray Wenderlich yaml file:
https://raw.githubusercontent.com/kodecocodes/swift-style-guide/main/com.raywenderlich.swiftlint.yml

But the relevant lines are:

opt_in_rules:
  - attributes
  • Are you using nested configurations? No
  • Which Xcode version are you using: Xcode 14.3.1 Build version 14E300c. Also get the same results with Xcode 15.0 Build version 15A5195m (beta 3)
  • Do you have a sample that shows the issue? Yes - see lines above
@SimplyDanny
Copy link
Collaborator

Duplicate of #5103.

The rule has an option attributes_with_arguments_always_on_line_above which is true by default. The violation message has also been improved by #5108 meanwhile but not yet released.

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

No branches or pull requests

2 participants