coapjs / node-coap

CoAP - Node.js style
MIT License
531 stars 154 forks source link

refactor: add strict nullchecks #297

Closed JKRhb closed 2 years ago

JKRhb commented 2 years ago

Another rather trivial PR adding explicit checks for null or undefined.

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 1314194310


Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/agent.js 24 25 96.0%
<!-- Total: 44 45 97.78% -->
Totals Coverage Status
Change from base Build 1313580033: -0.1%
Covered Lines: 1078
Relevant Lines: 1163

💛 - Coveralls
Apollon77 commented 2 years ago

honestly I do not like "type-unsafe" checks with == or != ... They are not rteally better then the "falsy" checks before ... (in my eyes) but all good we can leave it that way too ...

JKRhb commented 2 years ago

Yeah, it adds some noise that isn't really necessary :/ The reason for PRs like these were the fact that I activated the option for strict null checks in #293 which complained about checks for falsy values. Maybe we can discuss over there if this is actually necessary. So far I thought the stricter the checks the better but in most cases it probably doesn't bring that much value.

Apollon77 commented 2 years ago

I personally use "falsy" checks if I know that it can not be false and want to do tese checks ... or I really check for types or such depending on what I want/need... but as said ... personal flavour