Skip to content

Commit 1860b3f

Browse files
ChristianTackeGSIdennisklein
authored andcommitted
clang-format: Put braces on own line in special cases
Multi-line control statements with the opening brace on the last line can be a little confusing to read: ```cpp if (auto foo = something; foo.extra_data.check_for(17)) { foo.extra_data.check_and_act(19); } ``` It is not easy to see the end of the condition and the start of the "then" block. This gets much easier when putting the opening brace on its own line: ```cpp if (auto foo = something; foo.extra_data.check_for(17)) { foo.extra_data.check_and_act(19); } ```
1 parent b732912 commit 1860b3f

File tree

14 files changed

+37
-22
lines changed

14 files changed

+37
-22
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ BraceWrapping:
2626
SplitEmptyFunction: false
2727
SplitEmptyRecord: false
2828
SplitEmptyNamespace: false
29+
AfterControlStatement: MultiLine
2930
BreakConstructorInitializers: BeforeComma
3031
ColumnLimit: 120
3132
ConstructorInitializerIndentWidth: 4

examples/MQ/pixelDetector/src/Pixel.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ Bool_t Pixel::ProcessHits(FairVolume* vol)
9090

9191
// Create PixelPoint at exit of active volume
9292
if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop()
93-
|| TVirtualMC::GetMC()->IsTrackDisappeared()) {
93+
|| TVirtualMC::GetMC()->IsTrackDisappeared())
94+
{
9495
fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
9596
fVolumeID = vol->getMCid();
9697

examples/MQ/pixelDetector/src/PixelDigitize.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -144,7 +144,8 @@ void PixelDigitize::ActivatePixel(Int_t index,
144144
for (Int_t ipixel = 0; ipixel < fNDigis; ipixel++) {
145145
tempPixel = static_cast<PixelDigi*>(fDigis->At(ipixel));
146146
if (tempPixel->GetDetectorID() == detId && tempPixel->GetFeID() == feId && tempPixel->GetCol() == col
147-
&& tempPixel->GetRow() == row) {
147+
&& tempPixel->GetRow() == row)
148+
{
148149
pixelAlreadyFired = kTRUE;
149150
tempPixel->SetCharge(tempPixel->GetCharge() + charge);
150151
}

examples/advanced/Tutorial3/simulation/FairTestDetector.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ Bool_t FairTestDetector::ProcessHits(FairVolume* vol)
8585

8686
// Create FairTestDetectorPoint at exit of active volume
8787
if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop()
88-
|| TVirtualMC::GetMC()->IsTrackDisappeared()) {
88+
|| TVirtualMC::GetMC()->IsTrackDisappeared())
89+
{
8990
fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
9091
fVolumeID = vol->getMCid();
9192
TVirtualMC::GetMC()->TrackPosition(fPosOut);

examples/advanced/propagator/src/FairTutPropDet.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ Bool_t FairTutPropDet::ProcessHits(FairVolume* vol)
8080

8181
// Create FairTutPropPoint at exit of active volume
8282
if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop()
83-
|| TVirtualMC::GetMC()->IsTrackDisappeared()) {
83+
|| TVirtualMC::GetMC()->IsTrackDisappeared())
84+
{
8485
fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
8586
fVolumeID = vol->getMCid();
8687

fairroot/base/event/FairMultiLinkedData.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ void FairMultiLinkedData::AddLink(FairLink link, Bool_t bypass, Float_t mult)
132132

133133
if (!fPersistanceCheck || link.GetIndex() < 0
134134
|| (link.GetType() != ioman->GetMCTrackBranchId()
135-
&& ioman->CheckBranch(ioman->GetBranchName(link.GetType())) == 0)) {
135+
&& ioman->CheckBranch(ioman->GetBranchName(link.GetType())) == 0))
136+
{
136137
InsertLink(link);
137138
if (fInsertHistory)
138139
InsertHistory(link);
@@ -145,7 +146,8 @@ void FairMultiLinkedData::AddLink(FairLink link, Bool_t bypass, Float_t mult)
145146
<< " checkStatus: " << ioman->CheckBranch(ioman->GetBranchName(link.GetType())) << std::endl;
146147
}
147148
if (link.GetType() > ioman->GetMCTrackBranchId()
148-
&& ioman->CheckBranch(ioman->GetBranchName(link.GetType())) != 1) {
149+
&& ioman->CheckBranch(ioman->GetBranchName(link.GetType())) != 1)
150+
{
149151
if (fVerbose > 1) {
150152
std::cout << "BYPASS!" << std::endl;
151153
}

fairroot/base/steer/FairRadGridManager.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -143,7 +143,8 @@ Bool_t FairRadGridManager::IsTrackInside(TLorentzVector& pos, FairMesh* aMesh)
143143
{
144144
// check if inside volume
145145
if ((pos.X() >= aMesh->GetXmin()) && (pos.X() <= aMesh->GetXmax()) && (pos.Y() >= aMesh->GetYmin())
146-
&& (pos.Y() <= aMesh->GetYmax()) && (pos.Z() >= aMesh->GetZmin()) && (pos.Z() <= aMesh->GetZmax())) {
146+
&& (pos.Y() <= aMesh->GetYmax()) && (pos.Z() >= aMesh->GetZmin()) && (pos.Z() <= aMesh->GetZmax()))
147+
{
147148
/* cout << " inside Xpos: " << pos.X() << " Xmin: " << aMesh->GetXmin()
148149
<< " Xmax: " << aMesh->GetXmax() << endl;
149150
cout << " inside Ypos: " << pos.Y() << " Ymin: " << aMesh->GetYmin()

fairroot/base/steer/FairWriteoutBuffer.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ void FairWriteoutBuffer::FillDataToDeadTimeMap(FairTimeStamp* data, double activ
175175
// PrintDeadTimeMap();
176176
for (DTMapIter it = fDeadTime_map.lower_bound(currentdeadtime);
177177
it != fDeadTime_map.upper_bound(currentdeadtime);
178-
++it) {
178+
++it)
179+
{
179180
oldData = it->second;
180181
if (fVerbose > 1) {
181182
std::cout << "Check Data: " << it->first << " : " << oldData << std::endl;
@@ -195,8 +196,8 @@ void FairWriteoutBuffer::FillDataToDeadTimeMap(FairTimeStamp* data, double activ
195196
}
196197

197198
if (dataFound) {
198-
if (timeOfOldData
199-
> startTime) { // if older active data can interference with the new data call modify function
199+
if (timeOfOldData > startTime)
200+
{ // if older active data can interference with the new data call modify function
200201
std::vector<std::pair<double, FairTimeStamp*>> modifiedData =
201202
Modify(std::pair<double, FairTimeStamp*>(currentdeadtime, oldData),
202203
std::pair<double, FairTimeStamp*>(activeTime, data));

fairroot/generators/FairBoxGenerator.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ Bool_t FairBoxGenerator::Init()
161161
if (fPRangeIsSet && fYRangeIsSet) {
162162
LOG(fatal) << "FairBoxGenerator:Init(): Cannot set P and Y ranges simultaneously";
163163
}
164-
if ((fThetaRangeIsSet && fYRangeIsSet) || (fThetaRangeIsSet && fEtaRangeIsSet)
165-
|| (fYRangeIsSet && fEtaRangeIsSet)) {
164+
if ((fThetaRangeIsSet && fYRangeIsSet) || (fThetaRangeIsSet && fEtaRangeIsSet) || (fYRangeIsSet && fEtaRangeIsSet))
165+
{
166166
LOG(fatal) << "FairBoxGenerator:Init(): Cannot set Y, Theta or Eta ranges simultaneously";
167167
}
168168
return kTRUE;

fairroot/online/source/FairMbsSource.cxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -36,12 +36,14 @@ Bool_t FairMbsSource::Unpack(Int_t* data,
3636

3737
if (unpack->GetSubCrate() < 0) { // All sub-crates
3838
if (type != unpack->GetType() || subType != unpack->GetSubType() || procId != unpack->GetProcId()
39-
|| control != unpack->GetControl()) {
39+
|| control != unpack->GetControl())
40+
{
4041
continue;
4142
}
4243
} else { // specified sub-crate
4344
if (type != unpack->GetType() || subType != unpack->GetSubType() || procId != unpack->GetProcId()
44-
|| subCrate != unpack->GetSubCrate() || control != unpack->GetControl()) {
45+
|| subCrate != unpack->GetSubCrate() || control != unpack->GetControl())
46+
{
4547
continue;
4648
}
4749
}

0 commit comments

Comments
 (0)