realm / realm/SwiftLint

Fix all parsing warnings & errors in rule examples

Open
#3,348 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

Many rule examples are very succinct, focusing just on the syntax that is meant to be linted/corrected. For example: if foo == nil. However, this doesn't parse successfully:

$ echo "if foo == nil" > file.swift
$ swiftc -parse file.swift
file.swift:1:14: error: expected '{' after 'if' condition
if foo == nil
             ^

In an upcoming PR, I'll want to introduce a change to avoid correcting files if they have parser errors or warnings, since SwiftLint isn't designed to handle all possibilities of invalid Swift code. Generally, it's still useful for SwiftLint to lint Swift files that don't parse 100% cleanly as a feedback mechanism, but we shouldn't attempt to correct files with violations that don't parse cleanly, because that can mangle or delete code in unintended ways.

Because there are currently over 500 rule examples with parser diagnostics, I don't have time to fix all of them, but we probably should do that eventually.

This is a good starter task if someone's interested in contributing to SwiftLint.

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

Locate the rule examples that produce Swift parser diagnostics and use swiftc -parse, as shown in the issue, to identify the invalid cases. Update the examples so they parse without warnings or errors, then verify that all rule examples are clean before correction behavior is changed.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
4/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.