question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

leading chained method does not indent

See original GitHub issue
const create = (
  queue: AWS.SQS,
  queueSettings: AWS.SQS.ReceiveMessageRequest,
): Most.Stream<Job> =>
  Most.periodic(secondsToMilliseconds(queueSettings.WaitTimeSeconds))
    .map(() => pull(queue, queueSettings))
    .await()
    .concatMap(({ Messages }: AWS.SQS.ReceiveMessageResult) =>
      Most.from(Messages.map(parseMessage).map(createJob)),
    )
    .multicast()

Would read better as:

const create = (
  queue: AWS.SQS,
  queueSettings: AWS.SQS.ReceiveMessageRequest,
): Most.Stream<Job> =>
  Most
    .periodic(secondsToMilliseconds(queueSettings.WaitTimeSeconds))
    .map(() => pull(queue, queueSettings))
    .await()
    .concatMap(({ Messages }: AWS.SQS.ReceiveMessageResult) =>
      Most.from(Messages.map(parseMessage).map(createJob)),
    )
    .multicast()

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonkuhrtcommented, Jun 20, 2017

Warning: Bike Sheds Ahead

Because this looks funny:

Promise
  .resolve()
  .then(something)
  .then(somethingElse);

^ IMHO looks great to me. It is a computational pipeline along the lines of functional composition, I don’t see anything silly here personally.

Rx.Observable.fromEvent(someElement, "click")
  .throttle(200)
  .subscribe(doSomething);

^ IMHO worse than silly this is just plain harder to read. Personally I would write this as:

Rx
  .Observable
  .fromEvent(someElement, "click")
  .throttle(200)
  .subscribe(doSomething);

Which once again captures the functional pipeline nature (and some namespace access, fine) and is easy on the eyes because incremental steps follow along a single dimension.

_
  .chain(matrix)
  .flatMap(foo)
  .reduce(add)
  .value();

^ Silly because _ is not a great identifier. Use almost anything else and its fine. F or L or whatever.

0reactions
jasonkuhrtcommented, Jun 22, 2017

@vjeux clear! Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong indentation after chained methods #66816 - GitHub
For this particular issue, if the indentation rules are leading to more trouble than having no auto indent, you can set editor.autoIndent to ......
Read more >
c# - Indent chained method calls so they all start at the same ...
In ReSharper, under Code Editing -> C# -> Formatting Style -> Tabs, Indents, Alignment -> Align multiline constructs, check the Chained ...
Read more >
Auto-indent lines feature wrongly indents multiline chained ...
Auto -indent lines feature wrongly indents multiline chained method calls ; Relates to 1 issue (1 unresolved) · PY-33832 ; Is duplicated by...
Read more >
Indent Chained Methods - Unibeautify
Indent chained method calls. Configuration option for beautifiers JS-Beautify, ESLint and languages EJS, JSX, JavaScript.
Read more >
Standard rules - Ktlint
Indentation formatting - respects .editorconfig indent_size with no continuation indent (see ... Rule id: no-blank-lines-in-chained-method-calls ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found