Skip to content

Commit

Permalink
Per #3012, changes to the vx_grid library to address SonarQube code s…
Browse files Browse the repository at this point in the history
…mells in New Code and hopefully reduce the Overall number of code smells.
  • Loading branch information
MET Tools Test Account committed Dec 13, 2024
1 parent edeb3fd commit 2495099
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 105 deletions.
80 changes: 43 additions & 37 deletions src/libcode/vx_grid/grid_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void UnstructuredData::dump() const {
mlog << Debug(grid_debug_level)
<< "\nUnstructured Grid Data:\n"
<< " n_face: " << n_face << "\n"
<< " points: " << (0 < points_lonlat.size() ? "PointLonLat" : "PointXYZ") << "\n"
<< " points: " << (points_lonlat.empty() ? "PointXYZ" : "PointLonLat") << "\n"
<< " lat_checksum: " << lat_checksum << "\n"
<< " lon_checksum: " << lon_checksum << "\n"
<< " alt_checksum: " << alt_checksum << "\n"
Expand Down Expand Up @@ -443,18 +443,18 @@ void GridInfo::clear()

{

if ( lc ) { delete lc; lc = (const LambertData *) nullptr; };
if ( st ) { delete st; st = (const StereographicData *) nullptr; };
if ( ll ) { delete ll; ll = (const LatLonData *) nullptr; };
if ( rll ) { delete rll; rll = (const RotatedLatLonData *) nullptr; };
if ( m ) { delete m; m = (const MercatorData *) nullptr; };
if ( g ) { delete g; g = (const GaussianData *) nullptr; };
if ( gi ) { delete gi; gi = (const GoesImagerData *) nullptr; };
if ( la ) { delete la; la = (const LaeaData *) nullptr; };
if ( tc ) { delete tc; tc = (const TcrmwData *) nullptr; };
if ( sl ) { delete sl; sl = (const SemiLatLonData *) nullptr; };
if ( lc ) { delete lc; lc = (const LambertData *) nullptr; }
if ( st ) { delete st; st = (const StereographicData *) nullptr; }
if ( ll ) { delete ll; ll = (const LatLonData *) nullptr; }
if ( rll ) { delete rll; rll = (const RotatedLatLonData *) nullptr; }
if ( m ) { delete m; m = (const MercatorData *) nullptr; }
if ( g ) { delete g; g = (const GaussianData *) nullptr; }
if ( gi ) { delete gi; gi = (const GoesImagerData *) nullptr; }
if ( la ) { delete la; la = (const LaeaData *) nullptr; }
if ( tc ) { delete tc; tc = (const TcrmwData *) nullptr; }
if ( sl ) { delete sl; sl = (const SemiLatLonData *) nullptr; }
#ifdef WITH_UGRID
if ( us ) { delete us; us = (const UnstructuredData *) nullptr; };
if ( us ) { delete us; us = (const UnstructuredData *) nullptr; }
#endif

return;
Expand Down Expand Up @@ -556,13 +556,13 @@ void GridInfo::set(const LambertData & data)

clear();

LambertData * D = (LambertData *) nullptr;
LambertData * D = nullptr;

D = new LambertData;

memcpy(D, &data, sizeof(data));

lc = D; D = (LambertData *) nullptr;
lc = D; D = nullptr;

return;

Expand All @@ -578,13 +578,13 @@ void GridInfo::set(const StereographicData & data)

clear();

StereographicData * D = (StereographicData *) nullptr;
StereographicData * D = nullptr;

D = new StereographicData;

memcpy(D, &data, sizeof(data));

st = D; D = (StereographicData *) nullptr;
st = D; D = nullptr;

return;

Expand All @@ -600,13 +600,13 @@ void GridInfo::set(const LatLonData & data)

clear();

LatLonData * D = (LatLonData *) nullptr;
LatLonData * D = nullptr;

D = new LatLonData;

memcpy(D, &data, sizeof(data));

ll = D; D = (LatLonData *) nullptr;
ll = D; D = nullptr;

return;

Expand All @@ -622,13 +622,13 @@ void GridInfo::set(const RotatedLatLonData & data)

clear();

RotatedLatLonData * D = (RotatedLatLonData *) nullptr;
RotatedLatLonData * D = nullptr;

D = new RotatedLatLonData;

memcpy(D, &data, sizeof(data));

rll = D; D = (RotatedLatLonData *) nullptr;
rll = D; D = nullptr;

return;

Expand All @@ -644,13 +644,13 @@ void GridInfo::set(const MercatorData & data)

clear();

MercatorData * D = (MercatorData *) nullptr;
MercatorData * D = nullptr;

D = new MercatorData;

memcpy(D, &data, sizeof(data));

m = D; D = (MercatorData *) nullptr;
m = D; D = nullptr;

return;

Expand All @@ -666,13 +666,13 @@ void GridInfo::set(const GaussianData & data)

clear();

GaussianData * D = (GaussianData *) nullptr;
GaussianData * D = nullptr;

D = new GaussianData;

memcpy(D, &data, sizeof(data));

g = D; D = (GaussianData *) nullptr;
g = D; D = nullptr;

return;

Expand All @@ -688,13 +688,13 @@ void GridInfo::set(const GoesImagerData & data)

clear();

GoesImagerData * D = (GoesImagerData *) nullptr;
GoesImagerData * D = nullptr;

D = new GoesImagerData;

memcpy(D, &data, sizeof(data));

gi = D; D = (GoesImagerData *) nullptr;
gi = D; D = nullptr;

return;

Expand All @@ -710,13 +710,13 @@ void GridInfo::set(const LaeaData & data)

clear();

LaeaData * D = (LaeaData *) nullptr;
LaeaData * D = nullptr;

D = new LaeaData;

memcpy(D, &data, sizeof(data));

la = D; D = (LaeaData *) nullptr;
la = D; D = nullptr;

return;

Expand All @@ -732,7 +732,7 @@ void GridInfo::set(const SemiLatLonData & data)

clear();

SemiLatLonData * D = (SemiLatLonData *) nullptr;
SemiLatLonData * D = nullptr;

D = new SemiLatLonData;

Expand All @@ -743,7 +743,7 @@ D = new SemiLatLonData;

*D = data;

sl = D; D = (SemiLatLonData *) nullptr;
sl = D; D = nullptr;

return;

Expand All @@ -760,7 +760,9 @@ void GridInfo::set(const UnstructuredData & data)

clear();

UnstructuredData *D = new UnstructuredData;
UnstructuredData * D = nullptr;

D = new UnstructuredData;

D->n_edge = data.n_edge;
D->n_node = data.n_node;
Expand All @@ -772,7 +774,7 @@ else {
D->set_points(data.n_face, data.points_XYZ);
}
us = D;
D = (UnstructuredData *)nullptr;
D = nullptr;

}
#endif
Expand Down Expand Up @@ -1250,7 +1252,8 @@ if ( (nx_new < 2) || ( ny_new < 2) ) {
}

Grid g_new;
double lat_ll, lon_ll;
double lat_ll;
double lon_ll;
GridInfo info_new = info();


Expand Down Expand Up @@ -1302,7 +1305,8 @@ if ( info_new.lc ) {
} else if ( info_new.m ) {

MercatorData m_new = *(info_new.m);
double lat_ur, lon_ur;
double lat_ur;
double lon_ur;

xy_to_latlon(x_ll + nx_new - 1, y_ll + ny_new - 1, lat_ur, lon_ur);

Expand Down Expand Up @@ -1346,8 +1350,10 @@ Grid Grid::subset_center(double lat_center, double lon_center, int nx_new, int n
// subset_ll does sanity checking on nx_new and ny_new, so we don't have to do it here
//

int ix_ll, iy_ll;
double dx_center, dy_center;
int ix_ll;
int iy_ll;
double dx_center;
double dy_center;


//
Expand Down Expand Up @@ -1732,7 +1738,7 @@ return status;
////////////////////////////////////////////////////////////////////////


int ll_func(double x_center, int N)
static int ll_func(double x_center, int N)

{

Expand Down
Loading

0 comments on commit 2495099

Please sign in to comment.