realm / realm/SwiftLint

Merge opposite / possibly conflicting rules & support opposite/similar rule functionality

Open
#6,327 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

New Issue Checklist
Feature or Enhancement Proposal

Merge opposite / possibly conflicting rules. It should be possible to enable all rules without unavoidable conflicts. Furthermore, any setting on any rule (except for custom rules) should be able to coexist with any setting on any rule.

e.g., contrasted_opening_brace & opening_brace can't be enabled at the same time (at least under normal settings).

To resolve this, contrasted_opening_brace could be deprecated after the following options have been added to opening_brace:

  • default_placement: same_line (current behavior), next_line (contrasted_opening_brace behavior).
  • multiline_type_header_placement: same_line, next_line
  • multiline_statement_condition_placement: same_line, next_line
  • multiline_function_signature_placement: same_line, next_line

Also, the following rules could probably be merged:

  • explicit_type_interface & redundant_type_annotation
  • explicit_acl & explicit_top_level_acl

Also, any rule should allow at least the enforcement of the opposite of the rule. Any rule whose requirements could be expressed based on an integer should also support any integer (possibly limited to non-negatives, or to positives).

e.g., explicit_enum_raw_value should have an option allow (or accept, …) with values always (default, current behavior) & only_when_necessary (requires that any explicit enum raw value be different than the default raw value for the case).

e.g., vertical_whitespace_between_cases forces one blank line. A non-negative integer line_count option would support the "opposite" of default (0 being no lines) or any number of lines (2 requiring 2 blank lines, etc.). See #6326 for the request for this, but the principle should be applied to all new rules, while existing rules should be retrofitted to support such options.

Also, any rule that depends on a specific string should have an option to configure the string.

e.g. prefixed_toplevel_constant requires a k prefix; that hard-coded value should be replaced by a prefix option that defaults to k to be compatible with the current behavior, but someone could change it to _, constant, etc.

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 inventorying the rule pairs and opposite-setting examples named in the issue, including opening_brace and contrasted_opening_brace. Review how those rules currently expose configuration and identify a bounded first merge or option change. Done should include compatible rule behavior without unavoidable conflicts, preserved defaults, and coverage for the affected settings.

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
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.