Merge opposite / possibly conflicting rules & support opposite/similar rule functionality
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
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
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_bracebehavior).multiline_type_header_placement:same_line,next_linemultiline_statement_condition_placement:same_line,next_linemultiline_function_signature_placement:same_line,next_line
Also, the following rules could probably be merged:
explicit_type_interface&redundant_type_annotationexplicit_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
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 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