Closed
Description
Rule Request
Summary
Chained function calls should be either on the same line, or one per line.
This is similar to the existing "Multiline Arguments" and "Multiline Parameters" rules.
Q&A
- Why should this rule be added? Share links to existing discussion about what
the community thinks about this.
It's easier to follow control flow through long function chains when each call has the same indentation.
- Provide several examples of what would and wouldn't trigger violations.
- Triggering:
return match(pattern: pattern, with: [.comment]).flatMap { range in
return Command(string: contents, range: range)
}.flatMap { command in
return command.expand()
}
let evenSquaresSum = [20, 17, 35, 4]
.filter { $0 % 2 == 0 }.map { $0 * $0 }
.reduce(0, +)
- Non-triggering
return match(pattern: pattern, with: [.comment])
.flatMap { range in
return Command(string: contents, range: range)
}
.flatMap { command in
return command.expand()
}
let evenSquaresSum = [20, 17, 35, 4].filter { $0 % 2 == 0 }.map { $0 * $0 }.reduce(0, +)
let evenSquaresSum = [20, 17, 35, 4]
.filter { $0 % 2 == 0 }
.map { $0 * $0 }
.reduce(0, +)
- Should the rule be configurable, if so what parameters should be configurable?
No configuration necessary
- Should the rule be opt-in or enabled by default? Why?
See README.md for guidelines on when to mark a
rule as opt-in.
Disabled by default
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
freak4pc commentedon May 23, 2018
@erichoracek I like this and it's also useful to me and many friends in the Realm (😉) of Rx.
Do you want to tackle this or are you OK with me giving it a go?
erichoracek commentedon May 24, 2018
@freak4pc Thanks for the interest! I'm pretty close to having a working implementation—feel free to take a shot at this if you'd like to too though 😄
freak4pc commentedon May 24, 2018
@erichoracek oh not at all! Just wanted
To help out :) feel free to take your time with this
Add multiline function chain rule
Add multiline function chain rule
Add multiline function chain rule
marcelofabri commentedon Jun 11, 2018
Implemented in #2221 🚀
Add multiline function chain rule
Add multiline function chain rule
pre-commit
hooks, CICD Checks, and all warnings fixed [updated] mobilecoinofficial/MobileCoin-Swift#150