realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.61k stars 2.22k forks source link

Enable more swiftlint rules (and fix or suppress any violations) in SwiftLint's own .swiftlint.yml #5532

Closed mildm8nnered closed 5 months ago

mildm8nnered commented 5 months ago

Enables the following rules in .swiftlint.yml for SwiftLint itself. These all had less than 10 violations:

final_test_case - Fixed redundant_self_in_closure- Fixed self_binding- Fixed shorthand_argument - Supressed implicitly_unwrapped_optional - Suppressed.

I think implicitly_unwrapped_optional is the only one I had a question mark over in my mind - I made those changes on a separate commit so they're easy to revert.

SwiftLintBot commented 5 months ago
2 Warnings
:warning: Big PR
:warning: If this is a user-facing change, please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
17 Messages
:book: Linting Aerial with this PR took 1.24s vs 1.25s on main (0% faster)
:book: Linting Alamofire with this PR took 1.79s vs 1.8s on main (0% faster)
:book: Linting Brave with this PR took 10.41s vs 10.41s on main (0% slower)
:book: Linting DuckDuckGo with this PR took 5.23s vs 5.25s on main (0% faster)
:book: Linting Firefox with this PR took 13.3s vs 13.33s on main (0% faster)
:book: Linting Kickstarter with this PR took 12.66s vs 12.6s on main (0% slower)
:book: Linting Moya with this PR took 0.71s vs 0.69s on main (2% slower)
:book: Linting NetNewsWire with this PR took 3.83s vs 3.82s on main (0% slower)
:book: Linting Nimble with this PR took 1.02s vs 1.03s on main (0% faster)
:book: Linting PocketCasts with this PR took 10.32s vs 10.24s on main (0% slower)
:book: Linting Quick with this PR took 0.46s vs 0.47s on main (2% faster)
:book: Linting Realm with this PR took 6.35s vs 6.34s on main (0% slower)
:book: Linting Sourcery with this PR took 3.13s vs 3.15s on main (0% faster)
:book: Linting Swift with this PR took 6.34s vs 6.33s on main (0% slower)
:book: Linting VLC with this PR took 1.67s vs 1.68s on main (0% faster)
:book: Linting Wire with this PR took 23.64s vs 23.58s on main (0% slower)
:book: Linting WordPress with this PR took 15.59s vs 15.68s on main (0% faster)

Here's an example of your CHANGELOG entry:

* Enable more swiftlint rules (and fix or suppress any violations) in SwiftLint's own .swiftlint.yml.  
  [mildm8nnered](https://github.com/mildm8nnered)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by :no_entry_sign: Danger

mildm8nnered commented 5 months ago

So CI seems to be failing with these errors, but I can't work out why or reproduce them locally with a similar bazel build :-(

My local toolchain is Xcode 15.2

ERROR: /opt/homebrew/var/buildkite-agent/builds/SwiftLint-CI-5/swiftlint/swiftlint/BUILD:155:13: Linking swiftlint failed: (Exit 1): cc_wrapper.sh failed: error executing CppLink command (from target //:swiftlint) external/apple_support~1.11.1~apple_cc_configure_extension~local_config_apple_cc/cc_wrapper.sh @bazel-out/darwin_arm64-fastbuild/bin/swiftlint-2.params
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
ld: warning: duplicate -rpath '/usr/lib/swift' ignored
ld: Undefined symbols:
  ___tsan_external_write, referenced from:
      SwiftLintBuiltInRules.LegacyFunctionRuleHelper.Visitor.visitPost(SwiftSyntax.FunctionCallExprSyntax) -> () in libSwiftLintBuiltInRules.a[4](LegacyFunctionRuleHelper.swift.o)
      SwiftLintBuiltInRules.LegacyFunctionRuleHelper.Rewriter.visit(SwiftSyntax.FunctionCallExprSyntax) -> SwiftSyntax.ExprSyntax in libSwiftLintBuiltInRules.a[4](LegacyFunctionRuleHelper.swift.o)
      SwiftLintBuiltInRules.AnonymousArgumentInMultilineClosureRule.(Visitor in _909184598A1F28987DA6B2EDE58C898B).visitPost(SwiftSyntax.DeclReferenceExprSyntax) -> () in libSwiftLintBuiltInRules.a[7](AnonymousArgumentInMultilineClosureRule.swift.o)
      SwiftLintBuiltInRules.BlockBasedKVORule.(Visitor in _45F5D997305378178DDA703263CCB08F).visitPost(SwiftSyntax.FunctionDeclSyntax) -> () in libSwiftLintBuiltInRules.a[8](BlockBasedKVORule.swift.o)
      SwiftLintBuiltInRules.ConvenienceTypeRule.(Visitor in _D6E703D835C35DC47DA295F336C85C56).visitPost(SwiftSyntax.StructDeclSyntax) -> () in libSwiftLintBuiltInRules.a[9](ConvenienceTypeRule.swift.o)
      SwiftLintBuiltInRules.ConvenienceTypeRule.(Visitor in _D6E703D835C35DC47DA295F336C85C56).visitPost(SwiftSyntax.ClassDeclSyntax) -> () in libSwiftLintBuiltInRules.a[9](ConvenienceTypeRule.swift.o)
      SwiftLintBuiltInRules.DiscouragedAssertRule.(Visitor in _538780B5FE0535E689A29519BDF1099C).visitPost(SwiftSyntax.FunctionCallExprSyntax) -> () in libSwiftLintBuiltInRules.a[10](DiscouragedAssertRule.swift.o)
mildm8nnered commented 5 months ago

Finally managed to resolve the conflicts and CI issues.