Skip to content

Conversation

@rbx
Copy link
Member

@rbx rbx commented Apr 7, 2020

Just as a basis for discussion, feel free to change/ignore.

This is the format we use in FairMQ, it uses Mozilla format as the base.
Here you can find what each entry means.

Your favorite editor should have a feature/plugin to apply these rules to a file/section of code via button press/mouse click to try it out.

  • Format definition via .clang-format file.
  • Apply format to all files (*\.(h|hpp|c|C|cpp|cxx|tpl)$).
  • Script to check format for a diff.
  • Add cmake target that runs the diff check.
  • Test script to run the diff check target and upload result to CDash.
  • Integration with Jenkins.

@rbx rbx changed the title Clang format option WIP: Format Apr 20, 2020
@rbx rbx force-pushed the clang-format-option branch from 02237e4 to 589adbe Compare April 20, 2020 15:35
@FairRootGroup FairRootGroup deleted a comment from dennisklein Apr 20, 2020
@rbx rbx force-pushed the clang-format-option branch from 589adbe to 7ee4db3 Compare April 20, 2020 16:21
@rbx rbx force-pushed the clang-format-option branch from 5bdb84d to e0d2c9a Compare April 20, 2020 20:47
@FairRootGroup FairRootGroup deleted a comment from rbx Apr 20, 2020
@rbx rbx force-pushed the clang-format-option branch 2 times, most recently from 0b99883 to adc8462 Compare April 21, 2020 21:34
@rbx rbx force-pushed the clang-format-option branch from adc8462 to 2e44a43 Compare April 21, 2020 21:50
@rbx rbx force-pushed the clang-format-option branch 2 times, most recently from 301f9e7 to eb06a81 Compare April 21, 2020 22:26
@rbx rbx force-pushed the clang-format-option branch from eb06a81 to e60cab2 Compare April 21, 2020 22:34
@FairRootGroup FairRootGroup deleted a comment from dennisklein Apr 21, 2020
@dennisklein dennisklein force-pushed the clang-format-option branch 5 times, most recently from 0094a3d to 263c515 Compare April 22, 2020 04:09
@dennisklein dennisklein force-pushed the clang-format-option branch 4 times, most recently from 40d2f58 to 1c027b9 Compare April 22, 2020 04:31
@dennisklein
Copy link
Member

Codacy Here is an overview of what got changed by this pull request:

Issues
======
+ Solved 21
- Added 11
           

Clones added
============
- examples/simulation/Tutorial2/src/FairTutorialDet2.cxx  1
- trackbase/FairTrackParP.h  1
- fairtools/FairMonitor.cxx  2
- parbase/FairRuntimeDb.cxx  2
- templates/project_root_containers/NewDetector/NewDetector.cxx  1
- examples/simulation/Tutorial1/src/FairFastSimExample.cxx  1
- geane/FairGeanePro.cxx  2
- examples/simulation/Tutorial1/src/FairTutorialDet1.cxx  1
- examples/simulation/Tutorial1/src/FairFastSimExample2.cxx  1
- examples/simulation/rutherford/src/FairRutherford.cxx  1
- templates/NewDetector_root_containers/NewDetector.cxx  1
- templates/project_stl_containers/NewDetector/NewDetector.cxx  1
- examples/MQ/pixelSimSplit/src/devices/FairMQChunkMerger.cxx  2
- examples/MQ/pixelDetector/src/Pixel.cxx  1
- trackbase/FairTrackParH.h  1
- examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx  1
- templates/NewDetector_stl_containers/NewDetector.cxx  1
- examples/advanced/propagator/src/FairTutPropDet.cxx  1
- trackbase/FairGeaneUtil.h  3
- examples/MQ/pixelDetector/src/devices/FairMQPixelMerger.cxx  2
         

See the complete overview on Codacy

cout << "Event number: " << eventID << "\tNtracks: " << ntracks << endl;

for (Int_t ll = 0; ll < ntracks; ll++) {
ncols = fscanf(fInputFile,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f_evt_swap_filhe(ps_bufhe);
}
if (l_prihe) {
ii = f_evt_type(ps_bufhe, NULL, 0, 0, 0, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s_server.sock_name.sin_addr.s_addr = htonl(INADDR_ANY);
s_server.sock_name.sin_port = htons(*pl_port);

retval = bind(s_server.sock_rw, (struct sockaddr*)&s_server.sock_name, sizeof(s_server.sock_name));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while (nullptr != fgets(str, 100, file)) {
if (TString(str).Contains("treename")) {
char* treename = new char[100];
if (1 == sscanf(str, "treename=%s", treename)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pMbsHeader->iType);
if (iVerbose) {
if (pMbsHeader) {
printf("ElHd: words:%d type:%08x\n", pMbsHeader->iWords, pMbsHeader->iType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (iUseOffset == LMD__INDEX) {
fLmdOffsetResize(pLmdControl, iReturn / 4);
} // create and set first value
printf("fLmdPutOpen: %s. Bytes:%d over:%d table:%d large:%d.\n", Filename, iBytes, iOver, iUseOffset, iLargeFile);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while (nullptr != fgets(str, 100, file)) {
if (TString(str).Contains("foldername")) {
char* foldername = new char[100];
if (1 == sscanf(str, "foldername=%s", foldername)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


LOG(debug) << "GOT NEW EVENT " << fMCEntryNo << " (part " << fPartNo << ") with run id = " << fRunId;
}
if (buffer.find("EVENT") == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return (GETLMD__EOFILE);
}
if (iReturn != used) {
printf("fLmdGetBuffer: LMD read error: unexpected EOF: %s %u %u\n", pLmdControl->cFile, iReturn, used);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (pbuf == NULL) {
pbuf = (char*)pLmdControl->pOffset8;
}
iReturn = fLmdWriteBuffer(pLmdControl, pbuf, (pLmdControl->iElements + 1) * pLmdControl->iOffsetSize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cout << "Event number: " << eventID << "\tNtracks: " << ntracks << endl;

for (Int_t ll = 0; ll < ntracks; ll++) {
ncols = fscanf(fInputFile,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dennisklein dennisklein changed the title WIP: Format Format Apr 22, 2020
@dennisklein
Copy link
Member

I mainly looked at the script part and less at the actual formatting. Probably not a bad idea, if someone else looks at that too.

@dennisklein dennisklein merged commit 4d90e22 into FairRootGroup:dev Apr 23, 2020
@dennisklein dennisklein added this to the v18.4 milestone Apr 23, 2020
@dennisklein dennisklein linked an issue Apr 23, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a clang-format config file and enforce it with a PR check

2 participants