diff options
author | ypostolov <ypostolov@luxoft.com> | 2020-01-09 19:50:09 +0200 |
---|---|---|
committer | yurii <ypostolov> | 2020-03-26 15:02:49 +0200 |
commit | de558d3874d5cab610a4fe84d86af6b2b736977e (patch) | |
tree | 238b69cfb2ab483af1cc84b1866342d64a39e928 | |
parent | e31ca4b244402c61674c54e17a836adb79060896 (diff) | |
download | sdl_core-de558d3874d5cab610a4fe84d86af6b2b736977e.tar.gz |
fix cppcheck issues in component policy
27 files changed, 44 insertions, 11 deletions
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index d8819b6bad..540698b686 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -166,6 +166,7 @@ struct LinkCollector typedef std::vector<policy_table::UserConsentRecords::key_type> ApplicationsIds; + // cppcheck-suppress noExplicitConstructor LinkCollector(std::map<std::string, std::string>& links) : links_(links) {} void operator()(const policy_table::DeviceData::value_type& value) { @@ -208,10 +209,12 @@ struct ExternalConsentConsentGroupAppender }; struct DefaultPolicyUpdater { + // cppcheck-suppress noExplicitConstructor DefaultPolicyUpdater(const policy_table::ApplicationParams& default_params) : default_params_(default_params) {} - void operator()(policy_table::ApplicationPolicies::value_type& pt_value) { + void operator()( + policy_table::ApplicationPolicies::value_type& pt_value) const { if (policy::kDefaultId == pt_value.second.get_string()) { pt_value.second = default_params_; pt_value.second.set_to_string(policy::kDefaultId); @@ -2297,6 +2300,7 @@ bool CacheManager::IsMetaInfoPresent() const { CACHE_MANAGER_CHECK(false); bool result = true; sync_primitives::AutoLock lock(cache_lock_); + // cppcheck-suppress redundantAssignment result = NULL != pt_->policy_table.module_meta->ccpu_version && NULL != pt_->policy_table.module_meta->wers_country_code && NULL != pt_->policy_table.module_meta->language; diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index b8bbb1682c..b6634980f9 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -102,6 +102,7 @@ bool CompareGroupName::operator()( return !(strcasecmp(gn_.c_str(), gn_compare.c_str())); } +// cppcheck-suppress unusedFunction bool operator!=(const policy_table::ApplicationParams& first, const policy_table::ApplicationParams& second) { if (first.groups.size() != second.groups.size()) { @@ -622,6 +623,7 @@ bool CheckAppPolicy::IsConsentRequired(const std::string& app_id, policy_table::Strings::iterator it2 = std::find(pre_begin, pre_end, str); + // cppcheck-suppress redundantAssignment is_preconsented = pre_end != it2; return it->second.user_consent_prompt.is_initialized() && !is_preconsented; @@ -957,6 +959,7 @@ void FillNotificationData::UpdateParameters( // If 'parameters' section is omitted if (!in_parameters.is_initialized()) { + // cppcheck-suppress redundantCondition if (!does_require_user_consent_ || (does_require_user_consent_ && kAllowedKey == current_key_)) { out_parameter.any_parameter_allowed = true; @@ -1255,6 +1258,7 @@ FunctionalGroupIDs Merge(const FunctionalGroupIDs& first, return merged; } +// cppcheck-suppress unusedFunction FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first, const FunctionalGroupIDs& second) { LOG4CXX_INFO(logger_, "Find same groups"); diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 35dcd2a272..a66865bf5a 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -62,6 +62,7 @@ namespace { struct GroupNamesAppender : public std::unary_function<void, const policy::FunctionalGroupPermission&> { + // cppcheck-suppress noExplicitConstructor GroupNamesAppender(policy_table::Strings& names) : names_(names) {} void operator()(const policy::FunctionalGroupPermission& value) { @@ -1837,6 +1838,7 @@ bool PolicyManagerImpl::IsNeedToUpdateExternalConsentStatus( difference_v.resize(new_status_v.size() + existing_status_v.size()); ItemV::iterator ci = difference_v.begin(); + // cppcheck-suppress redundantAssignment ci = std::set_difference(new_status_v.begin(), new_status_v.end(), existing_status_v.begin(), @@ -2400,7 +2402,7 @@ void PolicyManagerImpl::SetDefaultHmiTypes( } struct HMITypeToInt { - int operator()(const policy_table::AppHMITypes::value_type item) { + int operator()(const policy_table::AppHMITypes::value_type item) const { return policy_table::AppHMIType(item); } }; @@ -2600,6 +2602,7 @@ __attribute__((visibility("default"))) policy::PolicyManager* CreateManager() { return new policy::PolicyManagerImpl(); } +// cppcheck-suppress unusedFunction __attribute__((visibility("default"))) void DeleteManager( policy::PolicyManager* pm) { delete pm; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index f0ea154f94..cb33a0085c 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -872,7 +872,6 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { exchange_after_x_days = from.exchange_after_x_days; exchange_after_x_kilometers = from.exchange_after_x_kilometers; - exchange_after_x_days = from.exchange_after_x_days; exchange_after_x_ignition_cycles = from.exchange_after_x_ignition_cycles; timeout_after_x_seconds = from.timeout_after_x_seconds; seconds_between_retries = from.seconds_between_retries; diff --git a/src/components/policy/policy_external/test/counter_test.cc b/src/components/policy/policy_external/test/counter_test.cc index af166f96ad..ed840f528b 100644 --- a/src/components/policy/policy_external/test/counter_test.cc +++ b/src/components/policy/policy_external/test/counter_test.cc @@ -42,6 +42,7 @@ namespace usage_statistics_test { using namespace usage_statistics; +// cppcheck-suppress syntaxError TEST( StatisticsManagerIncrementMethod1Arg, GlobalCounterOverloadedIncrement_CallONCE_StatisticsManagerIncrementCalledONCE) { diff --git a/src/components/policy/policy_external/test/generated_code_test.cc b/src/components/policy/policy_external/test/generated_code_test.cc index 03cfae511b..8de4bc0b7e 100644 --- a/src/components/policy/policy_external/test/generated_code_test.cc +++ b/src/components/policy/policy_external/test/generated_code_test.cc @@ -59,6 +59,7 @@ TEST(PolicyGeneratedCodeTest, TestValidPTPreloadJsonIsValid) { ASSERT_RPCTYPE_VALID(table); } +// cppcheck-suppress syntaxError TEST(PolicyGeneratedCodeTest, TestValidPTUpdateJsonIsValid) { std::ifstream json_file("json/valid_sdl_pt_update.json"); ASSERT_TRUE(json_file.is_open()); diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc index d5be757139..255b6bddcf 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc @@ -52,6 +52,7 @@ using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; +// cppcheck-suppress syntaxError TEST_F(PolicyManagerImplTest, DISABLED_TiggerPTUForNaviAppInCaseNoCertificateExistsInPolicyTable) { EXPECT_CALL(*cache_manager_, GetDeviceConsent(_)) diff --git a/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc index f89a2ce0c7..118ed2ded1 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc @@ -44,6 +44,7 @@ namespace policy_test { using ::testing::Return; +// cppcheck-suppress syntaxError TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) { // Arrange necessary pre-conditions StringsForUpdate new_data; diff --git a/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc index f886108463..85589cfed6 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_stress_test.cc @@ -231,6 +231,7 @@ void PolicyManagerImplStressTest::CreateTable(std::ofstream& ofs) { ofs << "} } }"; } +// cppcheck-suppress syntaxError TEST_F(PolicyManagerImplStressTest, OneCheck_AppAndFunctuionExisting_RpcAllowed) { EXPECT_CALL(*mock_listener, OnCurrentDeviceIdUpdateRequired(_)); diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index 388630a68f..e312850c14 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -57,6 +57,7 @@ TEST_F(PolicyManagerImplTest, GetNotificationsNumber) { EXPECT_EQ(notif_number, policy_manager_->GetNotificationsNumber(priority)); } +// cppcheck-suppress syntaxError TEST_F(PolicyManagerImplTest, IncrementGlobalCounter) { // Assert EXPECT_CALL(*cache_manager_, Increment(usage_statistics::SYNC_REBOOTS)); diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc index 7c2d231708..f69db73375 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc @@ -62,6 +62,7 @@ char GenRandomChar(char range_from, char range_to) { return rand() % range_size + range_from; } +// cppcheck-suppress unusedFunction struct StringsForUpdate CreateNewRandomData(StringsForUpdate& str) { // Generate random date srand(time(NULL)); @@ -83,6 +84,7 @@ struct StringsForUpdate CreateNewRandomData(StringsForUpdate& str) { return str; } +// cppcheck-suppress unusedFunction void CheckIsParamInList(const ::policy::RPCParams& list, const std::string& parameter) { EXPECT_TRUE(std::find(list.begin(), list.end(), parameter) != list.end()) diff --git a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc index 1db23260a8..de9d240fc7 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc @@ -44,6 +44,7 @@ using ::testing::_; using ::testing::Return; // Tests that use device without Consent +// cppcheck-suppress syntaxError TEST_F( PolicyManagerImplTest2, AddApplication_AddNewApplicationFromDeviceWithConsent_ExpectUpdateRequired) { diff --git a/src/components/policy/policy_external/test/shared_library_test.cc b/src/components/policy/policy_external/test/shared_library_test.cc index b7183a9085..0640889b2b 100644 --- a/src/components/policy/policy_external/test/shared_library_test.cc +++ b/src/components/policy/policy_external/test/shared_library_test.cc @@ -45,6 +45,7 @@ namespace policy_test { } } +// cppcheck-suppress syntaxError TEST(SharedLibraryTest, FullTest_OpenLibrarySetSymbolCloseLibrary_ExpectActsWithoutErrors) { // Arrange diff --git a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc index 7d40210ba4..e7b817c04d 100644 --- a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc @@ -274,6 +274,7 @@ const bool SQLPTExtRepresentationTest::in_memory_ = true; } } +// cppcheck-suppress syntaxError TEST_F(SQLPTExtRepresentationTest, DISABLED_GenerateSnapshot_SetPolicyTable_SnapshotIsPresent) { // TODO(AKutsan): APPLINK-31526 Test requires initial preloaded pt for diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc index 2f85f8dc0a..4c2735f150 100644 --- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc @@ -376,6 +376,7 @@ class SQLPTRepresentationTest2 : public ::testing::Test { const uint16_t kAttemptsToOpenPolicyDB = 2u; }; +// cppcheck-suppress syntaxError TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Item) { policy_table::VehicleDataItem rpm; rpm.mark_initialized(); diff --git a/src/components/policy/policy_external/test/update_status_manager_test.cc b/src/components/policy/policy_external/test/update_status_manager_test.cc index 29952bd18e..7b3a857702 100644 --- a/src/components/policy/policy_external/test/update_status_manager_test.cc +++ b/src/components/policy/policy_external/test/update_status_manager_test.cc @@ -112,6 +112,7 @@ class WaitAsync { }; } // namespace +// cppcheck-suppress syntaxError ACTION_P(NotifyAsync, waiter) { waiter->Notify(); } diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 8227090f5f..6d4872b8e0 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -79,6 +79,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "Policy") } struct LanguageFinder { + // cppcheck-suppress noExplicitConstructor LanguageFinder(const std::string& language) : language_(language) {} bool operator()(const policy_table::Languages::value_type& lang) const { return !strcasecmp(language_.c_str(), lang.first.c_str()); @@ -89,10 +90,12 @@ struct LanguageFinder { }; struct PolicyTableUpdater { + // cppcheck-suppress noExplicitConstructor PolicyTableUpdater(const policy_table::ApplicationParams& default_params) : default_params_(default_params) {} - void operator()(policy_table::ApplicationPolicies::value_type& pt_value) { + void operator()( + policy_table::ApplicationPolicies::value_type& pt_value) const { if (policy::kDefaultId == pt_value.second.get_string()) { pt_value.second = default_params_; pt_value.second.set_to_string(policy::kDefaultId); @@ -1314,8 +1317,6 @@ void CacheManager::PersistData() { copy_pt.policy_table.app_policies_section.apps.end(); bool is_revoked = false; - bool is_default_policy; - bool is_predata_policy; for (; app_policy_iter != app_policy_iter_end; ++app_policy_iter) { const std::string app_id = (*app_policy_iter).first; @@ -1325,7 +1326,7 @@ void CacheManager::PersistData() { is_revoked = copy_pt.policy_table.app_policies_section.apps[app_id].is_null(); } - + bool is_default_policy; is_default_policy = copy_pt.policy_table.app_policies_section.apps.end() != copy_pt.policy_table.app_policies_section.apps.find(app_id) && @@ -1334,6 +1335,7 @@ void CacheManager::PersistData() { .get_string(); // TODO(AOleynik): Remove this field from DB + bool is_predata_policy; is_predata_policy = copy_pt.policy_table.app_policies_section.apps.end() != copy_pt.policy_table.app_policies_section.apps.find(app_id) && diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc index 08f1fbb177..b92ad30cec 100644 --- a/src/components/policy/policy_regular/src/policy_helper.cc +++ b/src/components/policy/policy_regular/src/policy_helper.cc @@ -54,9 +54,10 @@ bool CompareStrings(const StringsValueType& first, } struct CheckGroupName { + // cppcheck-suppress noExplicitConstructor CheckGroupName(const policy::StringsValueType& value) : value_(value) {} - bool operator()(const FunctionalGroupNames::value_type& value) { + bool operator()(const FunctionalGroupNames::value_type& value) const { return value.second.second == std::string(value_); } @@ -562,8 +563,7 @@ bool CheckAppPolicy::IsConsentRequired(const std::string& app_id, return false; } - bool is_preconsented = false; - return it->second.user_consent_prompt.is_initialized() && !is_preconsented; + return it->second.user_consent_prompt.is_initialized(); } bool CheckAppPolicy::IsRequestTypeChanged( diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 8d4db9e675..c14f5ddf13 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1701,7 +1701,7 @@ void PolicyManagerImpl::SetDefaultHmiTypes( } struct HMITypeToInt { - int operator()(const policy_table::AppHMITypes::value_type item) { + int operator()(const policy_table::AppHMITypes::value_type item) const { return policy_table::AppHMIType(item); } }; diff --git a/src/components/policy/policy_regular/test/access_remote_impl_test.cc b/src/components/policy/policy_regular/test/access_remote_impl_test.cc index d9dba45ef2..91e104bdca 100644 --- a/src/components/policy/policy_regular/test/access_remote_impl_test.cc +++ b/src/components/policy/policy_regular/test/access_remote_impl_test.cc @@ -60,6 +60,7 @@ TEST(AccessRemoteImplTest, CheckModuleType) { EXPECT_FALSE(access_remote.CheckModuleType("1234", policy_table::MT_CLIMATE)); } +// cppcheck-suppress syntaxError TEST(AccessRemoteImplTest, SetDefaultHmiTypes) { AccessRemoteImpl access_remote; diff --git a/src/components/policy/policy_regular/test/counter_test.cc b/src/components/policy/policy_regular/test/counter_test.cc index c09347fd9c..694618d6c2 100644 --- a/src/components/policy/policy_regular/test/counter_test.cc +++ b/src/components/policy/policy_regular/test/counter_test.cc @@ -49,6 +49,7 @@ using namespace usage_statistics; // C - Input data // D - Expected result +// cppcheck-suppress syntaxError TEST( StatisticsManagerIncrementMethod1Arg, GlobalCounterOverloadedIncrement_CallONCE_StatisticsManagerIncrementCalledONCE) { diff --git a/src/components/policy/policy_regular/test/generated_code_test.cc b/src/components/policy/policy_regular/test/generated_code_test.cc index 2b79ef67fe..0e0f3b5856 100644 --- a/src/components/policy/policy_regular/test/generated_code_test.cc +++ b/src/components/policy/policy_regular/test/generated_code_test.cc @@ -57,6 +57,7 @@ TEST(PolicyGeneratedCodeTest, TestValidPTPreloadJsonIsValid) { ASSERT_RPCTYPE_VALID(table); } +// cppcheck-suppress syntaxError TEST(PolicyGeneratedCodeTest, TestValidPTUpdateJsonIsValid) { std::ifstream json_file("valid_sdl_pt_update.json"); ASSERT_TRUE(json_file.is_open()); diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index abf9a2ec14..bf004eebae 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -598,6 +598,7 @@ Json::Value CreatePTforLoad() { return table; } +// cppcheck-suppress syntaxError TEST_F(PolicyManagerImplTest, GetNotificationsNumber) { const std::string priority = "EMERGENCY"; const uint32_t notif_number = 100u; diff --git a/src/components/policy/policy_regular/test/shared_library_test.cc b/src/components/policy/policy_regular/test/shared_library_test.cc index b7183a9085..0640889b2b 100644 --- a/src/components/policy/policy_regular/test/shared_library_test.cc +++ b/src/components/policy/policy_regular/test/shared_library_test.cc @@ -45,6 +45,7 @@ namespace policy_test { } } +// cppcheck-suppress syntaxError TEST(SharedLibraryTest, FullTest_OpenLibrarySetSymbolCloseLibrary_ExpectActsWithoutErrors) { // Arrange diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 30536bbaa4..10ec70e128 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -428,6 +428,7 @@ class SQLPTRepresentationTest3 : public ::testing::Test { const std::string kAppStorageFolder; }; +// cppcheck-suppress syntaxError TEST_F(SQLPTRepresentationTest, VehicleDataItem_Store_Item) { policy_table::VehicleDataItem rpm; rpm.mark_initialized(); diff --git a/src/components/policy/policy_regular/test/update_status_manager_test.cc b/src/components/policy/policy_regular/test/update_status_manager_test.cc index 459913fe72..1b65465ff3 100644 --- a/src/components/policy/policy_regular/test/update_status_manager_test.cc +++ b/src/components/policy/policy_regular/test/update_status_manager_test.cc @@ -61,6 +61,7 @@ class UpdateStatusManagerTest : public ::testing::Test { void TearDown() OVERRIDE {} }; +// cppcheck-suppress syntaxError TEST_F(UpdateStatusManagerTest, OnAppSearchStartedCompleted_ExpectAppSearchCorrectStatus) { // Arrange diff --git a/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc b/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc index 02818887a5..7e9cfef0c2 100644 --- a/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc +++ b/src/components/policy/policy_regular/test/vehicle_data_item_type_test.cc @@ -142,6 +142,7 @@ class VehicleDataItemTypeTest : public ::testing::Test { utils::JsonReader reader_; }; +// cppcheck-suppress syntaxError TEST_F(VehicleDataItemTypeTest, Initialize_Success) { const std::string str = GetFullJsonString(); reader_.parse(str, &json_); |