From a44318872256aa057f49629a9982e68497af2215 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Wed, 29 Dec 2021 21:04:24 -0700 Subject: [PATCH] Reintroduce readability-uppercase-literal-suffix and readability-container-size-empty checks. (#536) --- .clang-tidy | 2 +- amr-wind/incflo.cpp | 2 +- amr-wind/turbulence/turb_utils.cpp | 2 +- amr-wind/utilities/DerivedQtyDefs.cpp | 16 ++++++++-------- amr-wind/utilities/IOManager.cpp | 2 +- amr-wind/utilities/console_io.cpp | 2 +- amr-wind/utilities/tagging/BoxRefiner.cpp | 2 +- .../utilities/tagging/CurvatureRefinement.cpp | 2 +- amr-wind/utilities/tagging/FieldRefinement.cpp | 2 +- .../utilities/tagging/GradientMagRefinement.cpp | 2 +- .../utilities/tagging/QCriterionRefinement.cpp | 2 +- .../utilities/tagging/VorticityMagRefinement.cpp | 2 +- .../wind_energy/actuator/ActuatorContainer.cpp | 4 ++-- unit_tests/core/test_physics.cpp | 2 +- unit_tests/utilities/test_refinement.cpp | 4 ++-- .../actuator/test_actuator_flat_plate.cpp | 6 +++--- 16 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 0957d25246..9d19861e6e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-modernize-use-emplace,-readability-qualified-auto,-readability-static-accessed-through-instance,-readability-container-size-empty,-readability-make-member-function-const,-readability-uppercase-literal-suffix,-modernize-pass-by-value,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' +Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-modernize-use-emplace,-readability-qualified-auto,-readability-static-accessed-through-instance,-readability-make-member-function-const,-modernize-pass-by-value,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' WarningsAsErrors: '' HeaderFilterRegex: '^((?!/amrex/Src/|/googletest/).)*$' AnalyzeTemporaryDtors: false diff --git a/amr-wind/incflo.cpp b/amr-wind/incflo.cpp index b70dee7912..096c7771a4 100644 --- a/amr-wind/incflo.cpp +++ b/amr-wind/incflo.cpp @@ -313,7 +313,7 @@ void incflo::init_physics_and_pde() // Register density first so that we can compute its `n+1/2` state before // other scalars attempt to use it in their computations. if (!m_constant_density) { - if (pde_mgr.scalar_eqns().size() > 0) + if (!pde_mgr.scalar_eqns().empty()) amrex::Abort( "For non-constant density, it must be the first equation " "registered for the scalar equations"); diff --git a/amr-wind/turbulence/turb_utils.cpp b/amr-wind/turbulence/turb_utils.cpp index 622844bc2f..69a0f9b398 100644 --- a/amr-wind/turbulence/turb_utils.cpp +++ b/amr-wind/turbulence/turb_utils.cpp @@ -16,7 +16,7 @@ void inject_turbulence_src_terms( pp.queryarr("sources", srcin); // If there are no sources (usually the case) then add sources and return - if (srcin.size() < 1) { + if (srcin.empty()) { pp.addarr("sources", terms); return; } diff --git a/amr-wind/utilities/DerivedQtyDefs.cpp b/amr-wind/utilities/DerivedQtyDefs.cpp index 21563fa11e..a9adb3787b 100644 --- a/amr-wind/utilities/DerivedQtyDefs.cpp +++ b/amr-wind/utilities/DerivedQtyDefs.cpp @@ -10,7 +10,7 @@ VorticityMag::VorticityMag( const FieldRepo& repo, const std::vector& args) : m_vel(repo.get_field("velocity")) { - AMREX_ALWAYS_ASSERT(args.size() == 0u); + AMREX_ALWAYS_ASSERT(args.empty()); } void VorticityMag::operator()(ScratchField& fld, const int scomp) @@ -24,7 +24,7 @@ QCriterion::QCriterion( const FieldRepo& repo, const std::vector& args) : m_vel(repo.get_field("velocity")) { - AMREX_ALWAYS_ASSERT(args.size() == 0u); + AMREX_ALWAYS_ASSERT(args.empty()); } void QCriterion::operator()(ScratchField& fld, const int scomp) @@ -38,7 +38,7 @@ QCriterionNondim::QCriterionNondim( const FieldRepo& repo, const std::vector& args) : m_vel(repo.get_field("velocity")) { - AMREX_ALWAYS_ASSERT(args.size() == 0u); + AMREX_ALWAYS_ASSERT(args.empty()); } void QCriterionNondim::operator()(ScratchField& fld, const int scomp) @@ -52,7 +52,7 @@ StrainRateMag::StrainRateMag( const FieldRepo& repo, const std::vector& args) : m_vel(repo.get_field("velocity")) { - AMREX_ALWAYS_ASSERT(args.size() == 0u); + AMREX_ALWAYS_ASSERT(args.empty()); } void StrainRateMag::operator()(ScratchField& fld, const int scomp) @@ -64,7 +64,7 @@ void StrainRateMag::operator()(ScratchField& fld, const int scomp) Gradient::Gradient(const FieldRepo& repo, const std::vector& args) { - AMREX_ALWAYS_ASSERT(args.size() == 1u); + AMREX_ALWAYS_ASSERT(args.size() == 1U); m_phi = &repo.get_field(args[0]); } @@ -78,7 +78,7 @@ void Gradient::operator()(ScratchField& fld, const int scomp) Divergence::Divergence( const FieldRepo& repo, const std::vector& args) { - AMREX_ALWAYS_ASSERT(args.size() == 1u); + AMREX_ALWAYS_ASSERT(args.size() == 1U); m_phi = &repo.get_field(args[0]); AMREX_ALWAYS_ASSERT(m_phi->num_comp() == AMREX_SPACEDIM); } @@ -93,7 +93,7 @@ void Divergence::operator()(ScratchField& fld, const int scomp) Laplacian::Laplacian( const FieldRepo& repo, const std::vector& args) { - AMREX_ALWAYS_ASSERT(args.size() == 1u); + AMREX_ALWAYS_ASSERT(args.size() == 1U); m_phi = &repo.get_field(args[0]); AMREX_ALWAYS_ASSERT(m_phi->num_comp() == AMREX_SPACEDIM); } @@ -109,7 +109,7 @@ FieldComponents::FieldComponents( const FieldRepo& repo, const std::vector& args) { const size_t nargs = args.size(); - AMREX_ALWAYS_ASSERT(nargs > 1u); + AMREX_ALWAYS_ASSERT(nargs > 1U); m_fld = &repo.get_field(args[0]); AMREX_ALWAYS_ASSERT(static_cast(nargs - 1) < m_fld->num_comp()); diff --git a/amr-wind/utilities/IOManager.cpp b/amr-wind/utilities/IOManager.cpp index fe79f087ed..0781584860 100644 --- a/amr-wind/utilities/IOManager.cpp +++ b/amr-wind/utilities/IOManager.cpp @@ -89,7 +89,7 @@ void IOManager::initialize_io() } } - if (out_derived_vars.size() > 0u) { + if (!out_derived_vars.empty()) { m_derived_mgr->create(out_derived_vars); m_plt_num_comp += m_derived_mgr->num_comp(); m_derived_mgr->var_names(m_plt_var_names); diff --git a/amr-wind/utilities/console_io.cpp b/amr-wind/utilities/console_io.cpp index 73160179ca..4363c95371 100644 --- a/amr-wind/utilities/console_io.cpp +++ b/amr-wind/utilities/console_io.cpp @@ -191,7 +191,7 @@ void print_tpls(std::ostream& out) tpls.push_back(std::string("ASCENT ") + ASCENT_VERSION); #endif - if (tpls.size() > 0) { + if (!tpls.empty()) { out << " Enabled third-party libraries: "; for (const auto& val : tpls) { out << "\n " << val; diff --git a/amr-wind/utilities/tagging/BoxRefiner.cpp b/amr-wind/utilities/tagging/BoxRefiner.cpp index 8a734f427b..2b65d78f61 100644 --- a/amr-wind/utilities/tagging/BoxRefiner.cpp +++ b/amr-wind/utilities/tagging/BoxRefiner.cpp @@ -13,7 +13,7 @@ inline vs::Vector parse_vector(amrex::ParmParse& pp, const std::string& key) { amrex::Vector tmp; pp.getarr(key.data(), tmp); - AMREX_ALWAYS_ASSERT(tmp.size() == 3u); + AMREX_ALWAYS_ASSERT(tmp.size() == 3U); return vs::Vector{tmp[0], tmp[1], tmp[2]}; } diff --git a/amr-wind/utilities/tagging/CurvatureRefinement.cpp b/amr-wind/utilities/tagging/CurvatureRefinement.cpp index 7c9a1018c8..41711d33d3 100644 --- a/amr-wind/utilities/tagging/CurvatureRefinement.cpp +++ b/amr-wind/utilities/tagging/CurvatureRefinement.cpp @@ -27,7 +27,7 @@ void CurvatureRefinement::initialize(const std::string& key) amrex::Vector curv_value; pp.queryarr("values", curv_value); - if ((curv_value.size() == 0u)) + if ((curv_value.empty())) amrex::Abort("CurvatureRefinement: Must specify at least one value"); { diff --git a/amr-wind/utilities/tagging/FieldRefinement.cpp b/amr-wind/utilities/tagging/FieldRefinement.cpp index 43319725f1..48cc2ab622 100644 --- a/amr-wind/utilities/tagging/FieldRefinement.cpp +++ b/amr-wind/utilities/tagging/FieldRefinement.cpp @@ -31,7 +31,7 @@ void FieldRefinement::initialize(const std::string& key) pp.queryarr("field_error", field_err); pp.queryarr("grad_error", grad_err); - if ((field_err.size() == 0u) && (grad_err.size() == 0u)) + if ((field_err.empty()) && (grad_err.empty())) amrex::Abort( "FieldRefinement: Must specify at least one of field_error or " "grad_error"); diff --git a/amr-wind/utilities/tagging/GradientMagRefinement.cpp b/amr-wind/utilities/tagging/GradientMagRefinement.cpp index f481129d48..eeab8bcc04 100644 --- a/amr-wind/utilities/tagging/GradientMagRefinement.cpp +++ b/amr-wind/utilities/tagging/GradientMagRefinement.cpp @@ -27,7 +27,7 @@ void GradientMagRefinement::initialize(const std::string& key) amrex::Vector gradmag_value; pp.queryarr("values", gradmag_value); - if ((gradmag_value.size() == 0u)) + if ((gradmag_value.empty())) amrex::Abort("GradientMagRefinement: Must specify at least one value"); { diff --git a/amr-wind/utilities/tagging/QCriterionRefinement.cpp b/amr-wind/utilities/tagging/QCriterionRefinement.cpp index 896934e3c1..ecde2b3c3e 100644 --- a/amr-wind/utilities/tagging/QCriterionRefinement.cpp +++ b/amr-wind/utilities/tagging/QCriterionRefinement.cpp @@ -27,7 +27,7 @@ void QCriterionRefinement::initialize(const std::string& key) pp.queryarr("values", qc_value); - if (qc_value.size() == 0u) + if (qc_value.empty()) amrex::Abort( "QCriterionRefinement: Must specify at least one of value"); diff --git a/amr-wind/utilities/tagging/VorticityMagRefinement.cpp b/amr-wind/utilities/tagging/VorticityMagRefinement.cpp index fa4101b6f9..8de77b7d2e 100644 --- a/amr-wind/utilities/tagging/VorticityMagRefinement.cpp +++ b/amr-wind/utilities/tagging/VorticityMagRefinement.cpp @@ -27,7 +27,7 @@ void VorticityMagRefinement::initialize(const std::string& key) pp.queryarr("values", vort_value); - if (vort_value.size() == 0u) + if (vort_value.empty()) amrex::Abort( "VorticityMagRefinement: Must specify at least one of value"); diff --git a/amr-wind/wind_energy/actuator/ActuatorContainer.cpp b/amr-wind/wind_energy/actuator/ActuatorContainer.cpp index 5195f99f1e..29bad74018 100644 --- a/amr-wind/wind_energy/actuator/ActuatorContainer.cpp +++ b/amr-wind/wind_energy/actuator/ActuatorContainer.cpp @@ -84,9 +84,9 @@ void ActuatorContainer::initialize_particles(const int total_pts) // query the particle ID from the container. We should always be starting // from 1. - ParticleType::NextID(1u); + ParticleType::NextID(1U); const auto id_start = ParticleType::NextID(); - AMREX_ALWAYS_ASSERT(id_start == 1u); + AMREX_ALWAYS_ASSERT(id_start == 1U); const int iproc = amrex::ParallelDescriptor::MyProc(); // Flag indicating if a tile was found where all particles were deposited. diff --git a/unit_tests/core/test_physics.cpp b/unit_tests/core/test_physics.cpp index d6e9df89ec..dc3c92ce7c 100644 --- a/unit_tests/core/test_physics.cpp +++ b/unit_tests/core/test_physics.cpp @@ -56,7 +56,7 @@ TEST_F(PhysicsTest, physics_test_duplicates) EXPECT_FALSE(phy_mgr.contains(PhysicsEx::identifier())); auto& pex1 = phy_mgr.create("PhysicsEx", sim()); auto& pex2 = phy_mgr.create("PhysicsEx", sim()); - EXPECT_EQ(phy_mgr.objects().size(), 1u); + EXPECT_EQ(phy_mgr.objects().size(), 1U); EXPECT_TRUE(phy_mgr.contains(PhysicsEx::identifier())); EXPECT_EQ(&pex1, &pex2); diff --git a/unit_tests/utilities/test_refinement.cpp b/unit_tests/utilities/test_refinement.cpp index 2cad09bbfc..e5965b2fbf 100644 --- a/unit_tests/utilities/test_refinement.cpp +++ b/unit_tests/utilities/test_refinement.cpp @@ -149,8 +149,8 @@ TEST_F(NestRefineTest, bbox_limits) box_refine->read_inputs(mesh(), ss); auto targets = box_refine->boxarray_vec(); - EXPECT_EQ(targets.size(), 1u); - EXPECT_EQ(targets[0].size(), 1u); + EXPECT_EQ(targets.size(), 1U); + EXPECT_EQ(targets[0].size(), 1U); auto domain = mesh().Geom(0).Domain(); auto bx = targets[0][0]; diff --git a/unit_tests/wind_energy/actuator/test_actuator_flat_plate.cpp b/unit_tests/wind_energy/actuator/test_actuator_flat_plate.cpp index b1e5f5b760..f824f1bb34 100644 --- a/unit_tests/wind_energy/actuator/test_actuator_flat_plate.cpp +++ b/unit_tests/wind_energy/actuator/test_actuator_flat_plate.cpp @@ -190,7 +190,7 @@ TEST_F(ActFlatPlateTest, act_model_init) { initialize_mesh(); sim().repo().declare_field("actuator_src_term", 3, 0); - amr_wind::actuator::ActuatorContainer::ParticleType::NextID(1u); + amr_wind::actuator::ActuatorContainer::ParticleType::NextID(1U); { amrex::ParmParse pp("Actuator.TestFlatPlateLine"); pp.add("num_points", 11); @@ -221,7 +221,7 @@ TEST_F(ActFlatPlateTest, actuator_init) initialize_mesh(); auto& vel = sim().repo().declare_field("velocity", 3, 3); init_field(vel); - amr_wind::actuator::ActuatorContainer::ParticleType::NextID(1u); + amr_wind::actuator::ActuatorContainer::ParticleType::NextID(1U); amrex::Vector actuators{"T1", "T2"}; { @@ -254,7 +254,7 @@ TEST_F(ActFlatPlateTest, flat_plate_init) initialize_mesh(); auto& vel = sim().repo().declare_field("velocity", 3, 3); vel.setVal(10.0, 0, 1, 3); - amr_wind::actuator::ActuatorContainer::ParticleType::NextID(1u); + amr_wind::actuator::ActuatorContainer::ParticleType::NextID(1U); amrex::Vector actuators{"T1", "T2"}; {