Skip to content

Commit

Permalink
Add clang formatting checks for src/ files (bloomberg#51)
Browse files Browse the repository at this point in the history
* add clang-format

* clang format

* Update .github/workflows/build.yaml

Co-authored-by: Will Hoy <[email protected]>

---------

Co-authored-by: Taylor Foxhall <[email protected]>
  • Loading branch information
willhoy and hallfox authored Aug 2, 2023
1 parent 1563c99 commit 25ae31f
Show file tree
Hide file tree
Showing 26 changed files with 11,059 additions and 11,474 deletions.
45 changes: 45 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
BasedOnStyle: LLVM
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowAllArgumentsOnNextLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortLambdasOnASingleLine: Empty
AlwaysBreakTemplateDeclarations: Yes
BinPackParameters: false
BinPackArguments: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakConstructorInitializers: BeforeComma
ColumnLimit: 79
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
FixNamespaceComments: false
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
PenaltyBreakBeforeFirstCallParameter: 25
PenaltyBreakAssignment: 100
PointerAlignment: Left
ReflowComments: true
SortIncludes: CaseInsensitive
SpaceBeforeCpp11BracedList: false
SpacesBeforeTrailingComments: 2
Standard: Cpp03
TabWidth: 4
24 changes: 18 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,30 @@ jobs:
cd cmake.bld/Linux
ctest -E mwcsys_executil.t --output-on-failure
lint_and_docs:
name: "Lint and Docs"
Documentation:
name: "Documentation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up dependencies
run: |
sudo apt-get update
sudo apt-get install -qy clang-format git doxygen
- name: Lint sources
run: |
git clang-format
sudo apt-get install -qy doxygen
- name: Build docs
run: |
doxygen Doxyfile
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
strategy:
matrix:
path:
- 'src'
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '14'
check-path: ${{ matrix.path }}
8 changes: 4 additions & 4 deletions src/groups/bmq/bmqa/bmqa_mocksession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,14 +955,14 @@ MockSession::MockSession(const bmqt::SessionOptions& options,
bdlf::PlaceHolders::_2,
bdlf::PlaceHolders::_3))
, d_lastQueueId(0)
, d_corrIdContainer_sp(new(*bslma::Default::allocator(allocator))
, d_corrIdContainer_sp(new (*bslma::Default::allocator(allocator))
bmqimp::MessageCorrelationIdContainer(
bslma::Default::allocator(allocator)),
bslma::Default::allocator(allocator))
, d_postedEvents(bslma::Default::allocator(allocator))
, d_rootStatContext(mwcst::StatContextConfiguration("MockSession", allocator),
allocator)
, d_queuesStats_sp(new(*bslma::Default::allocator(allocator))
, d_queuesStats_sp(new (*bslma::Default::allocator(allocator))
bmqimp::Stat(bslma::Default::allocator(allocator)),
bslma::Default::allocator(allocator))
, d_sessionOptions(options, allocator)
Expand Down Expand Up @@ -998,14 +998,14 @@ MockSession::MockSession(bslma::ManagedPtr<SessionEventHandler> eventHandler,
bdlf::PlaceHolders::_2,
bdlf::PlaceHolders::_3))
, d_lastQueueId(0)
, d_corrIdContainer_sp(new(*bslma::Default::allocator(allocator))
, d_corrIdContainer_sp(new (*bslma::Default::allocator(allocator))
bmqimp::MessageCorrelationIdContainer(
bslma::Default::allocator(allocator)),
bslma::Default::allocator(allocator))
, d_postedEvents(bslma::Default::allocator(allocator))
, d_rootStatContext(mwcst::StatContextConfiguration("MockSession", allocator),
allocator)
, d_queuesStats_sp(new(*bslma::Default::allocator(allocator))
, d_queuesStats_sp(new (*bslma::Default::allocator(allocator))
bmqimp::Stat(bslma::Default::allocator(allocator)),
bslma::Default::allocator(allocator))
, d_sessionOptions(options, allocator)
Expand Down
3 changes: 2 additions & 1 deletion src/groups/bmq/bmqa/bmqa_mocksession.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ using namespace bsl;

/// Mapping class. Will be partially specialized below.
template <typename T>
struct ResultRegistry {};
struct ResultRegistry {
};

/// Partial specialization for mapping to `bmqa::OpenQueueStatus`.
template <>
Expand Down
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqimp/bmqimp_brokersession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ BrokerSession::QueueFsm::QueueFsm(BrokerSession& session)
typedef QueueState S;
typedef QueueFsmEvent E;
QueueStateTransition table[] = {
// current state event new state
// current state event new state
{S::e_CLOSED, E::e_OPEN_CMD, S::e_OPENING_OPN},
//
{S::e_OPENING_OPN, E::e_RESP_OK, S::e_OPENING_CFG},
Expand Down
3 changes: 2 additions & 1 deletion src/groups/bmq/bmqp/bmqp_queueid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace bsl {
// need to have 'is_fundamental' trait.

template <>
struct is_fundamental<BloombergLP::bmqp::QueueId::QueueIdInt> : true_type {};
struct is_fundamental<BloombergLP::bmqp::QueueId::QueueIdInt> : true_type {
};

template <>
struct is_fundamental<BloombergLP::bmqp::QueueId::SubQueueIdInt> : true_type {
Expand Down
4 changes: 2 additions & 2 deletions src/groups/mqb/mqbblp/mqbblp_clusterorchestrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ ClusterOrchestrator::ClusterOrchestrator(
, d_stateManager_mp(
clusterConfig.clusterAttributes().isFSMWorkflow()
? static_cast<mqbi::ClusterStateManager*>(
new(*d_allocator_p) mqbc::ClusterStateManager(
new (*d_allocator_p) mqbc::ClusterStateManager(
clusterConfig,
d_cluster_p,
d_clusterData_p,
Expand All @@ -595,7 +595,7 @@ ClusterOrchestrator::ClusterOrchestrator(
k_WATCHDOG_TIMEOUT_DURATION,
d_allocators.get("ClusterStateManager")))
: static_cast<mqbi::ClusterStateManager*>(
new(*d_allocator_p) ClusterStateManager(
new (*d_allocator_p) ClusterStateManager(
clusterConfig,
d_cluster_p,
d_clusterData_p,
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ bool ClusterQueueHelper::createQueue(
<< context.d_handleParameters << "]";

mqbi::Cluster::OpenQueueConfirmationCookie confirmationCookie(
new (*d_allocator_p) mqbi::QueueHandle * (0),
new (*d_allocator_p) mqbi::QueueHandle*(0),
bdlf::BindUtil::bind(
&ClusterQueueHelper::onOpenQueueConfirmationCookieReleased,
this,
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_messagegroupidmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ MessageGroupIdManager::MessageGroupIdManager(const Time& timeout,
, d_timeout(timeout)
, d_maxMsgGroupIds(maxMsgGroupIds)
, d_rebalance(rebalance)
, d_index(new(*allocator) Index(allocator), allocator)
, d_index(new (*allocator) Index(allocator), allocator)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_queueconsumptionmonitor.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct ClientContext {

ClientContext::ClientContext()
: d_dispatcherClient(s_allocator_p)
, d_requesterContext_sp(new(*s_allocator_p)
, d_requesterContext_sp(new (*s_allocator_p)
mqbi::QueueHandleRequesterContext(s_allocator_p),
s_allocator_p)
{
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_queueengineutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ QueueEngineUtil_AppState::QueueEngineUtil_AppState(
const mqbu::StorageKey& appKey,
bslma::Allocator* allocator)
: d_storageIter_mp(iterator)
, d_routing_sp(new(*allocator) Routers::AppContext(queueContext, allocator),
, d_routing_sp(new (*allocator) Routers::AppContext(queueContext, allocator),
allocator)
, d_redeliveryList(allocator)
, d_putAsideList(allocator)
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_queuehandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ inline QueueHandle::Downstream::Downstream(const bsl::string& appId,
bslma::Allocator* allocator_p)
: d_appId(appId)
, d_upstreamSubQueueId(upstreamSubQueueId)
, d_data(new(*allocator_p)
, d_data(new (*allocator_p)
mqbi::QueueHandle::UnconfirmedMessageInfoMap(allocator_p),
allocator_p)
{
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_queuehandlecatalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void QueueHandleCatalog::queueHandleDeleter(mqbi::QueueHandle* handle)
QueueHandleCatalog::QueueHandleCatalog(mqbi::Queue* queue,
bslma::Allocator* allocator)
: d_queue_p(queue)
, d_handleFactory_mp(new(*allocator) DefaultHandleFactory(), allocator)
, d_handleFactory_mp(new (*allocator) DefaultHandleFactory(), allocator)
, d_handles(allocator)
, d_allocator_p(allocator)
{
Expand Down
4 changes: 2 additions & 2 deletions src/groups/mqb/mqbblp/mqbblp_queuesessionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ QueueSessionManager::QueueSessionManager(
, d_domainFactory_p(domainFactory)
, d_allocator_p(allocator)
, d_shutdownInProgress(false)
, d_validator_sp(new(*allocator) mwcu::AtomicValidator(), allocator)
, d_requesterContext_sp(new(*allocator)
, d_validator_sp(new (*allocator) mwcu::AtomicValidator(), allocator)
, d_requesterContext_sp(new (*allocator)
mqbi::QueueHandleRequesterContext(allocator),
allocator)
{
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_routers.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ inline Routers::QueueRoutingContext::QueueRoutingContext(
: d_expressions(allocator)
, d_nextSubscriptionId(0)
, d_groupIds(allocator)
, d_preader(new(*allocator) MessagePropertiesReader(schemaLearner, allocator),
, d_preader(new (*allocator) MessagePropertiesReader(schemaLearner, allocator),
allocator)
, d_evaluationContext(0, allocator)
, d_allocator_p(allocator)
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbblp/mqbblp_routers.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct TestStorage {
allocator)
, d_iterator(d_storage.getIterator(mqbu::StorageKey()))
, d_bufferFactory(32, allocator)
, d_queue_sp(new(*allocator) mqbmock::Queue(0, allocator), allocator)
, d_queue_sp(new (*allocator) mqbmock::Queue(0, allocator), allocator)
, d_allocator_p(allocator)

{
Expand Down
2 changes: 1 addition & 1 deletion src/groups/mqb/mqbc/mqbc_clusternodesession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ClusterNodeSession::ClusterNodeSession(
, d_clusterNode_p(netNode)
, d_peerInstanceId(0) // There is no invalid value for this field
, d_queueHandleRequesterContext_sp(
new(*allocator) mqbi::QueueHandleRequesterContext(allocator),
new (*allocator) mqbi::QueueHandleRequesterContext(allocator),
allocator)
, d_nodeStatus(bmqp_ctrlmsg::NodeStatus::E_UNAVAILABLE) // See note in ctor
, d_statContext_sp()
Expand Down
Loading

0 comments on commit 25ae31f

Please sign in to comment.