clang-tidy: Use auto where it improves the readability

run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-auto' \
-config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
-fix

Manually fixed some wrong `const auto` replacements and verified
that all types are deduced correctly.
This commit is contained in:
Urs Fleisch
2023-07-16 06:13:34 +02:00
parent 63922f2676
commit c2c9e8989c
57 changed files with 289 additions and 299 deletions

View File

@ -65,11 +65,11 @@ int main(int argc, char *argv[])
<< " bytes in tag"
<< endl;
ID3v2::FrameList::ConstIterator it = id3v2tag->frameList().begin();
auto it = id3v2tag->frameList().begin();
for(; it != id3v2tag->frameList().end(); it++) {
cout << (*it)->frameID();
if(ID3v2::CommentsFrame *comment = dynamic_cast<ID3v2::CommentsFrame *>(*it))
if(auto comment = dynamic_cast<ID3v2::CommentsFrame *>(*it))
if(!comment->description().isEmpty())
cout << " [" << comment->description() << "]";
@ -100,7 +100,7 @@ int main(int argc, char *argv[])
cout << endl << "APE" << endl;
if(ape) {
for(APE::ItemListMap::ConstIterator it = ape->itemListMap().begin();
for(auto it = ape->itemListMap().begin();
it != ape->itemListMap().end(); ++it)
{
if((*it).second.type() != APE::Item::Binary)

View File

@ -56,15 +56,15 @@ int main(int argc, char *argv[])
TagLib::PropertyMap tags = f.file()->properties();
unsigned int longest = 0;
for(TagLib::PropertyMap::ConstIterator i = tags.cbegin(); i != tags.cend(); ++i) {
for(auto i = tags.cbegin(); i != tags.cend(); ++i) {
if (i->first.size() > longest) {
longest = i->first.size();
}
}
cout << "-- TAG (properties) --" << endl;
for(TagLib::PropertyMap::ConstIterator i = tags.cbegin(); i != tags.cend(); ++i) {
for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j) {
for(auto i = tags.cbegin(); i != tags.cend(); ++i) {
for(auto j = i->second.begin(); j != i->second.end(); ++j) {
cout << left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << endl;
}
}

View File

@ -79,14 +79,14 @@ void checkForRejectedProperties(const TagLib::PropertyMap &tags)
{ // stolen from tagreader.cpp
if(tags.size() > 0) {
unsigned int longest = 0;
for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
for(auto i = tags.begin(); i != tags.end(); ++i) {
if(i->first.size() > longest) {
longest = i->first.size();
}
}
cout << "-- rejected TAGs (properties) --" << endl;
for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j) {
for(auto i = tags.begin(); i != tags.end(); ++i) {
for(auto j = i->second.begin(); j != i->second.end(); ++j) {
cout << left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << endl;
}
}