Add new invisible_characters rule#6424
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.
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.
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
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.
|
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. |
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: |
SimplyDanny
left a comment
There was a problem hiding this comment.
Impressive results!
7ad1d25 to
6de732a
Compare
6de732a to
4d3fc1e
Compare
|
@SimplyDanny is this ready for merge or anything else you would like to improve? |
a586bf8 to
142a9a6
Compare
5458d78 to
501e2c6
Compare
|
@SimplyDanny yet another rebase / resolve conflicts / make register is done. Looking forward to merge this PR. |
501e2c6 to
1f372ff
Compare
|
Sorry for the late reaction, @kapitoshka438. I have been quite busy with other tasks. I tried to address your recommendation with #6570. Could that resolve the issue and harmonize behavior? |
1f372ff to
c4008ec
Compare
Hey @SimplyDanny . I've applied your changed locally and can prove that it works and allow to remove the Windows/Linux workaround in InvisibleCharacterRule.swift. |
That's good news for the rule implementation part! Obviously, there are more cleanups necessary in @kapitoshka438: Would you like to rebase and update your implementation? |
c4008ec to
f9aee5c
Compare
@SimplyDanny done |
|
Thanks for all the effort @kapitoshka438! I'll check how |
#6045
Summary
invisible_characterslint rule that detects invisible characters in string literals: