Conversation
01a6b0a to
21d78ba
Compare
Generated by 🚫 Danger |
3561c44 to
a89ae33
Compare
|
@SimplyDanny please review. I don't check NULL control character: \u0000 because it gets lost when copypasting so it's almost impossible to have it in string literals by accident. |
9382226 to
ceccd1d
Compare
SimplyDanny
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
I wonder if this rule should catch even more characters of this kind, some maybe optionally. We could check what other linters do.
Source/SwiftLintBuiltInRules/Rules/Lint/InvisibleCharactersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/InvisibleCharactersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/InvisibleCharacterRule.swift
Outdated
Show resolved
Hide resolved
3a37574 to
708d32e
Compare
|
There was a problem hiding this comment.
Would it be wrong to have the rule auto-correct the findings by just removing the violating characters?
We could also think about making the rule configurable, so that people can add their own characters with descriptions. That's what the "tool" you cited allows as well.
Source/SwiftLintBuiltInRules/Rules/Lint/InvisibleCharacterRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/InvisibleCharacterRule.swift
Outdated
Show resolved
Hide resolved
708d32e to
09b260e
Compare
09b260e to
eef6f03
Compare
The second commit makes the rule correctable. I've also made some performance optimizations. |
eef6f03 to
60290ce
Compare
Source/SwiftLintBuiltInRules/Rules/Lint/InvisibleCharacterRule.swift
Outdated
Show resolved
Hide resolved
Tests/IntegrationTests/Resources/default_rule_configurations.yml
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/InvisibleCharacterRule.swift
Outdated
Show resolved
Hide resolved
Fine for me to skip the description or have it optional. |
I've added the ability to configure additional characters. I thought about it for a long time and initially decided not to allow disabling the validation of default characters. The hardest part was coming up with names for the parameter and variables 😅. But I'm still having doubts. Please review ) |
c336b5f to
01b29ad
Compare
SimplyDanny
left a comment
There was a problem hiding this comment.
This looks very good now! Thank you for all the updates.
I posted a suggestion for the option's name. Let me know what you think about it.
Source/SwiftLintBuiltInRules/Rules/RuleConfigurations/InvisibleCharacterConfiguration.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/RuleConfigurations/InvisibleCharacterConfiguration.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/InvisibleCharacterRule.swift
Outdated
Show resolved
Hide resolved
|
There is something wrong with the tests on Linux and Windows. I can reproduce that on Linux. The test execution is just stuck. |
1b30907 to
9921111
Compare
I can reproduce that on Windows but I wasn't able to debug the issue. The problem is related only to the 0x200D character. For some reason, it just stucks on Windows/Linux if there is an Example with this character. |
|
So that might even be an issue with the compiler. If we were able to create a small reproducer, we could use that to report a bug. |
…olating characters
344c92b to
e71d360
Compare
I was able to fix the behavior for Windows/Linux. On Windows, when ZWJ forms a grapheme cluster with the previous character (in this case "o" + ZWJ = one grapheme cluster), the
Here is a small piece of code where you can see the difference between Mac OS and Windows/Linux behavior: |
#6045
Summary
invisible_characterslint rule that detects invisible characters in string literals: