From 6f8d9803bf8e6d22e40dbb107ad25833acfa0d40 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sun, 15 Dec 2019 11:19:51 -0500 Subject: [PATCH] Fix various clang-tidy errors Having fixed the clang-tidy Travis build, it's now necessary to fix all the errors it highlights. --- src/character.cpp | 5 +---- src/handle_action.cpp | 4 ++-- src/json.cpp | 2 +- src/mapgen_functions.cpp | 4 ++-- src/mondefense.cpp | 2 -- src/npcmove.cpp | 2 -- src/player_display.cpp | 2 +- src/veh_interact.cpp | 3 --- tests/active_item_cache.cpp | 2 +- 9 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 9c02c37ca8e1f..10740e870ac85 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -550,10 +550,7 @@ void Character::set_stashed_activity( player_activity act, player_activity act_b bool Character::has_stashed_activity() const { - if( stashed_outbounds_activity ) { - return true; - } - return false; + return static_cast( stashed_outbounds_activity ); } void Character::assign_stashed_activity() diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 93177322c560e..bc232965454a4 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -976,9 +976,9 @@ static void sleep() as_m.reset(); as_m.text = can_hibernate ? - _( "You're engorged to hibernate. The alarm would only attract attention. Set an alarm anyway?" + + _( "You're engorged to hibernate. The alarm would only attract attention. Set an alarm anyway?" + deaf_text ) : - _( "You have an alarm clock. Set an alarm?" + deaf_text ); + _( "You have an alarm clock. Set an alarm?" + deaf_text ); as_m.entries.emplace_back( 0, true, get_option( "FORCE_CAPITAL_YN" ) ? 'N' : 'n', diff --git a/src/json.cpp b/src/json.cpp index dfe92a279e103..c53fc7276fc5b 100644 --- a/src/json.cpp +++ b/src/json.cpp @@ -1042,7 +1042,7 @@ number_sci_notation JsonIn::get_any_int() error( "Integers cannot have a decimal point or negative order of magnitude." ); } // Manually apply scientific notation, since std::pow converts to double under the hood. - for( int i = 0; i < n.exp; i++ ) { + for( int64_t i = 0; i < n.exp; i++ ) { if( n.number > std::numeric_limits::max() / 10ULL ) { error( "Specified order of magnitude too large -- encountered overflow applying it." ); } diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index aa52db76e3824..7a59435eca528 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -2293,8 +2293,8 @@ void mapgen_generic_house( mapgendata &dat, int variant ) // West external wall lw = rng( 0, 4 ); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) // Middle wall between bedroom & kitchen/bath + // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) mw = lw + rng( 7, 10 ); // East external wall rw = SEEX * 2 - rng( 1, 5 ); @@ -2302,8 +2302,8 @@ void mapgen_generic_house( mapgendata &dat, int variant ) tw = rng( 1, 6 ); // South external wall bw = SEEX * 2 - rng( 2, 5 ); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) // Middle wall between living room & kitchen/bed + // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) cw = tw + rng( 4, 7 ); //reserving some space for backyard. Actual south external wall. actual_house_height = bw - rng( 4, 6 ); diff --git a/src/mondefense.cpp b/src/mondefense.cpp index 73e0e5974f25e..dbbc13b0863cb 100644 --- a/src/mondefense.cpp +++ b/src/mondefense.cpp @@ -30,8 +30,6 @@ static const skill_id skill_gun( "gun" ); static const skill_id skill_rifle( "rifle" ); -std::vector closest_tripoints_first( int radius, const tripoint &p ); - void mdefense::none( monster &, Creature *, const dealt_projectile_attack * ) { } diff --git a/src/npcmove.cpp b/src/npcmove.cpp index ed96700495e4c..fcd453f21a376 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -804,12 +804,10 @@ void npc::move() if( has_stashed_activity() ) { if( !check_outbounds_activity( get_stashed_activity(), true ) ) { assign_stashed_activity(); - action = npc_player_activity; } else { // wait a turn, because next turn, the object of our activity // may have been loaded in. set_moves( 0 ); - action = npc_pause; } return; } diff --git a/src/player_display.cpp b/src/player_display.cpp index 4d180d867f8de..4ff479fe9602a 100644 --- a/src/player_display.cpp +++ b/src/player_display.cpp @@ -345,7 +345,7 @@ static void draw_stats_tab( const catacurses::window &w_stats, const catacurses: const int lines = fold_and_print( w_info, point( 1, 0 ), FULL_SCREEN_WIDTH - 2, c_magenta, _( "Your weight is a general indicator of how much fat your body has stored up," " which in turn shows how prepared you are to survive for a time without food." - " Having too much, or too little, can be unhealthy." ) ); + " Having too much, or too little, can be unhealthy." ) ); fold_and_print( w_info, point( 1, 1 + lines ), FULL_SCREEN_WIDTH - 2, c_magenta, you.get_weight_description() ); } diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index 7665627051f85..99399eb2751e6 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -85,14 +85,11 @@ static auto can_refill = []( const vehicle_part &pt ) return pt.can_reload(); }; -namespace -{ static const quality_id LIFT( "LIFT" ); static const quality_id JACK( "JACK" ); static const quality_id SELF_JACK( "SELF_JACK" ); static const skill_id skill_mechanics( "mechanics" ); static const itype_id fuel_type_battery( "battery" ); -} // namespace void act_vehicle_siphon( vehicle *veh ); void act_vehicle_unload_fuel( vehicle *veh ); diff --git a/tests/active_item_cache.cpp b/tests/active_item_cache.cpp index a3f0fbb26c2c2..f5cb49a12831a 100644 --- a/tests/active_item_cache.cpp +++ b/tests/active_item_cache.cpp @@ -37,7 +37,7 @@ TEST_CASE( "place_active_item_at_various_coordinates", "[item]" ) CHECK( !g->m.get_submaps_with_active_items().empty() ); CHECK( g->m.get_submaps_with_active_items().find( abs_loc ) != g->m.get_submaps_with_active_items().end() ); - CHECK( g->m.i_at( { x, y, z } ).size() != 0 ); + CHECK( !g->m.i_at( { x, y, z } ).empty() ); g->m.i_clear( { x, y, z } ); } }