Skip to content

Commit

Permalink
tools: discouraging exceptions in core c++ files (envoyproxy#27431)
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Ryan Eskin <ryan.eskin89@protonmail.com>
  • Loading branch information
alyssawilk authored and reskin89 committed Jul 11, 2023
1 parent 515ed3b commit a85490c
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tools/code_format/check_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ def allow_listed_for_raw_try(self, file_path):
def deny_listed_for_exceptions(self, file_path):
# Returns true when it is a non test header file or the file_path is in DENYLIST or
# it is under tools/testdata subdirectory.

return (file_path.endswith('.h') and not file_path.startswith("./test/") and not file_path in self.config.paths["exception"]["include"]) or file_path in self.config.paths["exception"]["exclude"] \
return (file_path.endswith('.h') and not file_path.startswith("./test/") and not file_path in self.config.paths["exception"]["include"]) \
or (file_path.endswith('.cc') and file_path.startswith("./source/") and not file_path.startswith("./source/extensions/") and not file_path in self.config.paths["exception"]["include"]) \
or self.is_in_subdir(file_path, 'tools/testdata')

def allow_listed_for_build_urls(self, file_path):
Expand Down
130 changes: 124 additions & 6 deletions tools/code_format/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,138 @@ paths:
- bazel/external/cargo/crates.bzl
- bazel/repository_locations.bzl

# Header files that can throw exceptions. These should be limited; the only
# valid situation identified so far is template functions used for config
# processing.
exception:
include:
# Header files that can throw exceptions. These should be limited; the only
# valid situation identified so far is template functions used for config
# processing.
- source/common/config/utility.h
- source/common/matcher/map_matcher.h
- source/common/matcher/field_matcher.h
- source/common/protobuf/visitor_helper.h
- source/extensions/common/matcher/trie_matcher.h
# These files should not throw exceptions. Add HTTP/1 when exceptions removed.
exclude:
- source/common/http/http2/codec_impl.h
# legacy core files which throw exceptions. We can add to this list but strongly prefer
# StausOr where possible.
- source/common/upstream/wrsq_scheduler.h
- source/common/upstream/cds_api_helper.cc
- source/common/upstream/thread_aware_lb_impl.cc
- source/common/upstream/load_balancer_impl.cc
- source/common/upstream/health_checker_impl.cc
- source/common/upstream/cluster_manager_impl.cc
- source/common/upstream/od_cds_api_impl.cc
- source/common/upstream/cds_api_impl.cc
- source/common/upstream/outlier_detection_impl.cc
- source/common/upstream/upstream_impl.cc
- source/common/network/connection_impl.cc
- source/common/network/listen_socket_impl.cc
- source/common/network/io_socket_handle_impl.cc
- source/common/network/address_impl.cc
- source/common/network/address_impl.h
- source/common/network/cidr_range.cc
- source/common/network/utility.cc
- source/common/network/dns_resolver/dns_factory_util.cc
- source/common/network/dns_resolver/dns_factory_util.h
- source/common/network/resolver_impl.cc
- source/common/network/utility.h
- source/common/network/lc_trie.h
- source/common/network/socket_impl.cc
- source/common/ssl/tls_certificate_config_impl.cc
- source/common/ssl/certificate_validation_context_config_impl.cc
- source/common/formatter/substitution_formatter.cc
- source/common/formatter/substitution_format_string.cc
- source/common/stats/tag_extractor_impl.cc
- source/common/stats/tag_producer_impl.cc
- source/common/http/http2/codec_impl.cc
- source/common/http/filter_chain_helper.cc
- source/common/http/request_id_extension_impl.cc
- source/common/http/utility.cc
- source/common/http/hash_policy.cc
- source/common/http/utility.h
- source/common/http/filter_chain_helper.h
- source/common/http/conn_manager_utility.cc
- source/common/http/match_delegate/config.cc
- source/common/http/http_server_properties_cache_manager_impl.cc
- source/common/protobuf/yaml_utility.cc
- source/common/protobuf/visitor_helper.h
- source/common/protobuf/visitor.cc
- source/common/protobuf/utility.cc
- source/common/protobuf/utility.h
- source/common/protobuf/message_validator_impl.cc
- source/common/access_log/access_log_impl.h
- source/common/access_log/access_log_manager_impl.cc
- source/common/secret/secret_manager_impl.cc
- source/common/secret/sds_api.h
- source/common/secret/sds_api.cc
- source/common/grpc/async_client_manager_impl.cc
- source/common/grpc/common.cc
- source/common/grpc/google_grpc_utils.cc
- source/common/grpc/common.h
- source/common/tcp_proxy/tcp_proxy.cc
- source/common/config/xds_resource.h
- source/common/config/subscription_factory_impl.cc
- source/common/config/xds_resource.cc
- source/common/config/datasource.cc
- source/common/config/xds_mux/delta_subscription_state.cc
- source/common/config/xds_mux/sotw_subscription_state.cc
- source/common/config/xds_mux/grpc_mux_impl.cc
- source/common/config/utility.cc
- source/common/config/watch_map.h
- source/common/config/datasource.h
- source/common/config/null_grpc_mux_impl.h
- source/common/config/utility.h
- source/common/config/custom_config_validators_impl.h
- source/common/config/xds_context_params.cc
- source/common/config/custom_config_validators_impl.cc
- source/common/runtime/runtime_impl.cc
- source/common/quic/quic_transport_socket_factory.cc
- source/common/filter/config_discovery_impl.cc
- source/common/event/timer_impl.h
- source/common/matcher/map_matcher.h
- source/common/matcher/field_matcher.h
- source/common/json/json_internal.cc
- source/common/json/json_internal.h
- source/common/json/json_sanitizer.cc
- source/common/router/header_formatter.cc
- source/common/router/scoped_rds.cc
- source/common/router/rds_impl.cc
- source/common/router/config_impl.cc
- source/common/router/config_impl.h
- source/common/router/scoped_config_impl.cc
- source/common/router/router_ratelimit.cc
- source/common/router/vhds.cc
- source/common/router/config_utility.cc
- source/common/router/scoped_rds.h
- source/common/router/header_parser.cc
- source/common/router/config_utility.h
- source/common/rds/rds_route_config_subscription.cc
- source/common/filesystem/inotify/watcher_impl.cc
- source/common/filesystem/posix/directory_iterator_impl.cc
- source/common/filesystem/posix/filesystem_impl.cc
- source/common/filesystem/kqueue/watcher_impl.cc
- source/common/filesystem/win32/directory_iterator_impl.cc
- source/common/filesystem/win32/filesystem_impl.cc
- source/common/filesystem/win32/watcher_impl.cc
- source/common/common/utility.cc
- source/common/common/regex.cc
- source/common/common/logger.h
- source/common/common/thread.h
- source/common/common/utility.h
- source/common/common/matchers.h
- source/common/common/matchers.cc
- source/exe/stripped_main_base.cc
- source/server/options_impl.cc
- source/server/options_impl.h
- source/server/server.h
- source/server/overload_manager_impl.cc
- source/server/config_validation/cluster_manager.cc
- source/server/config_validation/server.cc
- source/server/admin/html/active_stats.js
- source/server/server.cc
- source/server/configuration_impl.h
- source/server/hot_restarting_base.cc
- source/server/hot_restart_impl.cc
- source/server/ssl_context_manager.cc
- source/server/configuration_impl.cc

# Only one C++ file should instantiate grpc_init
grpc_init:
Expand Down

0 comments on commit a85490c

Please sign in to comment.