realm / realm/SwiftLint

Rule Request: `typesafe_shorthand_operator`

Open
#4,953 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

The existing shorthand_operator rule causes false positives for operands that don't support the suggested shorthand operator. Examples have been brought up in #3603, #3643 and #4936. The rule doesn't know anything about the operands' types so such mistakes are unavoidable and must be accepted.

A new typesafe version of shorthand_operator could be added, however, that knows depending on the types of the operands if a shorthand operator is supported or not. It can be based on the existing rule with additional type information at hand.

A similar pair of rules is already available with ArrayInitRule and TypesafeArrayInitRule.

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 inspecting the existing shorthand_operator rule and the analogous ArrayInitRule/TypesafeArrayInitRule pair. Review examples from issues #3603, #3643, and #4936 to understand the false positives. Done means adding a typesafe shorthand-operator rule that uses operand type information to accept only supported shorthand operators.

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
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.