realm / realm/SwiftLint

`optional_string_data_conversion`'s `Data` -> `String` rule should be optional

Open
#5,785 4 comments 1 reaction 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

In 0.57.0, the non_optional_string_data_conversion rule was split: the Data -> String conversion check was actually inverted and made its own rule. Unfortunately, as a default rule it's very heavy handed. In the vast majority of Swift apps, using String(decoding:as:) is perfectly correct, as non-UTF-8 strings are increasingly rare, and there often aren't any arbitrary strings at all. Additionally, using this initializer is an explicit acknowledgment that we don't care if the string isn't fully UTF-8. That is, we don't care if the decoding placeholder is inserted. That's may be a bug, but a far more minor one than not handling a string at all.

This part of the rule made optional by default.

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 locating the optional_string_data_conversion rule and its default configuration; the issue explains that the Data-to-String check should not be enabled by default. Review the rule's existing tests, if present, and verify that the default configuration no longer reports this conversion while an opt-in configuration still does.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.