Skip to content

Decide whether to check function arguments / null members or not #50

@HansAcker

Description

@HansAcker

Some methods guard against invalid arguments (formatRelativeNumber() checks that its argument is a number), others don't (hex2bg() assumes that its argument is a string). Some parts use null-checks (event.message?.StarSystem), others don't (event.message.Name).
Make it make more sense.

  • Pro: you'll never know. better to check argument types and requirements, throw or return sensible values in case of error. ?., typeof and === undefined should be cheap. Is branch prediction still a thing after Spectre?

  • Con: we don't need no safety checks, they only waste cycles. The gateway already validates the data, doesn't it? event.header.uploaderID should always be a string, never a number or undefined. And if it were, exceptions would be thrown and logged by MessageRouter, as intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions