Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Instrumentation/HTTP2/HTTPS: Enforce strictNullChecks and noUnusedLocals #406

Conversation

mayurkale22
Copy link
Member

strictNullChecks will help us to make the code safer (referencing nulls or undefined values), more robust and reduce some boilerplate.

This is part of #348

const path = requestHeaders[':path'];
let statusCode = 200;
if (path) {
statusCode = path.length > 1 ? +path.slice(1) : 200;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: what would you think about using Number(path.slice(1)) to make the type conversion a bit more explicit?

And do we need to worry about malformed numbers here (that would give NaN to the Number constructor call)? If so, I'd say we can do in a follow up PR, but figured I'd mention as I'm thinking of it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, added isNaN check. PTAL

@codecov-io
Copy link

codecov-io commented Mar 8, 2019

Codecov Report

Merging #406 into master will decrease coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #406      +/-   ##
==========================================
- Coverage   94.82%   94.77%   -0.06%     
==========================================
  Files         136      136              
  Lines        8935     8942       +7     
  Branches      656      662       +6     
==========================================
+ Hits         8473     8475       +2     
- Misses        462      467       +5
Impacted Files Coverage Δ
src/stackdriver-monitoring.ts 81.05% <0%> (-3.16%) ⬇️
src/http2.ts 88% <0%> (-1.92%) ⬇️
src/https.ts 97.5% <0%> (ø) ⬆️
test/test-https.ts 99.46% <0%> (ø) ⬆️
test/test-http2.ts 99.33% <0%> (+0.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89cb441...4833bcc. Read the comment docs.

@mayurkale22 mayurkale22 merged commit 0d91323 into census-instrumentation:master Mar 9, 2019
@mayurkale22 mayurkale22 deleted the enforce_strictNullcheck_http2_https branch March 9, 2019 20:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants