realm / realm/SwiftLint

function_body_length - Add Configuration To Ignore Switch/Case statements

Open
#5,184 7 comments 0 reactions 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
New rule request

Similar to how cyclomatic_complexity allows for ignoring case statements - https://realm.github.io/SwiftLint/cyclomatic_complexity.html, looking for an option on function_body_length to do the same.

We have an enum with 27 different errors, and a method that converts the error codes into a human readable string, but that involves calling into NSLocalizedString - which is 5 lines for ever call.

It's not horrible to have to do a "swiftlint:disable" just for that function, but I was hoping the justification for cyclomatic_complexity would apply to function_body_length, just so we don't need to disable in cases where there isn't a cleaner way to break apart a large method.

-Thanks!

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 cyclomatic_complexity rule and its documented option for ignoring case statements, then compare that behavior with function_body_length. Confirm the requested configuration can exclude Switch/Case statements from the function-body length calculation and that the option is documented consistently.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.