[SERVER-66202] MONGO_LOGV2_DEFAULT_COMPONENT conventions lint check Created: 03/May/22  Updated: 29/Oct/23  Resolved: 06/May/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-66203 Sweep: move MONGO_LOGV2_DEFAULT_COMPO... Closed
Issue split
split from SERVER-52604 Log from anywhere (normalize MONGO_LO... Closed
Related
is related to SERVER-71741 Move macro definition leaks check to ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2022-05-16
Participants:

 Description   

Enforce that MONGO_LOGV2_DEFAULT_COMPONENT definitions are hermetic, and affect only the file in which the definition appears. If a file defines the macro, it must undefine it before handing control to another file.

1) Headers that define it must undefine it.

2) It must not have a definition when an include is performed. This usually means the definition must be below the customary `#include` blocks.

A sweep of the codebase described in SERVER-52604 is a prerequisite for (2).



 Comments   
Comment by Billy Donahue [ 06/May/22 ]

I only implemented rule #1 from the description. Headers that define it must undefine it.

I think maybe violations of rule #2 are less harmful and it's harder to implement with Python+RE than #1. The risk it would allow is for #defines to appear after #includes in new files if we don't check against it. But my feeling is that after a little while, people will stop trying to do this, as it's an unusual thing to do in C++, and all other source files are setting a good example. If any find their way in, we can manually fix very easily. It shouldn't take more than 1 more round, perhaps a month or two down the road?

Comment by Githook User [ 06/May/22 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-66202 linter for undef MONGO_LOGV2_DEFAULT_COMPONENT
Branch: master
https://github.com/mongodb/mongo/commit/32f33cb29be85e58e3be2ac0cdc1481bf2d73910

Generated at Thu Feb 08 06:04:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.