Rule request: Comment character width
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
New rule request
I believe there should be a rule to enforce a maximum width on comment blocks. It's fairly common for developers to write long comment blocks above types and functions, and we tend to (whether consciously or not) enforce our own width requirements on these comment blocks. Furthermore, it's often desirable for these blocks to have different width requirements than code. For example, in the SwiftLint CONTRIBUTING.md, it states:
All CHANGELOG.md content is hard-wrapped at 80 characters.
This is different from the Line Length rule, which starts warning at 120 characters.
This rule should be configurable such that the developer can override the default width. My instinct is to suggest a max width of 80 characters to match CONTRIBUTING.md, but glancing at my own block comments, they tend to max out around 100 characters.
Rather than implementing a brand new rule, I could also see this being a configuration option on the existing Line Length rule. At the moment, the Line Length rule merely has an option for ignoring comments. Instead, it should have an option for specifying a different width for comments.
Because the Line Length rule is enabled by default, I believe this rule should also be enabled by default.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing Line Length rule and its documentation at line_length.html, along with the related guidance in CONTRIBUTING.md. Resolve whether comment width should be a separate rule or a Line Length option, then define the configurable default and what enabled-by-default behavior should mean before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100