Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature sonarqube v11 beta2 #2222

Merged
merged 4 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/basic/vx_config/my_config_scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1372,13 +1372,13 @@ if ( (pos2 = s.find('}', pos)) == string::npos ) {

std::string out;
std::string env;
char * env_value = 0;
char * tmp_env_value = 0;

env = s.substr(pos1 + 2, pos2 - pos1 - 2);

env_value = getenv(env.c_str());
tmp_env_value = getenv(env.c_str());

if ( ! env_value ) {
if ( ! tmp_env_value ) {

mlog << Error << "\nreplace_env() -> "
<< "unable to get value for environment variable \""
Expand All @@ -1390,7 +1390,7 @@ if ( ! env_value ) {

out = s.substr(0, pos1);

out += env_value;
out += tmp_env_value;

out += s.substr(pos2 + 1);

Expand Down
1 change: 1 addition & 0 deletions src/basic/vx_log/string_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ s = a.s;

IgnoreCase = a.IgnoreCase;
Sorted = a.Sorted;
MaxLength = a.MaxLength;

return;

Expand Down
1 change: 0 additions & 1 deletion src/libcode/vx_nc_obs/met_point_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ bool MetPointData::get_header(int header_offset, float hdr_arr[HDR_ARRAY_LEN],
////////////////////////////////////////////////////////////////////////

bool MetPointData::get_header_type(int header_offset, int hdr_typ_arr[HDR_TYPE_ARR_LEN]) {
int hdr_idx;
// Read the header integer types
hdr_typ_arr[0] = (header_data.prpt_typ_array.n() > header_offset ?
header_data.prpt_typ_array[header_offset] : bad_data_int);
Expand Down
91 changes: 66 additions & 25 deletions src/libcode/vx_nc_util/nc_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,22 @@ bool get_var_axis(const NcVar *var, ConcatString &att_val) {

////////////////////////////////////////////////////////////////////////

void set_def_fill_value(ncbyte *val) { *val = bad_data_int/100; }
void set_def_fill_value(char *val) { *val = bad_data_char; }
void set_def_fill_value(double *val) { *val = bad_data_double; }
void set_def_fill_value(float *val) { *val = bad_data_float; }
void set_def_fill_value(int *val) { *val = bad_data_int; }
void set_def_fill_value(long *val) { *val = (long)bad_data_int; }
void set_def_fill_value(short *val) { *val = (short)bad_data_int; }
void set_def_fill_value(long long *val) { *val = (long long)bad_data_int; }
void set_def_fill_value(unsigned char *val) { *val = (unsigned char)-1; }
void set_def_fill_value(unsigned int *val) { *val = (unsigned int)-1; }
void set_def_fill_value(unsigned long *val) { *val = (unsigned long)-1; }
void set_def_fill_value(unsigned long long *val) { *val = (unsigned long long)-1; }
void set_def_fill_value(unsigned short *val) { *val = (unsigned short)-1; }

////////////////////////////////////////////////////////////////////////

template <typename T>
bool get_var_fill_value(const NcVar *var, T &att_val) {
bool found = false;
Expand All @@ -1038,6 +1054,7 @@ bool get_var_fill_value(const NcVar *var, T &att_val) {
att->getValues(&att_val);
found = true;
}
else set_def_fill_value(&att_val);

if (att) delete att;

Expand Down Expand Up @@ -1208,7 +1225,7 @@ int get_int_var(NcVar * var, const int index) {
int dim_idx = 0;
int dim_size = get_dim_size(var, dim_idx);
if (0 >= dim_size) {
if ((index > 0) && (0 >= dim_size)) {
if (index > 0) {
mlog << Error << "\n" << method_name << "The start offset ("
<< index << ") should be 0 because of no dimension at the variable "
<< GET_NC_NAME_P(var) << ".\n\n";
Expand Down Expand Up @@ -1654,27 +1671,38 @@ bool get_nc_data(NcVar *var, short *data, const long *dims, const long *curs) {
template <typename T>
void copy_nc_data_t(NcVar *var, float *data, const T *packed_data,
const int cell_count, const char *data_type,
double add_offset, double scale_factor, bool has_missing, T missing_value) {
double add_offset, double scale_factor,
bool has_missing, T missing_value) {
clock_t start_clock = clock();
const char *method_name = "copy_nc_data_t(float) ";

if (cell_count > 0) {
int idx;
int idx, first_idx;
float min_value, max_value;
bool do_scale_factor = has_scale_factor_attr(var) || has_add_offset_attr(var);

idx = first_idx = 0;
if (do_scale_factor) {
int positive_cnt = 0;
int unpacked_count = 0;
T raw_min_val, raw_max_val;

for (idx=0; idx<cell_count; idx++) {
if (!has_missing || !is_eq(missing_value, packed_data[idx])) break;
data[idx] = bad_data_float;
if (has_missing) {
for (; idx<cell_count; idx++) {
if (!is_eq(missing_value, packed_data[idx])) {
first_idx = idx;
break;
}
data[idx] = bad_data_float;
}
}

raw_min_val = raw_max_val = packed_data[first_idx];
if (has_missing && is_eq(missing_value, raw_min_val)) {
min_value = max_value = bad_data_float;
}
else min_value = max_value = ((float)raw_min_val * scale_factor) + add_offset;

raw_min_val = raw_max_val = packed_data[idx];
min_value = max_value = ((float)packed_data[idx] * scale_factor) + add_offset;
for (; idx<cell_count; idx++) {
if (has_missing && is_eq(missing_value, packed_data[idx]))
data[idx] = bad_data_float;
Expand All @@ -1698,15 +1726,17 @@ void copy_nc_data_t(NcVar *var, float *data, const T *packed_data,
<< "] Positive count: " << positive_cnt << "\n";
}
else {
idx = 0;

if (has_missing) {
for (idx=0; idx<cell_count; idx++) {
if (!is_eq(missing_value, packed_data[idx])) break;
for (; idx<cell_count; idx++) {
if (!is_eq(missing_value, packed_data[idx])) {
first_idx = idx;
break;
}
data[idx] = bad_data_float;
}
}
min_value = max_value = (float)packed_data[idx];
min_value = max_value = (float)packed_data[first_idx];
for (; idx<cell_count; idx++) {
if (has_missing && is_eq(missing_value, packed_data[idx]))
data[idx] = bad_data_float;
Expand Down Expand Up @@ -1950,23 +1980,33 @@ void copy_nc_data_t(NcVar *var, double *data, const T *packed_data,
const char *method_name = "copy_nc_data_t(double) ";

if (cell_count > 0) {
int idx;
T missing_value;
int idx, first_idx;
double min_value, max_value;
bool do_scale_factor = has_scale_factor_attr(var) || has_add_offset_attr(var);

idx = first_idx = 0;
if (do_scale_factor) {
int positive_cnt = 0;
T raw_min_val, raw_max_val;

for (idx=0; idx<cell_count; idx++) {
if (!is_eq(missing_value, packed_data[idx])) break;
data[idx] = bad_data_double;
if (has_missing) {
// Skip missing values to find first min/max value
for (; idx<cell_count; idx++) {
if (!is_eq(missing_value, packed_data[idx])) {
first_idx = idx;
break;
}
data[idx] = bad_data_double;
}
}

raw_min_val = raw_max_val = packed_data[first_idx];
if (has_missing && is_eq(missing_value, raw_min_val)) {
min_value = max_value = bad_data_double;
}
else min_value = max_value = ((double)raw_min_val * scale_factor) + add_offset;

raw_min_val = raw_max_val = packed_data[0];
min_value = max_value = ((double)packed_data[0] * scale_factor) + add_offset;
for (int idx=0; idx<cell_count; idx++) {
for (; idx<cell_count; idx++) {
if (has_missing && is_eq(missing_value, packed_data[idx]))
data[idx] = bad_data_double;
else {
Expand All @@ -1988,15 +2028,16 @@ void copy_nc_data_t(NcVar *var, double *data, const T *packed_data,
<< "] Positive count: " << positive_cnt << "\n";
}
else {
idx = 0;

if (has_missing) {
for (idx=0; idx<cell_count; idx++) {
if (!is_eq(missing_value, packed_data[idx])) break;
for (; idx<cell_count; idx++) {
if (!is_eq(missing_value, packed_data[idx])) {
first_idx = idx;
break;
}
data[idx] = bad_data_float;
}
}
min_value = max_value = (double)packed_data[idx];
min_value = max_value = (double)packed_data[first_idx];
for (; idx<cell_count; idx++) {
if (has_missing && is_eq(missing_value, packed_data[idx]))
data[idx] = bad_data_double;
Expand Down
2 changes: 1 addition & 1 deletion src/libcode/vx_pointdata_python/pointdata_from_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void load_numpy (void * buf,

bool need_swap = (shuf != 0) && (native_endian != data_endian);

int j, x, y, r, c;
int j;
T * u = (T *) buf;
T value;

Expand Down
4 changes: 2 additions & 2 deletions src/libcode/vx_pointdata_python/pointdata_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ file_name.chomp(".py"); // remove possible ".py" suffix from script filename

bool status = python_point_data(file_name.c_str(), file_argc, file_argv, use_xarray, met_data);

int hdr_cnt = met_data.get_hdr_cnt();
int obs_cnt = met_data.get_obs_cnt();
met_data.get_hdr_cnt();
met_data.get_obs_cnt();
MetPointHeader *hdr_data = met_data.get_header_data();
MetPointObsData *obs_data = met_data.get_point_obs_data();

Expand Down
10 changes: 4 additions & 6 deletions src/libcode/vx_pointdata_python/python_pointdata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,10 @@ bool straight_python_point_data(const char * script_name, int script_argc, char
{

int int_value;
PyObject * module_obj = 0;
PyObject * module_dict_obj = 0;
PyObject * python_key = 0;
PyObject * python_value = 0;
PyObject * numpy_array_obj = 0;
PyObject * python_met_point_data = 0;
PyObject *module_obj = 0;
PyObject *module_dict_obj = 0;
PyObject *python_value = 0;
PyObject *python_met_point_data = 0;
ConcatString cs, user_dir, user_base;
const char *method_name = "straight_python_point_data -> ";
const char *method_name_s = "straight_python_point_data()";
Expand Down
4 changes: 2 additions & 2 deletions src/tools/other/ioda2nc/ioda2nc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ void process_ioda_file(int i_pb) {
// Initialize
diff_file_time_count = 0;

for(int idx=0; idx<OBS_ARRAY_LEN; idx++) obs_arr[idx] = 0;
for(idx=0; idx<OBS_ARRAY_LEN; idx++) obs_arr[idx] = 0;

// Loop through the IODA messages from the input file
for(i_read=0; i_read<npbmsg; i_read++) {
Expand Down Expand Up @@ -906,9 +906,9 @@ void process_ioda_file(int i_pb) {

void write_netcdf_hdr_data() {
int obs_cnt, hdr_cnt;
const long hdr_count = (long) nc_point_obs.get_hdr_index();
static const string method_name = "\nwrite_netcdf_hdr_data()";

nc_point_obs.get_hdr_index();
nc_point_obs.set_nc_out_data(observations, summary_obs, conf_info.getSummaryInfo());
nc_point_obs.get_dim_counts(&obs_cnt, &hdr_cnt);
nc_point_obs.init_netcdf(obs_cnt, hdr_cnt, program_name);
Expand Down
18 changes: 3 additions & 15 deletions src/tools/other/point2grid/point2grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,10 @@ void process_command_line(int argc, char **argv) {
OutputFilename = cline[2];

// Check if the input file
bool use_python = false;
#ifdef WITH_PYTHON
string python_command = InputFilename;
bool use_xarray = (0 == python_command.find(conf_val_python_xarray));
use_python = use_xarray || (0 == python_command.find(conf_val_python_numpy));
bool use_python = use_xarray || (0 == python_command.find(conf_val_python_numpy));
if (use_python) {
int offset = python_command.find("=");
if (offset == std::string::npos) {
Expand Down Expand Up @@ -376,12 +375,11 @@ void process_data_file() {
mlog << Debug(1) << "Reading data file: " << InputFilename << "\n";
bool goes_data = false;
bool use_python = false;
int obs_type = TYPE_UNKNOWN;
int obs_type;
Met2dDataFileFactory m_factory;
Met2dDataFile *fr_mtddf = (Met2dDataFile *) 0;
#ifdef WITH_PYTHON
string python_command = InputFilename;
MetPointData *met_point_obs = 0;
bool use_xarray = (0 == python_command.find(conf_val_python_xarray));
use_python = use_xarray || (0 == python_command.find(conf_val_python_numpy));
if (use_python) {
Expand Down Expand Up @@ -918,7 +916,7 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI
}

if (cellMapping) {
for (int idx=0; idx<(nx*ny); idx++) cellMapping[idx].clear();
for (idx=0; idx<(nx*ny); idx++) cellMapping[idx].clear();
delete [] cellMapping;
}
cellMapping = new IntArray[nx * ny];
Expand Down Expand Up @@ -1135,19 +1133,13 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI

void process_point_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo,
const Grid to_grid) {
int nhdr, nobs;
int nx, ny, var_count, to_count, var_count2;
int idx, hdr_idx;
int var_idx_or_gc;
int filtered_by_time, filtered_by_msg_type, filtered_by_qc;
ConcatString vname, vname_cnt, vname_mask;
DataPlane fr_dp, to_dp;
DataPlane cnt_dp, mask_dp;
DataPlane prob_dp, prob_mask_dp;
NcVar var_obs_gc, var_obs_var;

clock_t start_clock = clock();
bool has_prob_thresh = !prob_cat_thresh.check(bad_data_double);

unixtime requested_valid_time, valid_time;
static const char *method_name = "process_point_file() -> ";
Expand Down Expand Up @@ -1182,11 +1174,7 @@ void process_point_file(NcFile *nc_in, MetConfig &config, VarInfo *vinfo,

void process_point_python(string python_command, MetConfig &config, VarInfo *vinfo,
const Grid to_grid, bool use_xarray) {
int nhdr, nobs;
int nx, ny, var_count, to_count, var_count2;
int idx, hdr_idx;
int var_idx_or_gc;
int filtered_by_time, filtered_by_msg_type, filtered_by_qc;
ConcatString vname, vname_cnt, vname_mask;
DataPlane fr_dp, to_dp;
DataPlane cnt_dp, mask_dp;
Expand Down