From fb6e0bcb13cc17e427f35ec6bab8c349b4486327 Mon Sep 17 00:00:00 2001
From: "Dmitry Yu. Naumov" <github@naumov.de>
Date: Thu, 1 Jun 2017 13:05:04 +0200
Subject: [PATCH] Do not use else after return. (#1821)

---
 .../Utils/MeshEdit/editMaterialID.cpp         |  4 +++-
 MaterialLib/Adsorption/Reaction.cpp           | 14 +++++------
 .../Fluid/Density/CreateFluidDensityModel.cpp | 20 +++++++---------
 .../CreateRelativePermeabilityModel.cpp       | 24 +++++++++----------
 .../MeshEditing/DuplicateMeshComponents.cpp   |  6 ++---
 MeshLib/MeshEditing/MeshRevision.cpp          |  4 +++-
 .../ODESolver/TimeDiscretizationBuilder.cpp   |  6 ++---
 ProcessLib/Parameter/Parameter.cpp            | 10 ++++----
 8 files changed, 42 insertions(+), 46 deletions(-)

diff --git a/Applications/Utils/MeshEdit/editMaterialID.cpp b/Applications/Utils/MeshEdit/editMaterialID.cpp
index 35e560122aa..02e63ec981a 100644
--- a/Applications/Utils/MeshEdit/editMaterialID.cpp
+++ b/Applications/Utils/MeshEdit/editMaterialID.cpp
@@ -61,7 +61,9 @@ int main (int argc, char* argv[])
     {
         INFO("Please select only one editing mode: -r or -c or -s");
         return 0;
-    } else if (replaceArg.isSet()) {
+    }
+    if (replaceArg.isSet())
+    {
         if (!matIDArg.isSet() || !newIDArg.isSet()) {
             INFO("current and new material IDs must be provided for replacement");
             return 0;
diff --git a/MaterialLib/Adsorption/Reaction.cpp b/MaterialLib/Adsorption/Reaction.cpp
index d7357f14360..87becc87acb 100644
--- a/MaterialLib/Adsorption/Reaction.cpp
+++ b/MaterialLib/Adsorption/Reaction.cpp
@@ -45,19 +45,19 @@ newInstance(BaseLib::ConfigTree const& conf)
         return std::make_unique<DensityConst>();
     if (type == "Z13XBF_Cook")
         return std::make_unique<DensityCook>();
-    else if (type == "Z13XBF_Dubinin")
+    if (type == "Z13XBF_Dubinin")
         return std::make_unique<DensityDubinin>();
-    else if (type == "Z13XBF_Hauer")
+    if (type == "Z13XBF_Hauer")
         return std::make_unique<DensityHauer>();
-    else if (type == "Z13XBF_Mette")
+    if (type == "Z13XBF_Mette")
         return std::make_unique<DensityMette>();
-    else if (type == "Z13XBF_Nunez")
+    if (type == "Z13XBF_Nunez")
         return std::make_unique<DensityNunez>();
-    else if (type == "Inert")
+    if (type == "Inert")
         return std::make_unique<ReactionInert>();
-    else if (type == "Sinusoidal")
+    if (type == "Sinusoidal")
         return std::make_unique<ReactionSinusoidal>(conf);
-    else if (type == "CaOH2")
+    if (type == "CaOH2")
         return std::make_unique<ReactionCaOH2>(conf);
 
     OGS_FATAL("Unknown reactive system: %s.", type.c_str());
diff --git a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp
index 7940e0c919a..abc0f53c80c 100644
--- a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp
+++ b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp
@@ -112,7 +112,7 @@ std::unique_ptr<FluidProperty> createFluidDensityModel(
         return createLinearTemperatureDependentDensity(config);
     if (type == "ConcentrationDependent")
         return createLinearConcentrationDependentDensity(config);
-    else if (type == "IdealGasLaw")
+    if (type == "IdealGasLaw")
     {
         //! \ogs_file_param{material__fluid__density__type}
         config.checkConfigParameter("type", "IdealGasLaw");
@@ -120,19 +120,17 @@ std::unique_ptr<FluidProperty> createFluidDensityModel(
             //! \ogs_file_param{material__fluid__density__IdealGasLaw__molar_mass}
             config.getConfigParameter<double>("molar_mass"));
     }
-    else if (type == "WaterDensityIAPWSIF97Region1")
+    if (type == "WaterDensityIAPWSIF97Region1")
     {
         return std::make_unique<WaterDensityIAPWSIF97Region1>();
     }
-    else
-    {
-        OGS_FATAL(
-            "The density type %s is unavailable.\n"
-            "The available types are: \n\tConstant, \n\tLiquidDensity, "
-            "\n\tTemperatureDependent, \n\tIdealGasLaw."
-            "\n\tWaterDensityIAPWSIF97Region1\n",
-            type.data());
-    }
+
+    OGS_FATAL(
+        "The density type %s is unavailable.\n"
+        "The available types are: \n\tConstant, \n\tLiquidDensity, "
+        "\n\tTemperatureDependent, \n\tIdealGasLaw."
+        "\n\tWaterDensityIAPWSIF97Region1\n",
+        type.data());
 }
 
 }  // end namespace
diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp
index b6456f5b3ff..bda7d78e81a 100644
--- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp
+++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp
@@ -185,7 +185,7 @@ std::unique_ptr<RelativePermeability> createRelativePermeabilityModel(
     {
         return createNonWettingPhaseBrooksCoreyOilGas(config);
     }
-    else if (type == "Curve")
+    if (type == "Curve")
     {
         //! \ogs_file_param{material__porous_medium__relative_permeability__type}
         config.checkConfigParameter("type", "Curve");
@@ -197,18 +197,16 @@ std::unique_ptr<RelativePermeability> createRelativePermeabilityModel(
                               ::PiecewiseLinearInterpolation>(curve_config);
         return std::make_unique<RelativePermeabilityCurve>(std::move(curve));
     }
-    else
-    {
-        OGS_FATAL(
-            "The relative permeability model %s is unavailable.\n"
-            "The available models are:"
-            "\n\tWettingPhaseVanGenuchten,"
-            "\n\tNonWettingPhaseVanGenuchten,"
-            "\n\tWettingPhaseBrooksCoreyOilGas,"
-            "\n\tNonWettingPhaseBrooksCoreyOilGas,",
-            "\n\tCurve.\n",
-            type.data());
-    }
+
+    OGS_FATAL(
+        "The relative permeability model %s is unavailable.\n"
+        "The available models are:"
+        "\n\tWettingPhaseVanGenuchten,"
+        "\n\tNonWettingPhaseVanGenuchten,"
+        "\n\tWettingPhaseBrooksCoreyOilGas,"
+        "\n\tNonWettingPhaseBrooksCoreyOilGas,",
+        "\n\tCurve.\n",
+        type.data());
 }
 
 }  // end namespace
diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp
index 1cadf0e4e64..483aeb34a73 100644
--- a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp
+++ b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp
@@ -50,11 +50,11 @@ MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::v
         return copyElement<MeshLib::Quad>(element, nodes);
     if (element->getGeomType() == MeshElemType::TETRAHEDRON)
         return copyElement<MeshLib::Tet>(element, nodes);
-    else if (element->getGeomType() == MeshElemType::HEXAHEDRON)
+    if (element->getGeomType() == MeshElemType::HEXAHEDRON)
         return copyElement<MeshLib::Hex>(element, nodes);
-    else if (element->getGeomType() == MeshElemType::PYRAMID)
+    if (element->getGeomType() == MeshElemType::PYRAMID)
         return copyElement<MeshLib::Pyramid>(element, nodes);
-    else if (element->getGeomType() == MeshElemType::PRISM)
+    if (element->getGeomType() == MeshElemType::PRISM)
         return copyElement<MeshLib::Prism>(element, nodes);
 
     ERR ("Error: Unknown element type.");
diff --git a/MeshLib/MeshEditing/MeshRevision.cpp b/MeshLib/MeshEditing/MeshRevision.cpp
index af879086bdc..c2ed2fadd8d 100644
--- a/MeshLib/MeshEditing/MeshRevision.cpp
+++ b/MeshLib/MeshEditing/MeshRevision.cpp
@@ -319,7 +319,9 @@ std::size_t MeshRevision::reduceElement(MeshLib::Element const*const element,
     {
         this->reducePyramid(element, n_unique_nodes, nodes, elements, min_elem_dim);
         return 1;
-    } else if (element->getGeomType() == MeshElemType::PRISM) {
+    }
+    if (element->getGeomType() == MeshElemType::PRISM)
+    {
         return reducePrism(element, n_unique_nodes, nodes, elements, min_elem_dim);
     }
 
diff --git a/NumLib/ODESolver/TimeDiscretizationBuilder.cpp b/NumLib/ODESolver/TimeDiscretizationBuilder.cpp
index d434ac16cee..d185db80061 100644
--- a/NumLib/ODESolver/TimeDiscretizationBuilder.cpp
+++ b/NumLib/ODESolver/TimeDiscretizationBuilder.cpp
@@ -43,9 +43,7 @@ std::unique_ptr<TimeDiscretization> createTimeDiscretization(
         auto const order = config.getConfigParameter<unsigned>("order");
         return std::make_unique<BackwardDifferentiationFormula>(order);
     }
-    else
-    {
-        OGS_FATAL("Unrecognized time discretization type `%s'", type.c_str());
-    }
+
+    OGS_FATAL("Unrecognized time discretization type `%s'", type.c_str());
 }
 }
diff --git a/ProcessLib/Parameter/Parameter.cpp b/ProcessLib/Parameter/Parameter.cpp
index 3f9295f223a..9e81803fd1c 100644
--- a/ProcessLib/Parameter/Parameter.cpp
+++ b/ProcessLib/Parameter/Parameter.cpp
@@ -57,17 +57,15 @@ std::unique_ptr<ParameterBase> createParameter(
         auto param = createMeshElementParameter(name, config, *meshes.front());
         return param;
     }
-    else if (type == "MeshNode")
+    if (type == "MeshNode")
     {
         INFO("MeshNodeParameter: %s", name.c_str());
         auto param = createMeshNodeParameter(name, config, *meshes.front());
         return param;
     }
-    else
-    {
-        OGS_FATAL("Cannot construct a parameter of given type \'%s\'.",
-                  type.c_str());
-    }
+
+    OGS_FATAL("Cannot construct a parameter of given type \'%s\'.",
+              type.c_str());
 }
 
 }  // ProcessLib
-- 
GitLab