From a19c1f3a487e396a6e200512138dec07111fb352 Mon Sep 17 00:00:00 2001 From: Dimitri Rusin Date: Mon, 13 Nov 2023 12:55:53 +0100 Subject: [PATCH] Codacy-suggested fixes --- include/ioh/problem/cec/hybrid_function_1.hpp | 1 - include/ioh/problem/cec/hybrid_function_3.hpp | 1 - include/ioh/problem/functions/real.hpp | 3 +- tests/cpp/problem/set_cec_problems.cpp | 44 +++++++++---------- workflows.md | 4 +- 5 files changed, 23 insertions(+), 30 deletions(-) diff --git a/include/ioh/problem/cec/hybrid_function_1.hpp b/include/ioh/problem/cec/hybrid_function_1.hpp index b18915f9b..88ac49fac 100644 --- a/include/ioh/problem/cec/hybrid_function_1.hpp +++ b/include/ioh/problem/cec/hybrid_function_1.hpp @@ -43,7 +43,6 @@ namespace ioh::problem::cec int nx = x.size(); std::vector z(nx); std::vector y(nx); - std::vector fit(cf_num); std::vector G(cf_num); std::vector G_nx(cf_num); std::vector Gp = {0.4, 0.4, 0.2}; diff --git a/include/ioh/problem/cec/hybrid_function_3.hpp b/include/ioh/problem/cec/hybrid_function_3.hpp index fd4ce2a24..cd3d516f8 100644 --- a/include/ioh/problem/cec/hybrid_function_3.hpp +++ b/include/ioh/problem/cec/hybrid_function_3.hpp @@ -27,7 +27,6 @@ namespace ioh::problem::cec auto&& S = this->input_permutation_; const int cf_num = 5; - std::vector fit(cf_num, 0); std::vector G_nx(cf_num); std::vector G(cf_num); std::vector Gp = {0.3, 0.2, 0.2, 0.1, 0.2}; diff --git a/include/ioh/problem/functions/real.hpp b/include/ioh/problem/functions/real.hpp index 9d8c70c5d..e20c14111 100644 --- a/include/ioh/problem/functions/real.hpp +++ b/include/ioh/problem/functions/real.hpp @@ -153,7 +153,6 @@ inline double zakharov(const std::vector &x) { */ inline double schaffer_F7(const std::vector &y) { std::vector z(y.size()); - double tmp; double result = 0; for (size_t i = 0; i < z.size() - 1; ++i) { @@ -163,7 +162,7 @@ inline double schaffer_F7(const std::vector &y) { auto pow_val = std::pow(z[i], 0.2); - tmp = std::sin(50.0 * pow_val); + double tmp = std::sin(50.0 * pow_val); auto tmp_squared = tmp * tmp; diff --git a/tests/cpp/problem/set_cec_problems.cpp b/tests/cpp/problem/set_cec_problems.cpp index 158ab2add..1deef05d7 100644 --- a/tests/cpp/problem/set_cec_problems.cpp +++ b/tests/cpp/problem/set_cec_problems.cpp @@ -105,7 +105,7 @@ int ini_flag,n_flag,func_flag,*SS; void cec22_test_func(double *x, double *f, int nx, int mx,int func_num) { - int cf_num=12,i,j; + int cf_num=12,i; if (func_num<1||func_num>12) { printf("\nError: Test function %d is not defined.\n", func_num); @@ -127,9 +127,9 @@ void cec22_test_func(double *x, double *f, int nx, int mx,int func_num) free(y); free(z); free(x_bound); - y=(double *)malloc(sizeof(double) * nx); - z=(double *)malloc(sizeof(double) * nx); - x_bound=(double *)malloc(sizeof(double) * nx); + y = static_cast(malloc(nx * sizeof(double))); + z = static_cast(malloc(nx * sizeof(double))); + x_bound = static_cast(malloc(nx * sizeof(double))); for (i=0; i(malloc(nx * nx * sizeof(double))); if (M==NULL) printf("\nError: there is insufficient memory available!\n"); for (i=0; i(malloc(cf_num * nx * nx * sizeof(double))); if (M==NULL) printf("\nError: there is insufficient memory available!\n"); for (i=0; i(malloc(nx * sizeof(double))); if (OShift==NULL) printf("\nError: there is insufficient memory available!\n"); for(i=0;i(malloc(nx * cf_num * sizeof(double))); if (OShift==NULL) printf("\nError: there is insufficient memory available!\n"); for(i=0;i(malloc(nx * sizeof(int))); if (SS==NULL) printf("\nError: there is insufficient memory available!\n"); for(i=0;i(malloc(sizeof(double) * nx)); for (i=0; i(malloc(cf_num * sizeof(double))); // Re-allocation for w for (i=0; i(malloc(sizeof(double))); cec22_test_func(instance_input.data(), f, nx, 1, func_num); std::stringstream ss; diff --git a/workflows.md b/workflows.md index 423662209..eef27654d 100644 --- a/workflows.md +++ b/workflows.md @@ -1,5 +1,3 @@ - - You might get this error message: ```sh CMake Error at CMakeLists.txt:52 (add_subdirectory): @@ -76,7 +74,7 @@ g++ -o one_max -g -std=c++17 -I$fmt_include_path -I$ioh_include_path one_max.cpp ``` g++ version -``` +```sh g++ 9.4.0 ```