Skip to content

Add targeted [[nodiscard]] annotations to critical result-returning APIs - #8

Merged
eskfro merged 2 commits into
mainfrom
copilot/fix-add-nodiscard-to-functions
Sep 1, 2026
Merged

eskfro merged 2 commits into
mainfrom
copilot/fix-add-nodiscard-to-functions

Conversation

Copilot AI commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

This PR tightens compile-time misuse detection by marking a small set of high-signal return values as [[nodiscard]]. Scope is intentionally narrow: only validity checks and network send/receive outcomes where ignoring results can mask faults.

  • What changed

    • Added [[nodiscard]] to critical validators in state/order models:
      • ElevatorState::Valid(), ElevatorState::Usable()
      • Order::Valid(), OrderTable::Valid()
      • Order::ObservedBy(int) (observation-state check)
    • Added [[nodiscard]] to network outcome APIs:
      • UdpBroadcaster::SendPacket(...)
      • UdpReciever::RecievePacket(...)
      • NetworkPacket::Valid()
  • Scope boundaries

    • Header declarations only.
    • No behavioral, control-flow, or formatting changes outside these annotations.
  • Example

[[nodiscard]] bool Valid() const;
[[nodiscard]] bool SendPacket(NetworkPacket* packet);
[[nodiscard]] bool RecievePacket(NetworkPacket* packet);

Copilot AI linked an issue Sep 1, 2026 that may be closed by this pull request
Co-authored-by: eskfro <106732002+eskfro@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix: add nodiscard to critical functions Add targeted [[nodiscard]] annotations to critical result-returning APIs Sep 1, 2026
Copilot AI requested a review from eskfro September 1, 2026 14:23

@eskfro eskfro left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice.

@eskfro
eskfro marked this pull request as ready for review September 1, 2026 14:37
@eskfro
eskfro merged commit 9d35653 into main Sep 1, 2026
1 check passed
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.

fix: add nodiscard to functions

2 participants