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.

Rule proposal: `no-duplicate-loops`

See original GitHub issue

I’ve seen this a couple of times

Error

for (const gamma of bars.map(alpha => alpha.beta.gamma)) {
  gamma('ray')
}
 
for (const act of actions.filter(act => typeof act === 'function')) {
  act('a fool')
}

Pass

for (const alpha of bars) {
  alpha.beta.gamma('ray')
}


for (const act of actions) {
  if (typeof act === 'function') {
    act('a fool')
  }
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:23 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
sindresorhuscommented, Sep 30, 2020

@fisker Because you end up iterating through bars twice.

1reaction
sindresorhuscommented, Dec 10, 2020

How about forcing the looped expression to be one of:

That sounds sensible, but wouldn’t that be a completely different rule? This rule is about preventing duplicate iterations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proposed rule: Order Competition Rule - SEC.gov
proposed rule would prohibit a restricted competition trading center from internally executing certain orders of individual investors at a ...
Read more >
Federal Register/Vol. 87, No. 46/Wednesday, March 9, 2022 ...
ACTION: Proposed rule. SUMMARY: The Securities and Exchange. Commission is proposing new rules under the Investment Advisers Act of.
Read more >
Leveraging compatibility and diversity in ... - Springer Link
This article addresses the above limitations regarding scalability and user preference by proposing a computer-aided, diverse, user-customizable ...
Read more >
mattfenwick/NMRPyStar: A Python library for parsing NMR ...
Note that hierarchical rules' first letters are capitalized, ... is a link to the NMR-STAR data dictionary; no duplicate loops, based on the...
Read more >
Leveraging compatibility and diversity in computer-aided ...
Perceptual evaluations of existing rule-based. models have robustly shown that proposed mashups feature. harmonic, rhythmic, and spectral ...
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