Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST ONLY][Do not merge] New clang tidy checks #30508

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .clang-tidy
Expand Up @@ -5,10 +5,16 @@ Checks: -*,
,misc-uniqueptr-reset-release,
,modernize-deprecated-headers,
,modernize-make-shared,
,modernize-make-unique,
,modernize-use-bool-literals,
,modernize-use-equals-delete,
,modernize-use-nullptr,
,modernize-use-override,
,performance-inefficient-algorithm,
,performance-inefficient-vector-operation,
,performance-faster-string-find,
,performance-for-range-copy,
,performance-move-const-arg,
,performance-unnecessary-copy-initialization,
,readability-container-size-empty,
,readability-redundant-string-cstr,
Expand Down
2 changes: 1 addition & 1 deletion Alignment/CocoaFit/src/FittedEntry.cc
Expand Up @@ -44,7 +44,7 @@ FittedEntry::FittedEntry(ALIstring name, float value, float sigma) {
ALIint point = -1;
ALIint pointold = 0;
for (;;) {
point = name.find(".", point + 1);
point = name.find('.', point + 1);
if (point == -1)
break;
theOptOName += "/" + name.substr(pointold, point - pointold);
Expand Down
4 changes: 2 additions & 2 deletions Alignment/CocoaModel/src/ALIRmDataFromFile.cc
Expand Up @@ -49,8 +49,8 @@ ALIbool ALIRmDataFromFile::setAngleZ(const ALIdouble val) {

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void ALIRmDataFromFile::constructRm() {
if (theDataFilled.find("X") == std::string::npos || theDataFilled.find("Y") == std::string::npos ||
theDataFilled.find("Z") == std::string::npos) {
if (theDataFilled.find('X') == std::string::npos || theDataFilled.find('Y') == std::string::npos ||
theDataFilled.find('Z') == std::string::npos) {
std::cerr << "!!! ALIRmDataFromFile::constructRm. FATAL ERROR: building rm while one angle is missing: "
<< theDataFilled << std::endl;
} else {
Expand Down
2 changes: 1 addition & 1 deletion Alignment/CocoaModel/src/EntryMgr.cc
Expand Up @@ -123,7 +123,7 @@ EntryData* EntryMgr::findEntry(const std::vector<ALIstring>& wl) {

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ALIstring EntryMgr::extractShortName(const ALIstring& name) {
ALIint isl = name.rfind("/");
ALIint isl = name.rfind('/');
if (isl == -1) {
return name;
} else {
Expand Down
2 changes: 1 addition & 1 deletion Alignment/CocoaModel/src/MeasurementDiffEntry.cc
Expand Up @@ -28,7 +28,7 @@ void MeasurementDiffEntry::buildOptONamesList(const std::vector<ALIstring>& wl)
//--------- Fill list with names
for (int ii = 0; ii < NPairs; ii++) {
//--- take out Entry names from object names
int isl = wl[ii * 2].rfind("/");
int isl = wl[ii * 2].rfind('/');
AddOptONameListItem(wl[ii * 2].substr(0, isl));
// Check for separating '&'
if (ii != NPairs - 1 && wl[2 * ii + 1] != ALIstring("&")) {
Expand Down
6 changes: 3 additions & 3 deletions Alignment/CocoaModel/src/Model.cc
Expand Up @@ -1421,9 +1421,9 @@ void Model::copyMeasurements(const std::vector<ALIstring>& wl) {

//----- get list of Measurement's that satisfy the query in their name
//t std::string querystr = wl[1].substr( wl[1].find("/")+1, wl[1].length() );
std::string subsstr1 = wl[1].substr(0, wl[1].find("/"));
std::string subsstr2 = wl[1].substr(wl[1].find("/") + 1, wl[1].rfind("/") - wl[1].find("/") - 1);
std::string querystr = wl[1].substr(wl[1].rfind("/") + 1, wl[1].length());
std::string subsstr1 = wl[1].substr(0, wl[1].find('/'));
std::string subsstr2 = wl[1].substr(wl[1].find('/') + 1, wl[1].rfind('/') - wl[1].find('/') - 1);
std::string querystr = wl[1].substr(wl[1].rfind('/') + 1, wl[1].length());

std::cout << " Model::copyMeasurements "
<< " subsstr1 " << subsstr1 << " subsstr2 " << subsstr2 << " querystr " << querystr << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion Alignment/CocoaToDDL/src/UnitConverter.cc
Expand Up @@ -34,7 +34,7 @@ std::string UnitConverter::ucstring() {
} else {
str << *bu_ << '\0';
std::string s(str.str());
return s.replace(s.find(" "), 1, "*");
return s.replace(s.find(' '), 1, "*");
}
//return s;
}
Expand Down
12 changes: 6 additions & 6 deletions Alignment/CommonAlignmentMonitor/src/AlignmentMonitorBase.cc
Expand Up @@ -69,21 +69,21 @@ void AlignmentMonitorBase::duringLoop(const edm::Event &iEvent,
void AlignmentMonitorBase::endOfLoop() { afterAlignment(); }

TFileDirectory *AlignmentMonitorBase::directory(std::string dir) {
std::string::size_type lastPos = dir.find_first_not_of("/", 0);
std::string::size_type pos = dir.find_first_of("/", lastPos);
std::string::size_type lastPos = dir.find_first_not_of('/', 0);
std::string::size_type pos = dir.find_first_of('/', lastPos);
std::vector<std::string> dirs;

bool isIter = false;
if (dir.substr(lastPos, pos - lastPos) == std::string("iterN")) {
isIter = true;
lastPos = dir.find_first_not_of("/", pos);
pos = dir.find_first_of("/", lastPos);
lastPos = dir.find_first_not_of('/', pos);
pos = dir.find_first_of('/', lastPos);
}

while (std::string::npos != pos || std::string::npos != lastPos) {
dirs.push_back(dir.substr(lastPos, pos - lastPos));
lastPos = dir.find_first_not_of("/", pos);
pos = dir.find_first_of("/", lastPos);
lastPos = dir.find_first_not_of('/', pos);
pos = dir.find_first_of('/', lastPos);
}

std::map<std::vector<std::string>, TFileDirectory *> *theMap;
Expand Down
22 changes: 13 additions & 9 deletions Alignment/OfflineValidation/bin/DMRtrends.cc
Expand Up @@ -371,7 +371,7 @@ void DMRtrends(vector<int> IOVlist,
exit(EXIT_FAILURE);
}
}
for (TString Variable : Variables) {
for (const auto &Variable : Variables) {
compileDMRTrends(IOVlist, Variable, labels, Year, myValidation, geometries, showlumi, FORCE);
cout << "Begin plotting" << endl;
PlotDMRTrends(IOVlist,
Expand Down Expand Up @@ -406,7 +406,7 @@ void compileDMRTrends(vector<int> IOVlist,
TRegexp regexp("[0-9][0-9][0-9][0-9][0-9][0-9]");
for (const auto &entry : fs::recursive_directory_iterator(myValidation)) {
bool found_all_labels = true;
for (string label : labels) {
for (const string &label : labels) {
if (entry.path().string().find(label) == std::string::npos)
found_all_labels = false;
}
Expand Down Expand Up @@ -449,7 +449,7 @@ void compileDMRTrends(vector<int> IOVlist,
map<pair<pair<TString, int>, TString>, Geometry> mappoints; // pair = (structure, layer), geometry

std::sort(filenames.begin(), filenames.end()); //order the files in alphabetical order
for (TString filename : filenames) {
for (const TString &filename : filenames) {
int runN;
TString runstring(filename(regexp));
if (runstring.IsFloat()) {
Expand All @@ -466,7 +466,7 @@ void compileDMRTrends(vector<int> IOVlist,
structname.ReplaceAll("_y", "");
size_t layersnumber = nlayers.at(structname);
for (size_t layer = 0; layer <= layersnumber; layer++) {
for (string geometry : geometries) {
for (const string &geometry : geometries) {
TString name = Variable + "_" + getName(structure, layer, geometry);
TH1F *histo = dynamic_cast<TH1F *>(f->Get(name));
//Geometry *geom =nullptr;
Expand Down Expand Up @@ -502,7 +502,7 @@ void compileDMRTrends(vector<int> IOVlist,
f->Close();
}
TString outname = myValidation + "DMRtrends";
for (TString label : labels) {
for (const auto &label : labels) {
outname += "_";
outname += label;
}
Expand All @@ -514,7 +514,7 @@ void compileDMRTrends(vector<int> IOVlist,
structname.ReplaceAll("_y", "");
size_t layersnumber = nlayers.at(structname);
for (size_t layer = 0; layer <= layersnumber; layer++) {
for (string geometry : geometries) {
for (const string &geometry : geometries) {
TString name = Variable + "_" + getName(structure, layer, geometry);
Geometry geom = mappoints[make_pair(make_pair(structure, layer), geometry)];
using Trend = vector<float> (Geometry::*)() const;
Expand Down Expand Up @@ -808,7 +808,7 @@ void PlotDMRTrends(vector<int> IOVlist,
lumiIOVpairs = lumiperIOV(IOVlist, Year);

TString filename = myValidation + "DMRtrends";
for (TString label : labels) {
for (const auto &label : labels) {
filename += "_";
filename += label;
}
Expand Down Expand Up @@ -875,7 +875,7 @@ void PlotDMRTrends(vector<int> IOVlist,
TMultiGraph *mg = new TMultiGraph(structure, structure);
THStack *mh = new THStack(structure, structure);
size_t igeom = 0;
for (string geometry : geometries) {
for (const string &geometry : geometries) {
TString name = Variable + "_" + getName(structure, layer, geometry);
TGraphErrors *g = dynamic_cast<TGraphErrors *>(in->Get(name + "_" + variables.at(i)));
g->SetName(name + "_" + variables.at(i));
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void PlotDMRTrends(vector<int> IOVlist,
TString printfile = outputdir;
if (!(outputdir.EndsWith("/")))
outputdir += "/";
for (TString label : labels) {
for (const auto &label : labels) {
printfile += label;
printfile += "_";
}
Expand Down Expand Up @@ -1097,18 +1097,22 @@ int main(int argc, char *argv[]) {
bool showpixelupdate = argv[9], showlumi = argv[10], FORCE = argv[11];
TObjArray *vararray = all_variables.Tokenize(",");
vector<string> Variables;
Variables.reserve(vararray->GetEntries());
for (int i = 0; i < vararray->GetEntries(); i++)
Variables.push_back((string)(vararray->At(i)->GetName()));
TObjArray *labelarray = all_labels.Tokenize(",");
vector<string> labels;
labels.reserve(labelarray->GetEntries());
for (int i = 0; i < labelarray->GetEntries(); i++)
labels.push_back((string)(labelarray->At(i)->GetName()));
TObjArray *IOVarray = runlist.Tokenize(",");
vector<int> IOVlist;
IOVlist.reserve(IOVarray->GetEntries());
for (int i = 0; i < IOVarray->GetEntries(); i++)
IOVlist.push_back(stoi(IOVarray->At(i)->GetName()));
vector<int> pixelupdateruns;
TObjArray *PIXarray = pixelupdatelist.Tokenize(",");
pixelupdateruns.reserve(PIXarray->GetEntries());
for (int i = 0; i < PIXarray->GetEntries(); i++)
pixelupdateruns.push_back(stoi(PIXarray->At(i)->GetName()));
vector<string> geometries;
Expand Down
22 changes: 11 additions & 11 deletions Alignment/OfflineValidation/plugins/PrimaryVertexValidation.cc
Expand Up @@ -106,24 +106,24 @@ PrimaryVertexValidation::PrimaryVertexValidation(const edm::ParameterSet& iConfi
theBeamspotToken = consumes<reco::BeamSpot>(BeamspotTag_);

// select and configure the track filter
theTrackFilter_ = std::unique_ptr<TrackFilterForPVFinding>(
new TrackFilterForPVFinding(iConfig.getParameter<edm::ParameterSet>("TkFilterParameters")));
theTrackFilter_ =
std::make_unique<TrackFilterForPVFinding>(iConfig.getParameter<edm::ParameterSet>("TkFilterParameters"));
// select and configure the track clusterizer
std::string clusteringAlgorithm =
iConfig.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<std::string>("algorithm");
if (clusteringAlgorithm == "gap") {
theTrackClusterizer_ = std::unique_ptr<GapClusterizerInZ>(
new GapClusterizerInZ(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkGapClusParameters")));
theTrackClusterizer_ =
std::make_unique<GapClusterizerInZ>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkGapClusParameters"));
} else if (clusteringAlgorithm == "DA") {
theTrackClusterizer_ = std::unique_ptr<DAClusterizerInZ>(
new DAClusterizerInZ(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkDAClusParameters")));
theTrackClusterizer_ =
std::make_unique<DAClusterizerInZ>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkDAClusParameters"));
// provide the vectorized version of the clusterizer, if supported by the build
} else if (clusteringAlgorithm == "DA_vect") {
theTrackClusterizer_ = std::unique_ptr<DAClusterizerInZ_vect>(
new DAClusterizerInZ_vect(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkDAClusParameters")));
theTrackClusterizer_ =
std::make_unique<DAClusterizerInZ_vect>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkDAClusParameters"));
} else {
throw VertexException("PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
}
Expand Down
Expand Up @@ -176,7 +176,7 @@ class TrackerOfflineValidation : public edm::EDAnalyzer {
if (newDir.length() == 0)
tfd.reset(&(*upDir.tfd));
else
tfd.reset(new TFileDirectory(upDir.tfd->mkdir(newDir)));
tfd = std::make_unique<TFileDirectory>(upDir.tfd->mkdir(newDir));
} else {
theDbe = edm::Service<DQMStore>().operator->();
}
Expand All @@ -187,9 +187,9 @@ class TrackerOfflineValidation : public edm::EDAnalyzer {
if (!dqmMode) {
edm::Service<TFileService> fs;
if (newDir.length() == 0) {
tfd.reset(new TFileDirectory(fs->tFileDirectory()));
tfd = std::make_unique<TFileDirectory>(fs->tFileDirectory());
} else {
tfd.reset(new TFileDirectory(fs->mkdir(newDir)));
tfd = std::make_unique<TFileDirectory>(fs->mkdir(newDir));
directoryString = newDir;
}
} else {
Expand Down
Expand Up @@ -222,6 +222,7 @@ GeomDetEnumerators::SubDetector CreateIdealTkAlRecords::toSubDetector(const std:
std::vector<GeomDetEnumerators::SubDetector> CreateIdealTkAlRecords::toSubDetectors(
const std::vector<std::string>& subs) {
std::vector<GeomDetEnumerators::SubDetector> result;
result.reserve(subs.size());
for (const auto& sub : subs)
result.emplace_back(toSubDetector(sub));
return result;
Expand Down
6 changes: 3 additions & 3 deletions Alignment/TrackerAlignment/plugins/MCMisalignmentScaler.cc
Expand Up @@ -205,7 +205,7 @@ void MCMisalignmentScaler::analyze(const edm::Event&, const edm::EventSetup& iSe
(*ideal)->rotation().zz() + scaleFactor * zz_diff}};

const AlignTransform rescaledTransform{rescaledTranslation, rescaledRotation, misaligned->rawId()};
rescaledAlignments.m_align.emplace_back(std::move(rescaledTransform));
rescaledAlignments.m_align.emplace_back(rescaledTransform);
}
}

Expand All @@ -232,9 +232,9 @@ MCMisalignmentScaler::ScalerMap MCMisalignmentScaler::decodeSubDetectors(const e
const auto& factor = pset.getUntrackedParameter<double>("factor");

std::vector<int> sides;
if (name.find("-") != std::string::npos)
if (name.find('-') != std::string::npos)
sides.push_back(1);
if (name.find("+") != std::string::npos)
if (name.find('+') != std::string::npos)
sides.push_back(2);
if (sides.empty()) { // -> use both sides
sides.push_back(1);
Expand Down
2 changes: 1 addition & 1 deletion CalibCalorimetry/EcalLaserSorting/src/LmfSource.cc
Expand Up @@ -446,7 +446,7 @@ void LmfSource::checkFileNames() {
if (fileName.compare(0, sizeof(s) - 1, s) == 0) { //file: prefix => to strip
fileName.erase(fileName.begin(), fileName.begin() + sizeof(s) - 1);
}
if (fileName.find_first_of(":") != string::npos) {
if (fileName.find_first_of(':') != string::npos) {
throw cms::Exception("LmfSource") << "Character ':' is not allowed in paths specified fileNames "
<< "parameter. Please note only local file (or NFS, AFS)"
<< " is supported (no rfio, no /store)";
Expand Down
15 changes: 8 additions & 7 deletions CalibCalorimetry/EcalLaserSorting/src/WatcherStreamFileReader.cc
Expand Up @@ -5,16 +5,17 @@

#include <cerrno>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <libgen.h>
#include <fstream>
#include <libgen.h>
#include <memory>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

//using namespace edm;
using namespace std;
Expand Down Expand Up @@ -376,7 +377,7 @@ edm::StreamerInputFile* WatcherStreamFileReader::getInputFile() {
cout << "[WatcherSource " << now() << "]"
<< " Opening file " << fileName_ << "\n"
<< flush;
streamerInputFile_ = unique_ptr<edm::StreamerInputFile>(new edm::StreamerInputFile(fileName_));
streamerInputFile_ = std::make_unique<edm::StreamerInputFile>(fileName_);

ofstream f(".watcherfile");
f << fileName_;
Expand Down
Expand Up @@ -2,8 +2,10 @@
// Created: 2 Mar 2006
// Shahram Rahatlou, University of Rome & INFN
//
#include <iostream>
#include <fstream>
#include <iostream>
#include <memory>

#include "TRandom3.h"

#include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"
Expand Down Expand Up @@ -3437,7 +3439,7 @@ std::unique_ptr<Alignments> EcalTrivialConditionRetriever::produceEcalAlignmentE
}

std::unique_ptr<EcalSampleMask> EcalTrivialConditionRetriever::produceEcalSampleMask(const EcalSampleMaskRcd&) {
return std::unique_ptr<EcalSampleMask>(new EcalSampleMask(sampleMaskEB_, sampleMaskEE_));
return std::make_unique<EcalSampleMask>(sampleMaskEB_, sampleMaskEE_);
}

std::unique_ptr<EcalTimeBiasCorrections> EcalTrivialConditionRetriever::produceEcalTimeBiasCorrections(
Expand Down
Expand Up @@ -48,7 +48,7 @@ void HcalPulseContainmentTest::analyze(const edm::Event& iEvent, const edm::Even
float fixedphase_ns = 6.0;
float max_fracerror = 0.02;
std::unique_ptr<HcalPulseContainmentManager> manager;
manager = std::unique_ptr<HcalPulseContainmentManager>(new HcalPulseContainmentManager(max_fracerror));
manager = std::make_unique<HcalPulseContainmentManager>(max_fracerror);
manager->setTimeSlew(hcalTimeSlew_delay_);

HcalDetId hb1(HcalBarrel, 1, 1, 1);
Expand Down
7 changes: 7 additions & 0 deletions CalibCalorimetry/HcalAlgos/src/HcalLogicalMapGenerator.cc
Expand Up @@ -64,18 +64,25 @@ HcalLogicalMap HcalLogicalMapGenerator::createMap(const HcalTopology* topo, unsi
uint32_t illegal_value = 0;
for (int i = 0; i <= HcalElectronicsId::maxLinearIndex; i++)
LinearIndex2Entry.push_back(illegal_value);
HbHash2Entry.reserve(2 * HbHalf);
for (int iHb = 0; iHb < 2 * HbHalf; iHb++)
HbHash2Entry.push_back(illegal_value);
HeHash2Entry.reserve(2 * HeHalf);
for (int iHe = 0; iHe < 2 * HeHalf; iHe++)
HeHash2Entry.push_back(illegal_value);
HfHash2Entry.reserve(2 * HfHalf);
for (int iHf = 0; iHf < 2 * HfHalf; iHf++)
HfHash2Entry.push_back(illegal_value);
HtHash2Entry.reserve(2 * HtHalf);
for (int iHt = 0; iHt < 2 * HtHalf; iHt++)
HtHash2Entry.push_back(illegal_value);
HoHash2Entry.reserve(2 * HoHalf);
for (int iHo = 0; iHo < 2 * HoHalf; iHo++)
HoHash2Entry.push_back(illegal_value);
HxCalibHash2Entry.reserve(CalibFull);
for (int iHcalib = 0; iHcalib < CalibFull; iHcalib++)
HxCalibHash2Entry.push_back(illegal_value);
ZdcHash2Entry.reserve(2 * ZdcHalf);
for (int iZdc = 0; iZdc < 2 * ZdcHalf; iZdc++)
ZdcHash2Entry.push_back(illegal_value);

Expand Down