1
› let alert = UIAlertController(title: NSLocalizedString("Problem...", comment: ""),
›                                          message: NSLocalizedString("aaaaaaaaaaaaaaaaaaaaaa
                                          aaaaaaaaaaaaaaaaaaaaaaaa.", comment: ""),
›                                          preferredStyle: .alert)

I am having an issue with swift line showing my second line as being too long and the issue is because I have all this space before message so I could line it up properly for looks. I was wondering is there a way to customize that out of swiftlint because I am below 120 characters but it still gives me the violation for the spacing before but if I remove the spacing before it makes the code look worse and makes it more unreadable.

SRed
  • 185
  • 2
  • 12
  • 3
    I'd rather pull out a `let msg = NSLocalizedString(...)` than fight the linter here. – Gereon Dec 03 '20 at 14:52
  • Does this answer your question? [How to fix 'Line Length Violation: Line should be 120 characters or less' - SwiftLint](https://stackoverflow.com/questions/48965916/how-to-fix-line-length-violation-line-should-be-120-characters-or-less-swif) – Larme Dec 03 '20 at 14:53
  • What if you have `2000 spaces chars + "aString"`, that would "hide the "aString" because it's not visible on screen. That's the meaning behind that rule. But, I wouldn't either use a key for localization that long, or use a var before it, or ignore that rule for that line – Larme Dec 03 '20 at 14:56
  • I don't think the issue is the spaces before and that they are there (visually) because of Xcode doing a soft wrap of the line, try to add hard wraps by placing the cursor and hit return after each comma to really divide the line into multiple lines. – Joakim Danielson Dec 03 '20 at 14:58

0 Answers0