realm / realm/SwiftLint

Rule Request: [doc_pattern]. required_pattern for a doc comment

Open
#3,670 0 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've been trying to create a custom rule to force a pattern in documenting functions, specifically tests functions.
I want to force a multiline format for the tests as follows

class MyTests: XCTestCase {

    /// ### Given
    /// a
    /// ### When
    /// b
    /// ### Then
    /// c
    func testExample() throws {
    }

I've been trying to achieve this required pattern rule using a custom rule but I could not succeed, I don't even know if it would be possible.
I think a required pattern rule for functions can be beneficial:

  • to enforce doc styling,
  • to ease automatic parsing of doc for other tools to use.

The format of the rule could be inspired by the file_header rule

doc_pattern:
  required_pattern:
  included:
  name:
  match_kinds:
  message:
  severity:

The rule should be opt-in.

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

No implementation file or test is identified in the issue. Start by reviewing SwiftLint’s existing file_header rule and custom-rule capabilities, then define the opt-in configuration using the requested fields and add coverage for the multiline function-documentation pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
documentation, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.