realm / realm/SwiftLint

explicit_type_interface collides with redundant_type_annotation for Bool

Open
#3,578 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

New Issue Checklist
Describe the bug

This bug exist in version 0.43 and is introduced by #3438

The above change re-introduced the bug #2312 for Bool as allow_redundancy is no longer honored.
The error doesn't repro in version older than 0.43

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint

Redundant Type Annotation Violation: Variables should not have redundant type annotation (redundant_type_annotation)

Environment

SwiftLint installed via brew

whitelist_rules:
  - redundant_type_annotation

  - explicit_type_interface

explicit_type_interface: # requires type annotation on everything but local variables and constants
  excluded:
    - local
  allow_redundancy: true # Ignores rule if it would result in redundancy
swiftlint_version: 0.43.1

To test execute

if which swiftlint >/dev/null; then
    swiftlint --config --strict .swiftlint.yml
else
    echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

Xcode version 12.4

Swift code that triggers the warning

    private var isFirstLaunch: Bool = true

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 reproducing the report with the shown .swiftlint.yml configuration, the swiftlint lint command, and the isFirstLaunch Swift snippet. Compare the explicit_type_interface and redundant_type_annotation behavior for Bool; done means allow_redundancy is honored and the redundant type annotation violation is no longer reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
devtools, tooling
Issue type
Bug
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.