realm / realm/SwiftLint

Rule Request: delete unused auto-generated code

Open
#2,578 1 comment 1 reaction 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
  1. Why should this rule be added?

Xcode auto-generates function like didReceiveMemoryWarning() that are often unused, and just left in code to rot.

  1. Provide several examples of what would and wouldn't trigger violations.

Triggering:

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

Non-triggering:

    func emptyImplementationForRquiredProtocolFunction() {
    }
  1. Should the rule be configurable, if so what parameters should be configurable?

No params, I think.

  1. Should the rule be opt-in or enabled by default? Why?

Enabled by default, unused code should be deleted.

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 with the issue's triggering and non-triggering Swift examples and compare the requested behavior with SwiftLint's existing rule conventions. Done means the proposed rule consistently handles the listed generated methods without flagging the required empty protocol implementation; no files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.