Web3Swift icon indicating copy to clipboard operation
Web3Swift copied to clipboard

Lines length under 80 chars

Open driver733 opened this issue 7 years ago • 12 comments

Let's keep lines length in all our files under 80 characters. This should be enforced using a swiftlint rule.

driver733 avatar Mar 13 '18 03:03 driver733

@biboran/z please, pay attention to this issue

0crat avatar Mar 13 '18 09:03 0crat

@driver733 why 80?

abdulowork avatar Mar 13 '18 09:03 abdulowork

@driver733 it sounds reasonable for the project but how about unit tests? Some of the tests require a very lengthy input due to the nature of ethereum. I don't think we will gain any improvement in tests understanding if we will simply indent long inputs.

abdulowork avatar Mar 13 '18 14:03 abdulowork

@biboran

why 80?

For the improvement of readability See this.

it sounds reasonable for the project but how about unit tests?

I strongly believe that this rule has to be enforced both in test and project files for the purpose of readability and consistency.

driver733 avatar Mar 13 '18 16:03 driver733

@driver733 your link is broken. Let's use 120 characters for tests and 100 for the main project.

rockfridrich avatar Mar 13 '18 16:03 rockfridrich

@driver733 what do you suggest as a replacement for lengthy inputs in tests?

abdulowork avatar Mar 13 '18 16:03 abdulowork

@rockfridrich Fixed. @biboran Split array values into several lines. 80 lines is an industry standard and I believe that we should stick to it.

driver733 avatar Mar 13 '18 17:03 driver733

@driver733 lets say we have 100 bytes as UInt8 values. Are they supposed to span 100 lines?

abdulowork avatar Mar 13 '18 17:03 abdulowork

@biboran Notice that I did not say that we should dedicate a line for each of the array elements. For instance, if your array spans 100 characters in one line simply split it in two or three lines (so that each line has equal number of characters).

driver733 avatar Mar 13 '18 17:03 driver733

@driver733 ok, makes sense. However, 80 characters doesn't make any sense because the rule afaik was designed for IBM punch cards. Lets come up with a reasonable logic to establish the limit of characters.

abdulowork avatar Mar 13 '18 17:03 abdulowork

@driver733 I guess we can stick with 80 characters length just for the readability reasons. Would you be willing to implement it as a swiftlint rule?

abdulowork avatar May 16 '18 16:05 abdulowork

@biboran https://github.com/realm/SwiftLint/blob/master/Rules.md#line-length

driver733 avatar May 17 '18 19:05 driver733