You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unneeded_synthesized_initializer reports a false positive when the init has side effects. In the attached sample, the init prints something, and removing it would remove the print. In the example where I encountered it in a real app, a SwiftUI view modifier's init contained a call to UIScrollView.appearance().bounces = false, which we definitely don't want to lose by deleting the init!
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Linting Swift files in current working directory
Linting 'InitTest.swift' (1/1)
/Users/igeek/Downloads/InitTest/InitTest.swift:2:5: warning: Unneeded Synthesized Initializer Violation: This default initializer would be synthesized automatically - you do not need to define it (unneeded_synthesized_initializer)
Done linting! Found 1 violation, 0 serious in 1 file.
Environment
SwiftLint version: 0.52.3
Installation method used: homebrew
Paste your configuration file: n/a (default configuration)
Which Xcode version are you using? Xcode 14.3.1 (14E300c) on macOS 13.4.1 (22F82)
Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
to quickly test if your example is really demonstrating the issue. If your example is more
complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
structMyStruct{init(){print("perform side effect")}}
The text was updated successfully, but these errors were encountered:
New Issue Checklist
Describe the bug
unneeded_synthesized_initializer
reports a false positive when the init has side effects. In the attached sample, theinit
prints something, and removing it would remove the print. In the example where I encountered it in a real app, a SwiftUI view modifier'sinit
contained a call toUIScrollView.appearance().bounces = false
, which we definitely don't want to lose by deleting theinit
!Complete output when running SwiftLint, including the stack trace and command used
Environment
echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
to quickly test if your example is really demonstrating the issue. If your example is more
complex, you can use
swiftlint lint --path [file here] --no-cache --enable-all-rules
.The text was updated successfully, but these errors were encountered: