Rule Request: `typesafe_shorthand_operator`
Nobody has claimed this yet.
- 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
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 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