Open maximbilan opened 3 years ago
For what it's worth, this looks related to a couple issues that were never resolved and closed for staleness: https://github.com/realm/SwiftLint/issues/2677 https://github.com/realm/SwiftLint/issues/2040
are there plans to fix this?
I had a similar issue and after some digging into SwiftLint
I found out that the problem is the new-line
matching.
When a custom rule is applied, SwiftLint
passes the whole content of the file as a single-line to the NSRegularExpression
.
stringView
comes from SourceKitten
and stringView.string
returns the file content as a single line where new-line characters are replaced with \n
.I made my regex work after changing the regex to also work with a single line input.
New Issue Checklist
Describe the bug
I use
custom_rule
to show warnings for all@IBAction
functions which don't callhandleActionButton
function inside these functions and it doesn't work correctly. In that case,SwiftLint
doesn't work correctly.Here is the custom rule:
Input:
Linting:
However,
SwiftLint
highlights the first function instead of the second and third.Expected behavior
https://regex101.com/r/TdkiNC/32
Environment
swiftlint version
to be sure)? 0.42.0xcodebuild -version
)? 12.3 (12C33)