Code checks
CMSSW can run code checks via clang-tidy in scram. The default list is here: https://github.com/cms-sw/cmssw/blob/master/.clang-tidy
I added a few more: cppcoreguidelines-pro-type-member-init, modernize-loop-convert
and then ran over TreeMaker source code as follows:
touch TreeMakerCode.txt
find TreeMaker/ -name "*.h" >> TreeMakerCode.txt
find TreeMaker/ -name "*.cc" >> TreeMakerCode.txt
env USER_CODE_CHECKS_FILE=TreeMakerCode.txt scram b code-checks
The code is automatically updated to conform to the specified code checks.
A few caveats about modernize-loop-convert
:
- doesn't always use
const
where it could - sometimes chooses unclear names for loop variables
- doesn't seem to recognize range-based loops for
edm::View
types
I dealt with these few issues by hand.
Merge request reports
Activity
62 62 vector<TreeTypes> VarTypes; 63 63 map<string,unsigned> nameCache; 64 64 // general event information 65 UInt_t runNum; 66 UInt_t lumiBlockNum; 67 ULong64_t evtNum; 65 UInt_t runNum{}; 142 142 double dpnhat[3]; 143 143 unsigned int goodcount=0; 144 144 145 for(int i=0; i<3; ++i)dpnhat[i]=-999; 145 for(double & i : dpnhat)i=-999; 220 220 auto htp5 = std::make_unique<double>(dpnhat[2]); 221 221 iEvent.put(std::move(htp5),"DeltaPhiN3"); 222 222 float mindpn=9999; 223 for(int i=0; i<3; ++i){ 224 if(mindpn>fabs(dpnhat[i]))mindpn=fabs(dpnhat[i]); 223 for(double i : dpnhat){ 62 62 vector<TreeTypes> VarTypes; 63 63 map<string,unsigned> nameCache; 64 64 // general event information 65 UInt_t runNum; 66 UInt_t lumiBlockNum; 67 ULong64_t evtNum; 65 UInt_t runNum{}; 142 142 double dpnhat[3]; 143 143 unsigned int goodcount=0; 144 144 145 for(int i=0; i<3; ++i)dpnhat[i]=-999; 145 for(double & i : dpnhat)i=-999; 142 142 double dpnhat[3]; 143 143 unsigned int goodcount=0; 144 144 145 for(int i=0; i<3; ++i)dpnhat[i]=-999; 145 for(double & i : dpnhat)i=-999;
Please register or sign in to reply