Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does 'Type Body Length' mean in Swiftlint?

We just added Swiftlint to our project and we want to follow all the rules but I'm not sure what's meant by 'type_body_length' warning. I'm not a native english speaker so I find it a bit confusing.

There is a rule for file length aswell so how do they differ? What falls under this definition?

enter image description here

like image 592
andromedainiative Avatar asked Dec 21 '18 09:12

andromedainiative


People also ask

How does SwiftLint work?

SwiftLint is an open-source tool to enforce Swift style and conventions. It is developed by Realm. You can set your coding style rules and force them during development. SwiftLint has a command-line tool, Xcode plugin, AppCode, and Atom integration.

How do I turn off SwiftLint rules?

Disable rules in code Rules can be disabled with a comment inside a source file with the following format: // swiftlint:disable <rule1> [<rule2> <rule3>...] The rules will be disabled until the end of the file or until the linter sees a matching enable comment: // swiftlint:enable <rule1> [<rule2> <rule3>...]


1 Answers

type_body_length violation means that the class has too many lines in it. I dont think it counts extensions, comments or whitespace

Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length.

The rules documentation linked here and above also gives examples of what would and wouldn't be accepted (Triggering & Non Triggering). - Edit suggested by @GoodSp33d, thanks

like image 159
Scriptable Avatar answered Oct 05 '22 02:10

Scriptable