From 9084002bec7a5c46c47bdcd90b2d07e7db397dac Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 9 Oct 2024 17:04:40 +0000 Subject: [PATCH] Per #2887, more SonarQube tweaks --- src/libcode/vx_stat_out/stat_columns.cc | 46 +++++++++---------- src/libcode/vx_statistics/contable_nx2.cc | 2 +- .../core/stat_analysis/aggr_stat_line.cc | 17 +++---- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index f78db442c0..80892c6cb7 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -162,7 +162,6 @@ void write_pct_header_row(int hdr_flag, int n_thresh, AsciiTable &at, void write_pstd_header_row(int hdr_flag, int n_thresh, AsciiTable &at, int r, int c) { - int col; char tmp_str[max_str_len]; // Write the header column names if requested @@ -194,7 +193,8 @@ void write_pstd_header_row(int hdr_flag, int n_thresh, AsciiTable &at, at.set_entry(r, c+16, (string)pstd_columns[16]); // Write THRESH_i for each threshold - for(int i=0, col=c+17; irhist_na.n_elements(); i++) { at.set_entry(r, col, // RANK_i @@ -4477,7 +4477,6 @@ void write_rhist_cols(const PairDataEnsemble *pd_ptr, void write_phist_cols(const PairDataEnsemble *pd_ptr, AsciiTable &at, int r, int c) { - int col; // // Probability Integral Transform Histogram @@ -4496,6 +4495,7 @@ void write_phist_cols(const PairDataEnsemble *pd_ptr, // // Write BIN_i count for each bin // + int col = c+3; for(int i=0, col=c+3; iphist_na.n_elements(); i++) { at.set_entry(r, col, // BIN_i @@ -4510,7 +4510,6 @@ void write_phist_cols(const PairDataEnsemble *pd_ptr, void write_orank_cols(const PairDataEnsemble *pd_ptr, int i, AsciiTable &at, int r, int c) { - int col; // // Ensemble Observation Rank Matched Pairs @@ -4564,7 +4563,8 @@ void write_orank_cols(const PairDataEnsemble *pd_ptr, int i, // // Write ENS_j for each ensemble member // - for(int j=0, col=c+12; jn_ens; j++) { + int col = c+12; + for(int j=0; jn_ens; j++) { at.set_entry(r, col, // ENS_j pd_ptr->e_na[j][i]); @@ -4758,7 +4758,6 @@ void write_ssvar_cols(const PairDataEnsemble *pd_ptr, int i, void write_relp_cols(const PairDataEnsemble *pd_ptr, AsciiTable &at, int r, int c) { - int col; // // Relative Position @@ -4774,6 +4773,7 @@ void write_relp_cols(const PairDataEnsemble *pd_ptr, // // Write RELP_i count for each bin // + int col = c+2; for(int i=0, col=c+2; irelp_na.n_elements(); i++) { at.set_entry(r, col, // RELP_i diff --git a/src/libcode/vx_statistics/contable_nx2.cc b/src/libcode/vx_statistics/contable_nx2.cc index dbd4e00d27..b41ec7a798 100644 --- a/src/libcode/vx_statistics/contable_nx2.cc +++ b/src/libcode/vx_statistics/contable_nx2.cc @@ -271,7 +271,7 @@ double Nx2ContingencyTable::baser_ci(double alpha, double &cl, double &cu) const { double v = baser(); - compute_proportion_ci(v, total(), alpha, 1.0, cl, cu); + compute_proportion_ci(v, Npairs, alpha, 1.0, cl, cu); return v; } diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index bf95b6fea7..d3f7bd745a 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -596,7 +596,6 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, StringArray req_col; STATLineType lty; NumArray empty_na; - int n_add; double v; double w; @@ -723,7 +722,8 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, // // Update the map entries for each requested statistic // - for(int i=0, n_add=0; isecond.mse_oerr_na.wmean(it->second.ens_pd.wgt_na); it->second.ens_pd.rmse_oerr = (is_bad_data(v) ? bad_data_double : sqrt(v)); - double crps_emp = it->second.ens_pd.crps_emp_na.wmean(it->second.ens_pd.wgt_na); - double crps_emp_fair = it->second.ens_pd.crps_emp_fair_na.wmean(it->second.ens_pd.wgt_na); - double spread_md = it->second.ens_pd.spread_md_na.wmean(it->second.ens_pd.wgt_na); - double crpscl_emp = it->second.ens_pd.crpscl_emp_na.wmean(it->second.ens_pd.wgt_na); - double crps_gaus = it->second.ens_pd.crps_gaus_na.wmean(it->second.ens_pd.wgt_na); - double crpscl_gaus = it->second.ens_pd.crpscl_gaus_na.wmean(it->second.ens_pd.wgt_na); + double crps_emp = it->second.ens_pd.crps_emp_na.wmean(it->second.ens_pd.wgt_na); + double crpscl_emp = it->second.ens_pd.crpscl_emp_na.wmean(it->second.ens_pd.wgt_na); + double crps_gaus = it->second.ens_pd.crps_gaus_na.wmean(it->second.ens_pd.wgt_na); + double crpscl_gaus = it->second.ens_pd.crpscl_gaus_na.wmean(it->second.ens_pd.wgt_na); // Compute aggregated empirical CRPSS it->second.ens_pd.crpss_emp = @@ -3017,7 +3015,7 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, aggr.ens_pd.extend(cur.total); for(int i=0; i