loplugin:constvars in test..unotools

Change-Id: I087dc53ca5c18893974bbd9d959de56d5a4cdfa0
Reviewed-on: https://gerrit.libreoffice.org/77827
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2019-08-20 15:54:16 +02:00
parent 50a6041bfa
commit 1d4eb1be35
11 changed files with 30 additions and 30 deletions

View File

@ -24,13 +24,13 @@ namespace apitest
{ {
void FunctionDescription::testFunctionDescriptionProperties() void FunctionDescription::testFunctionDescriptionProperties()
{ {
uno::Sequence<beans::PropertyValue> aFunctionDescription(init()); const uno::Sequence<beans::PropertyValue> aFunctionDescription(init());
std::vector<OUString> names; std::vector<OUString> names;
// Only test the get/read operation of the values, because set/write operation doesn't // Only test the get/read operation of the values, because set/write operation doesn't
// make any sense. It doesn't trigger any changes. // make any sense. It doesn't trigger any changes.
// See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html. // See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
for (auto& value : aFunctionDescription) for (const auto& value : aFunctionDescription)
{ {
if (value.Name == "Id") if (value.Name == "Id")
{ {

View File

@ -27,13 +27,13 @@ namespace apitest
void SheetSortDescriptor2::testSheetSortDescriptor2Properties() void SheetSortDescriptor2::testSheetSortDescriptor2Properties()
{ {
uno::Reference<util::XSortable> xSortable(init(), UNO_QUERY_THROW); uno::Reference<util::XSortable> xSortable(init(), UNO_QUERY_THROW);
uno::Sequence<beans::PropertyValue> values = xSortable->createSortDescriptor(); const uno::Sequence<beans::PropertyValue> values = xSortable->createSortDescriptor();
std::vector<OUString> names; std::vector<OUString> names;
// Only test the get/read operation of the values, because set/write operation doesn't // Only test the get/read operation of the values, because set/write operation doesn't
// make any sense. It doesn't trigger any changes. // make any sense. It doesn't trigger any changes.
// See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html. // See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
for (auto& value : values) for (const auto& value : values)
{ {
if (value.Name == "BindFormatsToContent") if (value.Name == "BindFormatsToContent")
{ {

View File

@ -2068,7 +2068,7 @@ void VCLXToolkit::callTopWindowListeners(
{ {
css::lang::EventObject aAwtEvent( css::lang::EventObject aAwtEvent(
static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer())); static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()));
for (css::uno::Reference<XInterface> & i : aListeners) for (const css::uno::Reference<XInterface> & i : aListeners)
{ {
css::uno::Reference< css::awt::XTopWindowListener > css::uno::Reference< css::awt::XTopWindowListener >
xListener(i, css::uno::UNO_QUERY); xListener(i, css::uno::UNO_QUERY);
@ -2111,7 +2111,7 @@ bool VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(), pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(),
sal::static_int_cast< sal_Int16 >( sal::static_int_cast< sal_Int16 >(
pKeyEvent->GetKeyCode().GetFunction())); pKeyEvent->GetKeyCode().GetFunction()));
for (css::uno::Reference<XInterface> & i : aHandlers) for (const css::uno::Reference<XInterface> & i : aHandlers)
{ {
css::uno::Reference< css::awt::XKeyHandler > xHandler( css::uno::Reference< css::awt::XKeyHandler > xHandler(
i, css::uno::UNO_QUERY); i, css::uno::UNO_QUERY);
@ -2158,7 +2158,7 @@ void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent,
static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()), static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()),
static_cast<sal_Int16>(pWindow->GetGetFocusFlags()), static_cast<sal_Int16>(pWindow->GetGetFocusFlags()),
xNext, false); xNext, false);
for (css::uno::Reference<XInterface> & i : aListeners) for (const css::uno::Reference<XInterface> & i : aListeners)
{ {
css::uno::Reference< css::awt::XFocusListener > xListener( css::uno::Reference< css::awt::XFocusListener > xListener(
i, css::uno::UNO_QUERY); i, css::uno::UNO_QUERY);

View File

@ -579,7 +579,7 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent
while ( pLangDepProp->pPropName != nullptr ) while ( pLangDepProp->pPropName != nullptr )
{ {
bool bMustBeInserted( true ); bool bMustBeInserted( true );
for (PropertyValue & i : aPeerPropertiesToSet) for (const PropertyValue & i : aPeerPropertiesToSet)
{ {
if ( i.Name.equalsAsciiL( if ( i.Name.equalsAsciiL(
pLangDepProp->pPropName, pLangDepProp->nPropNameLength )) pLangDepProp->pPropName, pLangDepProp->nPropNameLength ))

View File

@ -103,7 +103,7 @@ long ButtonDialog::ImplGetButtonSize()
long nSepSize = 0; long nSepSize = 0;
maCtrlSize = Size( IMPL_MINSIZE_BUTTON_WIDTH, IMPL_MINSIZE_BUTTON_HEIGHT ); maCtrlSize = Size( IMPL_MINSIZE_BUTTON_WIDTH, IMPL_MINSIZE_BUTTON_HEIGHT );
for (auto & it : m_ItemList) for (const auto & it : m_ItemList)
{ {
nSepSize += nLastSepSize; nSepSize += nLastSepSize;
@ -203,7 +203,7 @@ void ButtonDialog::ImplPosControls()
IMPL_LINK( ButtonDialog, ImplClickHdl, Button*, pBtn, void ) IMPL_LINK( ButtonDialog, ImplClickHdl, Button*, pBtn, void )
{ {
for (auto & it : m_ItemList) for (const auto & it : m_ItemList)
{ {
if ( it->mpPushButton == pBtn ) if ( it->mpPushButton == pBtn )
{ {

View File

@ -227,7 +227,7 @@ void FTPContentProvider::forHost( const OUString& host,
OUString& account) OUString& account)
{ {
osl::MutexGuard aGuard(m_aMutex); osl::MutexGuard aGuard(m_aMutex);
for(ServerInfo & i : m_ServerInfo) for(const ServerInfo & i : m_ServerInfo)
if(host == i.host && if(host == i.host &&
port == i.port && port == i.port &&
username == i.username ) username == i.username )

View File

@ -605,7 +605,7 @@ FTPDirentry FTPURL::direntry() const
std::vector<FTPDirentry> aList = aURL.list(OpenMode::ALL); std::vector<FTPDirentry> aList = aURL.list(OpenMode::ALL);
for(FTPDirentry & d : aList) { for(const FTPDirentry & d : aList) {
if(d.m_aName == nettitle) { // the relevant file is found if(d.m_aName == nettitle) { // the relevant file is found
aDirentry = d; aDirentry = d;
break; break;

View File

@ -1334,7 +1334,7 @@ structMember:
dynamic_cast<unoidl::detail::SourceProviderPlainStructTypeEntityPad *>( dynamic_cast<unoidl::detail::SourceProviderPlainStructTypeEntityPad *>(
ent->pad.get()); ent->pad.get());
if (p1 != nullptr) { if (p1 != nullptr) {
for (auto & i: p1->members) { for (const auto & i: p1->members) {
if (id == i.name) { if (id == i.name) {
error( error(
@3, yyscanner, @3, yyscanner,
@ -1401,7 +1401,7 @@ structMember:
p2 = dynamic_cast<unoidl::detail::SourceProviderPolymorphicStructTypeTemplateEntityPad *>( p2 = dynamic_cast<unoidl::detail::SourceProviderPolymorphicStructTypeTemplateEntityPad *>(
ent->pad.get()); ent->pad.get());
if (p2 != nullptr) { if (p2 != nullptr) {
for (auto & i: p2->members) { for (const auto & i: p2->members) {
if (id == i.name) { if (id == i.name) {
error( error(
@3, yyscanner, @3, yyscanner,
@ -1420,7 +1420,7 @@ structMember:
= dynamic_cast<unoidl::detail::SourceProviderExceptionTypeEntityPad *>( = dynamic_cast<unoidl::detail::SourceProviderExceptionTypeEntityPad *>(
ent->pad.get()); ent->pad.get());
assert(p3 != nullptr); assert(p3 != nullptr);
for (auto & i: p3->members) { for (const auto & i: p3->members) {
if (id == i.name) { if (id == i.name) {
error( error(
@3, yyscanner, @3, yyscanner,
@ -1869,7 +1869,7 @@ methodParam:
default: default:
break; break;
} }
for (auto & i: pad->directMethods.back().parameters) { for (const auto & i: pad->directMethods.back().parameters) {
if (id == i.name) { if (id == i.name) {
error( error(
@5, yyscanner, @5, yyscanner,
@ -2353,7 +2353,7 @@ singleInterfaceBasedServiceDefn:
assert(pad != nullptr); assert(pad != nullptr);
std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor> ctors; std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor> ctors;
if ($7) { if ($7) {
for (auto & i: pad->constructors) { for (const auto & i: pad->constructors) {
std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter> parms; std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter> parms;
for (auto & j: i.parameters) { for (auto & j: i.parameters) {
parms.emplace_back(j.name, j.type.getName(), j.rest); parms.emplace_back(j.name, j.type.getName(), j.rest);
@ -2392,7 +2392,7 @@ ctor:
rtl::Reference<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad> rtl::Reference<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>
pad(getCurrentPad<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>( pad(getCurrentPad<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>(
data)); data));
for (auto & i: pad->constructors) { for (const auto & i: pad->constructors) {
if (id == i.name) { if (id == i.name) {
error( error(
@2, yyscanner, @2, yyscanner,
@ -2518,7 +2518,7 @@ ctorParam:
+ " rest parameter must be last parameter")); + " rest parameter must be last parameter"));
YYERROR; YYERROR;
} }
for (auto & i: pad->constructors.back().parameters) { for (const auto & i: pad->constructors.back().parameters) {
if (id == i.name) { if (id == i.name) {
error( error(
@6, yyscanner, @6, yyscanner,
@ -2630,7 +2630,7 @@ serviceBase:
std::vector<unoidl::AnnotatedReference> & v( std::vector<unoidl::AnnotatedReference> & v(
opt opt
? pad->directOptionalBaseServices : pad->directMandatoryBaseServices); ? pad->directOptionalBaseServices : pad->directMandatoryBaseServices);
for (auto & i: v) { for (const auto & i: v) {
if (name == i.name) { if (name == i.name) {
error( error(
@4, yyscanner, @4, yyscanner,
@ -2707,7 +2707,7 @@ serviceInterfaceBase:
opt opt
? pad->directOptionalBaseInterfaces ? pad->directOptionalBaseInterfaces
: pad->directMandatoryBaseInterfaces); : pad->directMandatoryBaseInterfaces);
for (auto & i: v) { for (const auto & i: v) {
if (name == i.name) { if (name == i.name) {
error( error(
@4, yyscanner, @4, yyscanner,
@ -2794,7 +2794,7 @@ serviceProperty:
rtl::Reference<unoidl::detail::SourceProviderAccumulationBasedServiceEntityPad> rtl::Reference<unoidl::detail::SourceProviderAccumulationBasedServiceEntityPad>
pad(getCurrentPad<unoidl::detail::SourceProviderAccumulationBasedServiceEntityPad>( pad(getCurrentPad<unoidl::detail::SourceProviderAccumulationBasedServiceEntityPad>(
data)); data));
for (auto & i: pad->directProperties) { for (const auto & i: pad->directProperties) {
if (id == i.name) { if (id == i.name) {
error( error(
@4, yyscanner, @4, yyscanner,
@ -3477,7 +3477,7 @@ primaryExpr:
unoidl::detail::SourceProviderEnumTypeEntityPad * p1 = dynamic_cast< unoidl::detail::SourceProviderEnumTypeEntityPad * p1 = dynamic_cast<
unoidl::detail::SourceProviderEnumTypeEntityPad *>(pad.get()); unoidl::detail::SourceProviderEnumTypeEntityPad *>(pad.get());
if (p1 != nullptr) { if (p1 != nullptr) {
for (auto & j: p1->members) { for (const auto & j: p1->members) {
if (j.name == name) { if (j.name == name) {
v = unoidl::ConstantValue(j.value); v = unoidl::ConstantValue(j.value);
found = true; found = true;
@ -3490,7 +3490,7 @@ primaryExpr:
unoidl::detail::SourceProviderConstantGroupEntityPad *>( unoidl::detail::SourceProviderConstantGroupEntityPad *>(
pad.get()); pad.get());
if (p2 != nullptr) { if (p2 != nullptr) {
for (auto & j: p2->members) { for (const auto & j: p2->members) {
if (j.name == name) { if (j.name == name) {
v = j.value; v = j.value;
found = true; found = true;
@ -3538,7 +3538,7 @@ primaryExpr:
unoidl::detail::SourceProviderConstantGroupEntityPad *>( unoidl::detail::SourceProviderConstantGroupEntityPad *>(
ent->pad.get()); ent->pad.get());
if (pad != nullptr) { if (pad != nullptr) {
for (auto & j: pad->members) { for (const auto & j: pad->members) {
if (j.name == id) { if (j.name == id) {
v = j.value; v = j.value;
found = true; found = true;

View File

@ -204,7 +204,7 @@ void insertTypeDependency(
OUString nucl(decomposeType(type, &rank, &args, &entity)); OUString nucl(decomposeType(type, &rank, &args, &entity));
if (entity) { if (entity) {
insertEntityDependency(manager, iterator, nucl, true); insertEntityDependency(manager, iterator, nucl, true);
for (auto & i: args) { for (const auto & i: args) {
insertTypeDependency(manager, iterator, i); insertTypeDependency(manager, iterator, i);
} }
} }
@ -1041,7 +1041,7 @@ SAL_IMPLEMENT_MAIN() {
scanMap(mgr, prov->createRootCursor(), published, "", ents); scanMap(mgr, prov->createRootCursor(), published, "", ents);
std::vector<OUString> sorted(sort(ents)); std::vector<OUString> sorted(sort(ents));
std::vector<OUString> mods; std::vector<OUString> mods;
for (auto & i: sorted) { for (const auto & i: sorted) {
writeEntity(ents, mods, i); writeEntity(ents, mods, i);
} }
closeModules(mods, mods.size()); closeModules(mods, mods.size());

View File

@ -713,7 +713,7 @@ sal_uInt64 writeMap(
write32(file, cmap.size()); write32(file, cmap.size());
// overflow from std::map::size_type -> sal_uInt64 is // overflow from std::map::size_type -> sal_uInt64 is
// unrealistic // unrealistic
for (auto & j: cmap) { for (const auto & j: cmap) {
write32(file, j.second.nameOffset); write32(file, j.second.nameOffset);
write32(file, j.second.dataOffset); write32(file, j.second.dataOffset);
} }
@ -846,7 +846,7 @@ sal_uInt64 writeMap(
*rootSize = map.size(); *rootSize = map.size();
// overflow from std::map::size_type -> std::size_t is unrealistic // overflow from std::map::size_type -> std::size_t is unrealistic
} }
for (auto & i: map) { for (const auto & i: map) {
write32(file, i.second.nameOffset); write32(file, i.second.nameOffset);
write32(file, i.second.dataOffset); write32(file, i.second.dataOffset);
} }

View File

@ -416,7 +416,7 @@ css::uno::Sequence < OUString > SvtModuleOptions_Impl::GetAllServiceNames()
{ {
std::vector<OUString> aVec; std::vector<OUString> aVec;
for( auto & rFactory : m_lFactories ) for( const auto & rFactory : m_lFactories )
if( rFactory.getInstalled() ) if( rFactory.getInstalled() )
aVec.push_back( rFactory.getFactory() ); aVec.push_back( rFactory.getFactory() );