realm / realm/SwiftLint

Rule request: Comment character width

Open
#3,268 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

rule-request
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

New Issue Checklist
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.