realm / realm/SwiftLint

Rule Request: `Bool` variable naming

Open
#5,034 2 comments 2 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

New Issue Checklist
New rule request

It is a convention to prefix Bool variables with a verb to indicate the type - usually is/are, but there could be others. Examples include UIView.isHidden, UIDeviceOrientation.isPortrait or the standard library's Collection.isEmpty.

Triggering examples:

var flipped = false

var changes = true

let empty: Bool

Non-triggering examples:

var isFlipped = false

var hasChanges = true

let isEmpty: Bool

The rule should have a list of prefixes that are allowed by default and the ability to specify more. From my experience, I'd start with is, are, has, should, can, will, did.

The rule should probably be opt-in.

I'm posting this first in case there are any red flags - I don't want to spend time developing this only to be told later that the rule won't be merged 🙂

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

No files, tests, or entry points are named. Start by reviewing SwiftLint's existing rule implementations and configuration conventions, then determine how an opt-in Bool-naming rule and configurable prefixes should fit them. Done means the proposed behavior, defaults, configuration, and triggering and non-triggering cases are covered and accepted.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.