diff --git a/src/calamares/progresstree/ProgressTreeModel.cpp b/src/calamares/progresstree/ProgressTreeModel.cpp
index 530b427961e56377d6bb3cc637456b4a0cf0b07a..dbe8315eb6b6b94afd71f2072dc7dcdd6a0a09bd 100644
--- a/src/calamares/progresstree/ProgressTreeModel.cpp
+++ b/src/calamares/progresstree/ProgressTreeModel.cpp
@@ -132,7 +132,8 @@ ProgressTreeModel::setupModelData()
     m_rootItem = new ProgressTreeRoot();
     const Calamares::ViewManager* vm = Calamares::ViewManager::instance();
 
-    foreach ( const Calamares::ViewStep* step, vm->viewSteps() )
+    const auto steps = vm->viewSteps();
+    for ( const Calamares::ViewStep* step : steps )
     {
         m_rootItem->appendChild( new ViewStepItem( step, m_rootItem ) );
     }
diff --git a/src/libcalamares/GlobalStorage.cpp b/src/libcalamares/GlobalStorage.cpp
index 69edafa0725dd07343188c30c5517dbc270830a6..5cef6f931c8a168dc73ce566561621c7c38214ec 100644
--- a/src/libcalamares/GlobalStorage.cpp
+++ b/src/libcalamares/GlobalStorage.cpp
@@ -118,7 +118,8 @@ bp::list
 GlobalStoragePythonWrapper::keys() const
 {
     bp::list pyList;
-    foreach( const QString& key, m_gs->keys() )
+    const auto keys = m_gs->keys();
+    for ( const QString& key : keys )
         pyList.append( key.toStdString() );
     return pyList;
 }
diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp
index 40d476e337d98a54e0a21404f90394ede87cebca..51bb03228dfb4bc382a548f9fb11fb33f2f22fba 100644
--- a/src/libcalamares/PythonHelper.cpp
+++ b/src/libcalamares/PythonHelper.cpp
@@ -97,7 +97,7 @@ boost::python::list
 variantListToPyList( const QVariantList& variantList )
 {
     bp::list pyList;
-    foreach ( const QVariant& variant, variantList )
+    for ( const QVariant& variant : variantList )
         pyList.append( variantToPyObject( variant ) );
     return pyList;
 }
diff --git a/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.cpp b/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.cpp
index cd76f881183c28614716214bc873698fb3168d32..6b2a2e13ac20981cc907f00288356cebfeae906f 100644
--- a/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.cpp
+++ b/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.cpp
@@ -390,7 +390,7 @@ void ProcessInfo::setArguments( const QStringList & arguments )
         return;
 
     size_t totalsize = MarkerSize;
-    Q_FOREACH( const QString& arg, arguments )
+    for ( const QString& arg : arguments )
     {
         const QByteArray utf8 = arg.toUtf8();
         totalsize += utf8.size() + MarkerSize;
@@ -406,7 +406,7 @@ void ProcessInfo::setArguments( const QStringList & arguments )
     char* const commandline = this->commandline + reinterpret_cast<qptrdiff>(reg->commandLines);
 
     int argpos = 0;
-    Q_FOREACH( const QString & arg, arguments )
+    for ( const QString & arg : arguments )
     {
         const QByteArray utf8 = arg.toUtf8();
         const int required = MarkerSize + utf8.size() + MarkerSize ;
diff --git a/src/libcalamares/utils/CalamaresUtils.cpp b/src/libcalamares/utils/CalamaresUtils.cpp
index 6cb66dfea990f2d25d22bd04fbd983443f30e661..7685a701826c5d95f1c7c5e5f057914bd28b73a0 100644
--- a/src/libcalamares/utils/CalamaresUtils.cpp
+++ b/src/libcalamares/utils/CalamaresUtils.cpp
@@ -273,7 +273,7 @@ removeDiacritics( const QString& string )
     };
 
     QString output;
-    foreach ( QChar c, string )
+    for ( const QChar &c : string )
     {
         int i = diacriticLetters.indexOf( c );
         if ( i < 0 )
diff --git a/src/libcalamares/utils/Retranslator.cpp b/src/libcalamares/utils/Retranslator.cpp
index d0aa03e835bf97dbd2b2478f7dfad6bef6b0ac38..1f498293704a1a5e71523047bbbe531dc189c4a0 100644
--- a/src/libcalamares/utils/Retranslator.cpp
+++ b/src/libcalamares/utils/Retranslator.cpp
@@ -29,7 +29,7 @@ Retranslator::attachRetranslator( QObject* parent,
                                   std::function< void ( void ) > retranslateFunc )
 {
     Retranslator* r = nullptr;
-    foreach ( QObject* child, parent->children() )
+    for ( QObject* child : parent->children() )
     {
         r = qobject_cast< Retranslator* >( child );
         if ( r )
diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp
index b6cf0932188e91b4fe04eaed1702cbb8dcf162f4..8814b1b7ecfb02de9285948fb888b98224df7c17 100644
--- a/src/libcalamaresui/Branding.cpp
+++ b/src/libcalamaresui/Branding.cpp
@@ -44,7 +44,7 @@ Branding::instance()
 }
 
 
-QStringList Branding::s_stringEntryStrings =
+const QStringList Branding::s_stringEntryStrings =
 {
     "productName",
     "version",
@@ -60,14 +60,14 @@ QStringList Branding::s_stringEntryStrings =
 };
 
 
-QStringList Branding::s_imageEntryStrings =
+const QStringList Branding::s_imageEntryStrings =
 {
     "productLogo",
     "productIcon",
     "productWelcome"
 };
 
-QStringList Branding::s_styleEntryStrings =
+const QStringList Branding::s_styleEntryStrings =
 {
     "sidebarBackground",
     "sidebarText",
@@ -268,7 +268,7 @@ void
 Branding::setGlobals( GlobalStorage* globalStorage ) const
 {
     QVariantMap brandingMap;
-    foreach ( const QString& key, s_stringEntryStrings )
+    for ( const QString& key : s_stringEntryStrings )
         brandingMap.insert( key, m_strings.value( key ) );
     globalStorage->insert( "branding", brandingMap );
 }
diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h
index 45afc8531cb13968ab94e69c48f03ed0dc8fa9c6..09e12ecda6069d4fb63d2708e4cfb06624db4860 100644
--- a/src/libcalamaresui/Branding.h
+++ b/src/libcalamaresui/Branding.h
@@ -91,9 +91,9 @@ public:
 private:
     static Branding* s_instance;
 
-    static QStringList s_stringEntryStrings;
-    static QStringList s_imageEntryStrings;
-    static QStringList s_styleEntryStrings;
+    static const QStringList s_stringEntryStrings;
+    static const QStringList s_imageEntryStrings;
+    static const QStringList s_styleEntryStrings;
 
     void bail( const QString& message );
 
diff --git a/src/libcalamaresui/Settings.cpp b/src/libcalamaresui/Settings.cpp
index 362ea1b45878e34ed70135c0d7639f5cdc043562..102026a33590a5e7b9785cb154119f491b14b37e 100644
--- a/src/libcalamaresui/Settings.cpp
+++ b/src/libcalamaresui/Settings.cpp
@@ -98,7 +98,8 @@ Settings::Settings( const QString& settingsFilePath,
                         = CalamaresUtils::yamlToVariant( config[ "instances" ] ).toList();
                 if ( instancesV.type() == QVariant::List )
                 {
-                    foreach ( const QVariant& instancesVListItem, instancesV.toList() )
+                    const auto instances = instancesV.toList();
+                    for ( const QVariant& instancesVListItem : instances )
                     {
                         if ( instancesVListItem.type() != QVariant::Map )
                             continue;
@@ -123,7 +124,8 @@ Settings::Settings( const QString& settingsFilePath,
                 QVariant sequenceV
                         = CalamaresUtils::yamlToVariant( config[ "sequence" ] );
                 Q_ASSERT( sequenceV.type() == QVariant::List );
-                foreach ( const QVariant& sequenceVListItem, sequenceV.toList() )
+                const auto sequence = sequenceV.toList();
+                for ( const QVariant& sequenceVListItem : sequence )
                 {
                     if ( sequenceVListItem.type() != QVariant::Map )
                         continue;
diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp
index 913414bff80db6e20ae877c840549c6213093a5f..109882692e13614c99e9966eb883fca549ebc517 100644
--- a/src/libcalamaresui/modulesystem/ModuleManager.cpp
+++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp
@@ -77,13 +77,13 @@ ModuleManager::doInit()
     // the module name, and must contain a settings file named module.desc.
     // If at any time the module loading procedure finds something unexpected, it
     // silently skips to the next module or search path. --Teo 6/2014
-    foreach ( const QString& path, m_paths )
+    for ( const QString& path : m_paths )
     {
         QDir currentDir( path );
         if ( currentDir.exists() && currentDir.isReadable() )
         {
-            QStringList subdirs = currentDir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot );
-            foreach ( const QString& subdir, subdirs )
+            const QStringList subdirs = currentDir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot );
+            for ( const QString& subdir : subdirs )
             {
                 currentDir.setPath( path );
                 bool success = currentDir.cd( subdir );
@@ -179,8 +179,8 @@ ModuleManager::loadModules()
         QList< QMap< QString, QString > > customInstances =
                 Settings::instance()->customModuleInstances();
 
-        for ( const QPair< ModuleAction, QStringList >& modulePhase :
-                  Settings::instance()->modulesSequence() )
+        const auto modulesSequence = Settings::instance()->modulesSequence();
+        for ( const auto &modulePhase : modulesSequence )
         {
             ModuleAction currentAction = modulePhase.first;
 
diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h
index 7c70e66216fb7a7cea3875dba4fd4678ed742eeb..7aa3ca418edaf5aadc5b904f5c77611353b47de2 100644
--- a/src/libcalamaresui/modulesystem/ModuleManager.h
+++ b/src/libcalamaresui/modulesystem/ModuleManager.h
@@ -66,7 +66,7 @@ private:
     QMap< QString, QVariantMap > m_availableDescriptorsByModuleName;
     QMap< QString, QString > m_moduleDirectoriesByModuleName;
     QMap< QString, Module* > m_loadedModulesByInstanceKey;
-    QStringList m_paths;
+    const QStringList m_paths;
 
     static ModuleManager* s_instance;
 };
diff --git a/src/libcalamaresui/modulesystem/ViewModule.cpp b/src/libcalamaresui/modulesystem/ViewModule.cpp
index c153000da62c685a5483b5926358c0c33ba4802b..b7a94d0ea59fe5af037db0455b6166df6e837b84 100644
--- a/src/libcalamaresui/modulesystem/ViewModule.cpp
+++ b/src/libcalamaresui/modulesystem/ViewModule.cpp
@@ -95,10 +95,10 @@ ViewModule::initFrom( const QVariantMap& moduleDescriptor )
     // If a load path is not specified, we look for a plugin to load in the directory.
     if ( load.isEmpty() || !QLibrary::isLibrary( load ) )
     {
-        QStringList ls = directory.entryList( QStringList{ "*.so" } );
+        const QStringList ls = directory.entryList( QStringList{ "*.so" } );
         if ( !ls.isEmpty() )
         {
-            foreach ( QString entry, ls )
+            for ( QString entry : ls )
             {
                 entry = directory.absoluteFilePath( entry );
                 if ( QLibrary::isLibrary( entry ) )
diff --git a/src/libcalamaresui/utils/DebugWindow.cpp b/src/libcalamaresui/utils/DebugWindow.cpp
index 504a56b6e304bb9609f9624526678518c0689b79..879ef3e46444eef5423835b4fa9a9d99993b22f2 100644
--- a/src/libcalamaresui/utils/DebugWindow.cpp
+++ b/src/libcalamaresui/utils/DebugWindow.cpp
@@ -59,7 +59,7 @@ DebugWindow::DebugWindow()
              this, [ this ]( const QList< Calamares::job_ptr >& jobs )
     {
         QStringList text;
-        foreach( auto job, jobs )
+        for ( const auto &job : jobs )
         {
             text.append( job->prettyName() );
         }
diff --git a/src/libcalamaresui/utils/PluginFactory.cpp b/src/libcalamaresui/utils/PluginFactory.cpp
index 2834e5b4a7b37713efa3772b8d10a0cfda5be1ab..30a5bf4bf9e2b8a27f9d360ea1a3aeb016b8160e 100644
--- a/src/libcalamaresui/utils/PluginFactory.cpp
+++ b/src/libcalamaresui/utils/PluginFactory.cpp
@@ -66,10 +66,10 @@ void PluginFactory::doRegisterPlugin(const QString &keyword, const QMetaObject *
         }
         d->createInstanceHash.insert(keyword, PluginFactoryPrivate::Plugin(metaObject, instanceFunction));
     } else {
-        QList<PluginFactoryPrivate::Plugin> clashes(d->createInstanceHash.values(keyword));
+        const QList<PluginFactoryPrivate::Plugin> clashes(d->createInstanceHash.values(keyword));
         const QMetaObject *superClass = metaObject->superClass();
         if (superClass) {
-            foreach (const PluginFactoryPrivate::Plugin &plugin, clashes) {
+            for (const PluginFactoryPrivate::Plugin &plugin : clashes) {
                 for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper;
                         otherSuper = otherSuper->superClass()) {
                     if (superClass == otherSuper) {
@@ -78,7 +78,7 @@ void PluginFactory::doRegisterPlugin(const QString &keyword, const QMetaObject *
                 }
             }
         }
-        foreach (const PluginFactoryPrivate::Plugin &plugin, clashes) {
+        for (const PluginFactoryPrivate::Plugin &plugin : clashes) {
             superClass = plugin.first->superClass();
             if (superClass) {
                 for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper;
@@ -102,7 +102,7 @@ QObject *PluginFactory::create(const char *iface, QWidget *parentWidget, QObject
     const QList<PluginFactoryPrivate::Plugin> candidates(d->createInstanceHash.values(keyword));
     // for !keyword.isEmpty() candidates.count() is 0 or 1
 
-    foreach (const PluginFactoryPrivate::Plugin &plugin, candidates) {
+    for (const PluginFactoryPrivate::Plugin &plugin : candidates) {
         for (const QMetaObject *current = plugin.first; current; current = current->superClass()) {
             if (0 == qstrcmp(iface, current->className())) {
                 if (obj) {
diff --git a/src/libcalamaresui/utils/qjsonitem.cpp b/src/libcalamaresui/utils/qjsonitem.cpp
index 7913962aeb70f62c601bd7e0c3335727dc5a5836..35c9725dd999ccffb7717c8379f445d55a24a95f 100644
--- a/src/libcalamaresui/utils/qjsonitem.cpp
+++ b/src/libcalamaresui/utils/qjsonitem.cpp
@@ -104,7 +104,8 @@ QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* paren
     {
 
         //Get all QJsonValue childs
-        foreach (QString key , value.toObject().keys()){
+        const auto keys = value.toObject().keys();
+        for (const QString &key : keys){
             QJsonValue v = value.toObject().value(key);
             QJsonTreeItem * child = load(v,rootItem);
             child->setKey(key);
@@ -119,7 +120,8 @@ QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* paren
     {
         //Get all QJsonValue childs
         int index = 0;
-        foreach (QJsonValue v , value.toArray()){
+        const auto valueArray = value.toArray();
+        for (const QJsonValue &v : valueArray) {
 
             QJsonTreeItem * child = load(v,rootItem);
             child->setKey(QString::number(index));
diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp
index 4e688bfe4ce0322ad77c0f88854ca771fb3c4134..d1b62b4d6907319b1ae18568573b8a2e16d3fb68 100644
--- a/src/modules/keyboard/KeyboardPage.cpp
+++ b/src/modules/keyboard/KeyboardPage.cpp
@@ -92,10 +92,10 @@ KeyboardPage::init()
 
     if ( process.waitForFinished() )
     {
-        QStringList list = QString( process.readAll() )
+        const QStringList list = QString( process.readAll() )
                            .split( "\n", QString::SkipEmptyParts );
 
-        foreach( QString line, list )
+        for ( QString line : list )
         {
             line = line.trimmed();
             if ( !line.startsWith( "xkb_symbols" ) )
diff --git a/src/modules/keyboard/keyboardwidget/keyboardpreview.cpp b/src/modules/keyboard/keyboardwidget/keyboardpreview.cpp
index e29673d88087690426edafdf4b176aa02c07ab04..53fa9c2af6e80e65d875d3a4a67622e5f96f8fe2 100644
--- a/src/modules/keyboard/keyboardwidget/keyboardpreview.cpp
+++ b/src/modules/keyboard/keyboardwidget/keyboardpreview.cpp
@@ -122,9 +122,9 @@ bool KeyBoardPreview::loadCodes() {
     // Clear codes
     codes.clear();
 
-    QStringList list = QString(process.readAll()).split("\n", QString::SkipEmptyParts);
+    const QStringList list = QString(process.readAll()).split("\n", QString::SkipEmptyParts);
 
-    foreach(QString line, list) {
+    for (const QString &line : list) {
         if (!line.startsWith("keycode") || !line.contains('='))
             continue;
 
@@ -253,7 +253,7 @@ void KeyBoardPreview::paintEvent(QPaintEvent* event) {
         int rw=usable_width-x;
         int ii=0;
 
-        foreach (int k, kb->keys.at(i)) {
+        for (int k : kb->keys.at(i)) {
             QRectF rect = QRectF(x, y, key_w, key_w);
 
             if (ii == kb->keys.at(i).size()-1 && last_end)
diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp
index 7499c50c0935466cd02508c491e9ec3bc274a1fb..680ed33b1f0f985c16592f26f7d43658df333786 100644
--- a/src/modules/license/LicensePage.cpp
+++ b/src/modules/license/LicensePage.cpp
@@ -97,7 +97,7 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
     CalamaresUtils::clearLayout( ui->licenseEntriesLayout );
 
     bool required = false;
-    foreach ( const LicenseEntry& entry, entriesList )
+    for ( const LicenseEntry& entry : entriesList )
     {
         if ( entry.required )
         {
@@ -134,7 +134,7 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
         ui->retranslateUi( this );
     )
 
-    foreach ( const LicenseEntry& entry, entriesList )
+    for ( const LicenseEntry& entry : entriesList )
     {
         QWidget* widget = new QWidget( this );
         QPalette pal( palette() );
diff --git a/src/modules/license/LicenseViewStep.cpp b/src/modules/license/LicenseViewStep.cpp
index 6e5ad2631378e5c93ed6d98ace3dae7dd6c14cf1..2b10738861f701d8ea29e981e6da1ca694c9aca3 100644
--- a/src/modules/license/LicenseViewStep.cpp
+++ b/src/modules/license/LicenseViewStep.cpp
@@ -112,7 +112,8 @@ LicenseViewStep::setConfigurationMap( const QVariantMap& configurationMap )
     if ( configurationMap.contains( "entries" ) &&
          configurationMap.value( "entries" ).type() == QVariant::List )
     {
-        foreach ( const QVariant& entryV, configurationMap.value( "entries" ).toList() )
+        const auto entries = configurationMap.value( "entries" ).toList();
+        for ( const QVariant& entryV : entries )
         {
             if ( entryV.type() != QVariant::Map )
                 continue;
diff --git a/src/modules/locale/LocaleConfiguration.cpp b/src/modules/locale/LocaleConfiguration.cpp
index 00f13ad42341eed2141cd72aafdd215866d0c5af..ca6316fc5790eba697419d3839115bc6eb19096b 100644
--- a/src/modules/locale/LocaleConfiguration.cpp
+++ b/src/modules/locale/LocaleConfiguration.cpp
@@ -43,7 +43,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
     QString language = languageLocale.split( '_' ).first();
 
     QStringList linesForLanguage;
-    foreach ( QString line, availableLocales )
+    for ( const QString &line : availableLocales )
     {
         if ( line.startsWith( language ) )
             linesForLanguage.append( line );
@@ -95,7 +95,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
     // language locale and pick the first result, if any.
     if ( lang.isEmpty() )
     {
-        foreach ( QString line, availableLocales )
+        for ( const QString &line : availableLocales )
         {
             if ( line.startsWith( languageLocale ) )
             {
@@ -161,7 +161,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
     QString combined = QString( "%1_%2" ).arg( language )
                                          .arg( countryCode );
     // We look up if it's a supported locale.
-    foreach ( QString line, availableLocales )
+    for ( const QString &line : availableLocales )
     {
         if ( line.startsWith( combined ) )
         {
@@ -174,7 +174,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
     if ( lc_formats.isEmpty() )
     {
         QStringList available;
-        foreach ( QString line, availableLocales )
+        for ( const QString &line : availableLocales )
         {
             if ( line.contains( QString( "_%1" ).arg( countryCode ) ) )
             {
@@ -239,7 +239,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
                         QString( "%1_%2" ).arg( countryToDefaultLanguage.value( countryCode ) )
                                           .arg( countryCode );
 
-                foreach ( QString line, availableLocales )
+                for ( const QString &line : availableLocales )
                 {
                     if ( line.startsWith( combinedLocale ) )
                     {
diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp
index efe00e53bcbc9151dad635ed4d30f134e2970e15..ed166ea3557df7286498238f207cfd404d136156 100644
--- a/src/modules/locale/LocalePage.cpp
+++ b/src/modules/locale/LocalePage.cpp
@@ -108,8 +108,8 @@ LocalePage::LocalePage( QWidget* parent )
 
         m_zoneCombo->clear();
 
-        QList< LocaleGlobal::Location > zones = regions.value( m_regionCombo->currentData().toString() );
-        foreach ( const LocaleGlobal::Location& zone, zones )
+        const QList< LocaleGlobal::Location > zones = regions.value( m_regionCombo->currentData().toString() );
+        for ( const LocaleGlobal::Location& zone : zones )
         {
             m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone );
         }
@@ -270,7 +270,7 @@ LocalePage::init( const QString& initialRegion,
     auto containsLocation = []( const QList< LocaleGlobal::Location >& locations,
                                 const QString& zone ) -> bool
     {
-        foreach ( const LocaleGlobal::Location& location, locations )
+        for ( const LocaleGlobal::Location& location : locations )
         {
             if ( location.zone == zone )
                 return true;
@@ -303,7 +303,8 @@ LocalePage::init( const QString& initialRegion,
         ba = supported.readAll();
         supported.close();
 
-        foreach ( QByteArray line, ba.split( '\n' ) )
+        const auto lines = ba.split( '\n' );
+        for ( const QByteArray &line : lines )
         {
             m_localeGenLines.append( QString::fromLatin1( line.simplified() ) );
         }
@@ -326,7 +327,8 @@ LocalePage::init( const QString& initialRegion,
             localeA.waitForFinished();
             ba = localeA.readAllStandardOutput();
         }
-        foreach ( QByteArray line, ba.split( '\n' ) )
+        const auto lines = ba.split( '\n' );
+        for ( const QByteArray &line : lines )
         {
             if ( line.startsWith( "## " ) ||
                  line.startsWith( "# " ) ||
diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp
index 020b79b45565d33d1d6c2ea5e4b34341a9cfd80e..11931347fa0230909fb8b7786b79eed1ec15f09e 100644
--- a/src/modules/partition/core/PartUtils.cpp
+++ b/src/modules/partition/core/PartUtils.cpp
@@ -155,10 +155,10 @@ lookForFstabEntries( const QString& partitionPath )
         QFile fstabFile( mountsDir.path() + "/etc/fstab" );
         if ( fstabFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
         {
-            QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() )
+            const QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() )
                                      .split( '\n' );
 
-            foreach ( const QString& rawLine, fstabLines )
+            for ( const QString& rawLine : fstabLines )
             {
                 QString line = rawLine.simplified();
                 if ( line.startsWith( '#' ) )
@@ -194,7 +194,7 @@ findPartitionPathForMountPoint( const FstabEntryList& fstab,
     if ( fstab.isEmpty() )
         return QString();
 
-    foreach ( const FstabEntry& entry, fstab )
+    for ( const FstabEntry& entry : fstab )
     {
         if ( entry.mountPoint == mountPoint )
         {
@@ -283,7 +283,8 @@ runOsprober( PartitionCoreModule* core )
     QString osProberReport( "Osprober lines, clean:\n" );
     QStringList osproberCleanLines;
     OsproberEntryList osproberEntries;
-    foreach ( const QString& line, osproberOutput.split( '\n' ) )
+    const auto lines = osproberOutput.split( '\n' );
+    for ( const QString& line : lines )
     {
         if ( !line.simplified().isEmpty() )
         {
diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp
index 219192a24880d7f4fadd0b0a075150770d21c57d..cf2b2c2a5d691848ec80b39d491bdb38649cecc6 100644
--- a/src/modules/partition/core/PartitionCoreModule.cpp
+++ b/src/modules/partition/core/PartitionCoreModule.cpp
@@ -480,7 +480,7 @@ PartitionCoreModule::dumpQueue() const
 }
 
 
-OsproberEntryList
+const OsproberEntryList
 PartitionCoreModule::osproberEntries() const
 {
     return m_osproberLines;
diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h
index 46f1b7be8b520045eb58a28186f9c1bf0be9f062..3051f99b4633ee76fd4e335aeb34decd69922d6c 100644
--- a/src/modules/partition/core/PartitionCoreModule.h
+++ b/src/modules/partition/core/PartitionCoreModule.h
@@ -127,7 +127,7 @@ public:
 
     void dumpQueue() const;
 
-    OsproberEntryList osproberEntries() const;
+    const OsproberEntryList osproberEntries() const;
 
 Q_SIGNALS:
     void hasRootMountPointChanged( bool value );
diff --git a/src/modules/partition/gui/AlongsidePage.cpp b/src/modules/partition/gui/AlongsidePage.cpp
index 2271691dd8da2a66b9e0a82c36d8cb03362680a4..0b1615b3293c25b45b41a2b04e0a0bde59e0c898 100644
--- a/src/modules/partition/gui/AlongsidePage.cpp
+++ b/src/modules/partition/gui/AlongsidePage.cpp
@@ -129,7 +129,7 @@ AlongsidePage::init( PartitionCoreModule* core )
                                         string( Calamares::Branding::ProductName ) ) );
     } );
 
-    foreach ( const OsproberEntry& e, m_core->osproberEntries() )
+    for ( const OsproberEntry& e : m_core->osproberEntries() )
     {
         if ( e.canBeResized )
             m_partitionsComboBox->addItem( e.prettyName + " (" + e.path + ")", e.path );
diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp
index d6c025639cb30d15f6ca00939cdffd87c6385272..1538d2f72a38d4b4f8af997e58c2d19170ea71b8 100644
--- a/src/modules/partition/gui/ChoicePage.cpp
+++ b/src/modules/partition/gui/ChoicePage.cpp
@@ -733,7 +733,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
                 // Find out is the selected partition has a rootfs. If yes, then make the
                 // m_reuseHomeCheckBox visible and set its text to something meaningful.
                 homePartitionPath->clear();
-                foreach ( const OsproberEntry& osproberEntry, m_core->osproberEntries() )
+                for ( const OsproberEntry& osproberEntry : m_core->osproberEntries() )
                     if ( osproberEntry.path == partPath )
                         *homePartitionPath = osproberEntry.homePath;
                 if ( homePartitionPath->isEmpty() )
@@ -1329,7 +1329,7 @@ OsproberEntryList
 ChoicePage::getOsproberEntriesForDevice( Device* device ) const
 {
     OsproberEntryList eList;
-    foreach ( const OsproberEntry& entry, m_core->osproberEntries() )
+    for ( const OsproberEntry& entry : m_core->osproberEntries() )
     {
         if ( entry.path.startsWith( device->deviceNode() ) )
             eList.append( entry );
diff --git a/src/modules/partition/gui/PartitionLabelsView.cpp b/src/modules/partition/gui/PartitionLabelsView.cpp
index 23e1ca17c386c430db57a64ea207e077b4abf60b..d2629a6e25dfb8b1f6df74e7d489ec082a1968c6 100644
--- a/src/modules/partition/gui/PartitionLabelsView.cpp
+++ b/src/modules/partition/gui/PartitionLabelsView.cpp
@@ -240,11 +240,11 @@ PartitionLabelsView::drawLabels( QPainter* painter,
     if ( !modl )
         return;
 
-    QModelIndexList indexesToDraw = getIndexesToDraw( parent );
+    const QModelIndexList indexesToDraw = getIndexesToDraw( parent );
 
     int label_x = rect.x();
     int label_y = rect.y();
-    foreach ( const QModelIndex& index, indexesToDraw )
+    for ( const QModelIndex& index : indexesToDraw )
     {
         QStringList texts = buildTexts( index );
 
@@ -306,12 +306,12 @@ PartitionLabelsView::sizeForAllLabels( int maxLineWidth ) const
     if ( !modl )
         return QSize();
 
-    QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
+    const QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
 
     int lineLength = 0;
     int numLines = 1;
     int singleLabelHeight = 0;
-    foreach ( const QModelIndex& index, indexesToDraw )
+    for ( const QModelIndex& index : indexesToDraw )
     {
         QStringList texts = buildTexts( index );
 
@@ -349,7 +349,7 @@ PartitionLabelsView::sizeForLabel( const QStringList& text ) const
 {
     int vertOffset = 0;
     int width = 0;
-    foreach ( const QString& textLine, text )
+    for ( const QString& textLine : text )
     {
         QSize textSize = fontMetrics().size( Qt::TextSingleLine, textLine );
 
@@ -371,7 +371,7 @@ PartitionLabelsView::drawLabel( QPainter* painter,
     painter->setPen( Qt::black );
     int vertOffset = 0;
     int width = 0;
-    foreach ( const QString& textLine, text )
+    for ( const QString& textLine : text )
     {
         QSize textSize = painter->fontMetrics().size( Qt::TextSingleLine, textLine );
         painter->drawText( pos.x()+LABEL_PARTITION_SQUARE_MARGIN,
@@ -402,12 +402,12 @@ PartitionLabelsView::indexAt( const QPoint& point ) const
     if ( !modl )
         return QModelIndex();
 
-    QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
+    const QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
 
     QRect rect = this->rect();
     int label_x = rect.x();
     int label_y = rect.y();
-    foreach ( const QModelIndex& index, indexesToDraw )
+    for ( const QModelIndex& index : indexesToDraw )
     {
         QStringList texts = buildTexts( index );
 
@@ -437,12 +437,12 @@ PartitionLabelsView::visualRect( const QModelIndex& idx ) const
     if ( !modl )
         return QRect();
 
-    QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
+    const QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
 
     QRect rect = this->rect();
     int label_x = rect.x();
     int label_y = rect.y();
-    foreach ( const QModelIndex& index, indexesToDraw )
+    for ( const QModelIndex& index : indexesToDraw )
     {
         QStringList texts = buildTexts( index );
 
diff --git a/src/modules/partition/gui/PartitionSplitterWidget.cpp b/src/modules/partition/gui/PartitionSplitterWidget.cpp
index b82a81e93e5f49584d193682efb2c53bbfd5c86b..a4aacbe9f782d10da2416de8cc1807980772a097 100644
--- a/src/modules/partition/gui/PartitionSplitterWidget.cpp
+++ b/src/modules/partition/gui/PartitionSplitterWidget.cpp
@@ -105,7 +105,7 @@ PartitionSplitterWidget::setupItems( const QVector<PartitionSplitterItem>& items
     m_items.clear();
     m_items = items;
     repaint();
-    foreach ( const PartitionSplitterItem& item, items )
+    for ( const PartitionSplitterItem& item : items )
         cDebug() << "PSI added item" << item.itemPath << "size" << item.size;
 }
 
diff --git a/src/modules/partition/gui/ReplaceWidget.cpp b/src/modules/partition/gui/ReplaceWidget.cpp
index a4a63e2ad5ca994f081433ad046dba8557058c4d..5a0a1837daea532e59ffc5f76fc4b6964661ea19 100644
--- a/src/modules/partition/gui/ReplaceWidget.cpp
+++ b/src/modules/partition/gui/ReplaceWidget.cpp
@@ -149,7 +149,7 @@ ReplaceWidget::onPartitionSelected()
     PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
     if ( model && ok )
     {
-        QStringList osproberLines = Calamares::JobQueue::instance()
+        const QStringList osproberLines = Calamares::JobQueue::instance()
                                     ->globalStorage()
                                     ->value( "osproberLines" ).toStringList();
 
@@ -197,7 +197,7 @@ ReplaceWidget::onPartitionSelected()
 
         QString prettyName = tr( "Data partition (%1)" )
                              .arg( partition->fileSystem().name() );
-        foreach ( const QString& line, osproberLines )
+        for ( const QString& line : osproberLines )
         {
             QStringList lineColumns = line.split( ':' );
 
diff --git a/src/modules/partition/jobs/ClearMountsJob.cpp b/src/modules/partition/jobs/ClearMountsJob.cpp
index b116ce1b48698bff6c2416becc6c0e6199412986..bf07b909cf41b9d069cb1d588ce387d6e332502c 100644
--- a/src/modules/partition/jobs/ClearMountsJob.cpp
+++ b/src/modules/partition/jobs/ClearMountsJob.cpp
@@ -72,8 +72,8 @@ ClearMountsJob::exec()
     process.start();
     process.waitForFinished();
 
-    QString partitions = process.readAllStandardOutput();
-    QStringList partitionsList = partitions.simplified().split( ' ' );
+    const QString partitions = process.readAllStandardOutput();
+    const QStringList partitionsList = partitions.simplified().split( ' ' );
 
     // Build a list of partitions of type 82 (Linux swap / Solaris).
     // We then need to clear them just in case they contain something resumable from a
@@ -100,7 +100,8 @@ ClearMountsJob::exec()
         *it = (*it).simplified().split( ' ' ).first();
     }
 
-    foreach ( QString mapperPath, getCryptoDevices() )
+    const QStringList cryptoDevices = getCryptoDevices();
+    for ( const QString &mapperPath : cryptoDevices )
     {
         tryUmount( mapperPath );
         QString news = tryCryptoClose( mapperPath );
@@ -113,8 +114,8 @@ ClearMountsJob::exec()
     process.waitForFinished();
     if ( process.exitCode() == 0 ) //means LVM2 tools are installed
     {
-        QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
-        foreach ( const QString& lvscanLine, lvscanLines )
+        const QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
+        for ( const QString& lvscanLine : lvscanLines )
         {
             QString lvPath = lvscanLine.simplified().split( ' ' ).value( 1 ); //second column
             lvPath = lvPath.replace( '\'', "" );
@@ -137,8 +138,8 @@ ClearMountsJob::exec()
         {
             QSet< QString > vgSet;
 
-            QStringList pvdisplayLines = pvdisplayOutput.split( '\n' );
-            foreach ( const QString& pvdisplayLine, pvdisplayLines )
+            const QStringList pvdisplayLines = pvdisplayOutput.split( '\n' );
+            for ( const QString& pvdisplayLine : pvdisplayLines )
             {
                 QString pvPath = pvdisplayLine.simplified().split( ' ' ).value( 0 );
                 QString vgName = pvdisplayLine.simplified().split( ' ' ).value( 1 );
@@ -160,7 +161,8 @@ ClearMountsJob::exec()
     else
         cDebug() << "WARNING: this system does not seem to have LVM2 tools.";
 
-    foreach ( QString mapperPath, getCryptoDevices() )
+    const QStringList cryptoDevices2 = getCryptoDevices();
+    for ( const QString &mapperPath : cryptoDevices2 )
     {
         tryUmount( mapperPath );
         QString news = tryCryptoClose( mapperPath );
@@ -168,7 +170,7 @@ ClearMountsJob::exec()
             goodNews.append( news );
     }
 
-    foreach ( QString p, partitionsList )
+    for ( const QString &p : partitionsList )
     {
         QString partPath = QString( "/dev/%1" ).arg( p );
 
@@ -247,13 +249,13 @@ ClearMountsJob::tryCryptoClose( const QString& mapperPath )
 
 
 QStringList
-ClearMountsJob::getCryptoDevices()
+ClearMountsJob::getCryptoDevices() const
 {
     QDir mapperDir( "/dev/mapper" );
-    QFileInfoList fiList = mapperDir.entryInfoList( QDir::Files );
+    const QFileInfoList fiList = mapperDir.entryInfoList( QDir::Files );
     QStringList list;
     QProcess process;
-    foreach ( QFileInfo fi, fiList )
+    for ( const QFileInfo &fi : fiList )
     {
         if ( fi.baseName() == "control" )
             continue;
diff --git a/src/modules/partition/jobs/ClearMountsJob.h b/src/modules/partition/jobs/ClearMountsJob.h
index d4f639ffc5ecf0cd7b0406bffdbb8de84eef607d..bc4df8fe7afbe092a868671f04c357127ca3c879 100644
--- a/src/modules/partition/jobs/ClearMountsJob.h
+++ b/src/modules/partition/jobs/ClearMountsJob.h
@@ -39,7 +39,7 @@ private:
     QString tryUmount( const QString& partPath );
     QString tryClearSwap( const QString& partPath );
     QString tryCryptoClose( const QString& mapperPath );
-    QStringList getCryptoDevices();
+    QStringList getCryptoDevices() const;
     Device* m_device;
 };
 
diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp
index bc70ec0b5359e74debc8b3772c52298a772c9d6a..516d04b2f300fef44968e89056e5ace436eb48da 100644
--- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp
+++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp
@@ -126,7 +126,8 @@ FillGlobalStorageJob::prettyDescription() const
 {
     QStringList lines;
 
-    foreach ( QVariant partitionItem, createPartitionList().toList() )
+    const auto partitionList = createPartitionList().toList();
+    for ( const QVariant &partitionItem : partitionList )
     {
         if ( partitionItem.type() == QVariant::Map )
         {
diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp
index 387aa274a5ad5f401b431994ce936fa6b76d6d15..351ef49a4d536ddf9555e46beba5452afd90eaca 100644
--- a/src/modules/summary/SummaryPage.cpp
+++ b/src/modules/summary/SummaryPage.cpp
@@ -63,10 +63,10 @@ SummaryPage::onActivate()
 
     QString text;
     bool first = true;
-    Calamares::ViewStepList steps =
+    const Calamares::ViewStepList steps =
         stepsForSummary( Calamares::ViewManager::instance()->viewSteps() );
 
-    foreach ( Calamares::ViewStep* step, steps )
+    for ( Calamares::ViewStep* step : steps )
     {
         QString text = step->prettyStatus();
         QWidget* widget = step->createSummaryWidget();
@@ -101,7 +101,7 @@ Calamares::ViewStepList
 SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
 {
     Calamares::ViewStepList steps;
-    foreach ( Calamares::ViewStep* step, allSteps )
+    for ( Calamares::ViewStep* step : allSteps )
     {
         // We start from the beginning of the complete steps list. If we encounter any
         // ExecutionViewStep, it means there was an execution phase in the past, and any
diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp
index a45b1cc4905155e0ffa6df47ac0984281cf9390d..6beb61de0aa0f322ed58c26c787122dcce57c0cf 100644
--- a/src/modules/welcome/WelcomePage.cpp
+++ b/src/modules/welcome/WelcomePage.cpp
@@ -109,7 +109,8 @@ WelcomePage::initLanguages()
     {
         bool isTranslationAvailable = false;
 
-        foreach ( const QString& locale, QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') )
+        const auto locales = QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';');
+        for ( const QString& locale : locales )
         {
             QLocale thisLocale = QLocale( locale );
             QString lang = QLocale::languageToString( thisLocale.language() );
diff --git a/src/modules/welcome/checker/RequirementsChecker.cpp b/src/modules/welcome/checker/RequirementsChecker.cpp
index 1ad98b79d9d9bfc420c1fb3a147e91e3e774c84e..0a7233e3dcae24f8cdcaf9623b27e9cfba2705f9 100644
--- a/src/modules/welcome/checker/RequirementsChecker.cpp
+++ b/src/modules/welcome/checker/RequirementsChecker.cpp
@@ -264,9 +264,8 @@ RequirementsChecker::checkBatteryExists()
         return false;
 
     QDir baseDir( basePath.absoluteFilePath() );
-    foreach ( auto item, baseDir.entryList( QDir::AllDirs |
-                                            QDir::Readable |
-                                            QDir::NoDotAndDotDot ) )
+    const auto entries = baseDir.entryList( QDir::AllDirs | QDir::Readable | QDir::NoDotAndDotDot );
+    for ( const auto &item : entries )
     {
         QFileInfo typePath( baseDir.absoluteFilePath( QString( "%1/type" )
                                                       .arg( item ) ) );