RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

CODING_CONVENTIONS.md: Add IWYU policy

Open maribu opened this issue 1 year ago • 3 comments

Contribution description

This makes an implicit agreement that code should include the headers is uses, no more and no less, explicit.

It also recommends using tooling (such as clangd) and adding IWUY pragma comments to aid those tools in common cases they otherwise would provide false positives.

Testing procedure

Read the changed coding conventions and confirm that this is what we want to do.

Issues/PRs references

None

maribu avatar Apr 14 '24 13:04 maribu

Murdock results

:heavy_check_mark: PASSED

e13ceeb765cdb42eb0cec9c3234386d2ff9d465e Update CODING_CONVENTIONS.md

Success Failures Total Runtime
1 0 1 01m:00s

Artifacts

riot-ci avatar Apr 14 '24 13:04 riot-ci

Having that done is in no way a precondition to adopting this convention, but relevant to whether we can uphold the convention: Is it realistic to have this enforced by CI? (Otherwise I fear it will be a frequently missed point in both PRs and reviews).

chrysn avatar Apr 14 '24 18:04 chrysn

I think this is only relevant for hardware abstraction APIs, e.g. periph drivers and IRQ APIs. So I don't really expect new offenders to merged at a rate faster than I can fix.

I don't think that adding the pragmas can be enforcement. But having the code IWYU clean could be enforced by the CI, which would indirectly enforce suppression of false positives. But getting there will be more work than a few minutes of spare in-betweeen on a Sunday afternoon...

I might tackle that in a few months. Sounds like a sensible thing to aim for.

maribu avatar Apr 14 '24 19:04 maribu