Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(test): prefer forEach instead of map #556

Merged
merged 2 commits into from
Nov 21, 2019

Conversation

ferhatelmas
Copy link
Contributor

Which problem is this PR solving?

  • prefer forEach over map unless the generated array is needed.

Short description of the changes

  • makes the intention clearer.

@codecov-io
Copy link

codecov-io commented Nov 20, 2019

Codecov Report

Merging #556 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master    #556      +/-   ##
=========================================
- Coverage   90.22%   90.2%   -0.02%     
=========================================
  Files         150     150              
  Lines        7435    7462      +27     
  Branches      663     669       +6     
=========================================
+ Hits         6708    6731      +23     
- Misses        727     731       +4
Impacted Files Coverage Δ
packages/opentelemetry-tracing/test/Span.test.ts 100% <ø> (ø) ⬆️
...ckages/opentelemetry-plugin-grpc/test/grpc.test.ts 96.11% <100%> (ø) ⬆️
...-scope-zone-peer-dep/test/ZoneScopeManager.test.ts 0% <0%> (ø) ⬆️
...s/opentelemetry-core/test/trace/NoopTracer.test.ts 60% <0%> (ø) ⬆️
...lemetry-core/test/trace/ProbabilitySampler.test.ts 56.52% <0%> (ø) ⬆️
...elemetry-core/test/trace/spancontext-utils.test.ts 55.55% <0%> (ø) ⬆️
...s/opentelemetry-core/test/context/B3Format.test.ts 63.39% <0%> (ø) ⬆️
...ges/opentelemetry-core/test/trace/NoopSpan.test.ts 63.63% <0%> (ø) ⬆️
...s/opentelemetry-core/test/trace/tracestate.test.ts 65.06% <0%> (ø) ⬆️
...pentelemetry-core/test/internal/validators.test.ts 50% <0%> (ø) ⬆️
... and 64 more

@dyladan
Copy link
Member

dyladan commented Nov 21, 2019

In general do we prefer Array.prototype.forEach or for..of syntax? I prefer for..of usually.

@mayurkale22
Copy link
Member

@draffensperger
Copy link
Contributor

One interesting note is that for (const of loops can sometimes optimize better with the Closure compiler (useful for certain web builds) since it enables it to do better reachability analysis of the code. I also like it for style reasons, but I'm open to .forEach.

Copy link
Contributor

@draffensperger draffensperger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely prefer forEach to map when the eventual list is not used

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mayurkale22 mayurkale22 merged commit df2cc43 into open-telemetry:master Nov 21, 2019
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
martinkuba pushed a commit to martinkuba/opentelemetry-js that referenced this pull request Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants