[SERVER-34802] Automate enforcement of #pragma once in header files Created: 02/May/18  Updated: 25/Jan/24

Status: Backlog
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Andy Schwerin Assignee: Backlog - Service Architecture
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-30747 Add a lint rule to enforce #pragma on... Closed
Assigned Teams:
Service Arch
Participants:

 Description   

Just under 70 header files fail to issue a  #pragma once directive. We should automate the detection of this in our linting tools.

$ grep --include="*.h" -IrL '#pragma once' src/mongo
src/mongo/bson/mutable/mutable_bson_test_utils.h
src/mongo/transport/message_compressor_noop.h
src/mongo/transport/message_compressor_zlib.h
src/mongo/transport/message_compressor_snappy.h
src/mongo/util/table_formatter.h
src/mongo/util/quick_exit.h
src/mongo/util/version.h
src/mongo/util/md5.h
src/mongo/util/options_parser/startup_options.h
src/mongo/util/dns_query_windows-impl.h
src/mongo/util/dns_query_android-impl.h
src/mongo/util/dns_query_posix-impl.h
src/mongo/shell/linenoise.h
src/mongo/shell/linenoise_utf8.h
src/mongo/shell/mk_wcwidth.h
src/mongo/platform/stack_locator.h
src/mongo/s/database_version_helpers.h
src/mongo/s/version_mongos.h
src/mongo/dbtests/framework.h
src/mongo/gotools/vendor/src/gopkg.in/mgo.v2/internal/sasl/sasl_windows.h
src/mongo/gotools/vendor/src/gopkg.in/mgo.v2/internal/sasl/sspi_windows.h
src/mongo/gotools/vendor/src/github.com/10gen/llmgo/internal/sasl/sasl_windows.h
src/mongo/gotools/vendor/src/github.com/10gen/llmgo/internal/sasl/sspi_windows.h
src/mongo/gotools/vendor/src/github.com/10gen/openssl/shim.h
src/mongo/db/ftdc/ftdc_test.h
src/mongo/db/auth/restriction_mock.h
src/mongo/db/auth/impersonation_session.h
src/mongo/db/auth/user_cache_invalidator_job.h
src/mongo/db/catalog/drop_database.h
src/mongo/db/catalog/drop_indexes.h
src/mongo/db/catalog/catalog_control.h
src/mongo/db/catalog/capped_utils.h
src/mongo/db/catalog/coll_mod.h
src/mongo/db/catalog/drop_collection.h
src/mongo/db/catalog/rename_collection.h
src/mongo/db/catalog/create_collection.h
src/mongo/db/repl/do_txn.h
src/mongo/db/repl/apply_ops.h
src/mongo/db/repl/mock_repl_coord_server_fixture.h
src/mongo/db/storage/wiredtiger/wiredtiger_parameters.h
src/mongo/db/storage/mmap_v1/file_allocator.h
src/mongo/db/storage/mmap_v1/dur_stats.h
src/mongo/db/startup_warnings_mongod.h
src/mongo/db/startup_warnings_common.h
src/mongo/db/exec/and_common-inl.h
src/mongo/db/ops/insert.h
src/mongo/db/commands/copydb_start_commands.h
src/mongo/db/commands/kill_op_cmd_base.h
src/mongo/db/commands/shutdown.h
src/mongo/db/commands/killcursors_common.h
src/mongo/db/query/parsed_projection.h
src/mongo/db/query/find_common.h
src/mongo/db/query/get_executor.h
src/mongo/db/query/query_planner_test_lib.h
src/mongo/db/modules/subscription/src/snmp/snmp.h
src/mongo/db/modules/subscription/src/snmp/serverstatus_client.h
src/mongo/db/modules/subscription/src/rlp/rlp_language.h
src/mongo/db/modules/subscription/src/rlp/rlp_options.h
src/mongo/db/modules/subscription/src/queryable/queryable_wt/blockstore_fs.h
src/mongo/db/curop_failpoint_helpers.h
src/mongo/db/stats/fine_clock.h
src/mongo/db/field_parser-inl.h
src/mongo/executor/async_stream_common.h
src/mongo/executor/connection_pool_test_fixture.h
src/mongo/executor/test_network_connection_hook.h
src/mongo/client/native_sasl_client_session.h
src/mongo/client/cyrus_sasl_client_session.h
src/mongo/client/embedded/libmongodbcapi.h
src/mongo/client/embedded/embedded_transport_layer.h

 



 Comments   
Comment by David Storch [ 25/Jan/24 ]

alex.neben@mongodb.com I found this ticket because in the course of my usual work I noticed a header file that snuck into the code base without "#pragma once" and wondered how this escaped detection. Is this very easy to implement, and if so should it be re-triaged?

Comment by Alex Neben [ 29/Aug/23 ]

I think this could be a clang-tidy rule. Sending this over to service arch to decide how to prioritize this.

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