Skip to content

Commit

Permalink
Per #1019, second pass through to further reduce SonarQube findings.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway committed Jan 15, 2025
1 parent 8a9b02a commit 65dd8ec
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/basic/vx_util/data_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DataLine {
friend std::ostream & operator<<(std::ostream &, const DataLine &);
friend Logger & operator<<(Logger &, const DataLine &);

protected:
private:

std::string Line;
std::vector<std::string> Items;
Expand Down
6 changes: 0 additions & 6 deletions src/basic/vx_util/num_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ using namespace std;
////////////////////////////////////////////////////////////////////////


NumArray::NumArray() {}


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


NumArray::~NumArray()

{
Expand Down
2 changes: 1 addition & 1 deletion src/basic/vx_util/num_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NumArray {

public:

NumArray();
NumArray() = default;
~NumArray();
NumArray(const NumArray &);
explicit NumArray(const std::vector<double> &a) : e(a) {};
Expand Down
7 changes: 2 additions & 5 deletions src/basic/vx_util/observation.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,7 @@ class Observation

}

protected:

///////////////////////
// Protected members //
///////////////////////
private:

std::string _headerType;
std::string _stationId;
Expand All @@ -230,6 +226,7 @@ class Observation
double _height;
double _value;

protected:

///////////////////////
// Protected methods //
Expand Down
6 changes: 1 addition & 5 deletions src/libcode/vx_summary/summary_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@ class SummaryKey
return _varCode < other._varCode;
}

protected:

///////////////////////
// Protected members //
///////////////////////
private:

std::string _headerType;
std::string _stationId;
Expand Down
13 changes: 5 additions & 8 deletions src/libcode/vx_summary/summary_obs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,16 @@ class SummaryObs
long countHeaders(std::vector< Observation > &obs_vector);
long countSummaryHeaders();
time_t getValidTime(const std::string &time_string) const;
TimeSummaryInfo getSummaryInfo();
TimeSummaryInfo getSummaryInfo() const;
void setSummaryInfo(const TimeSummaryInfo &summary_info);
StringArray getObsNames() const;
StringArray getObsUnits() const;
StringArray getObsDescs() const;

protected:
private:

static const float FILL_VALUE;


///////////////////////
// Protected members //
///////////////////////

bool dataSummarized;
TimeSummaryInfo summaryInfo;

Expand All @@ -76,6 +71,8 @@ class SummaryObs
StringArray obs_units;
StringArray obs_descs;

protected:

///////////////////////
// Protected methods //
///////////////////////
Expand Down Expand Up @@ -263,7 +260,7 @@ inline StringArray SummaryObs::getObsUnits() const { return obs_uni
inline StringArray SummaryObs::getObsDescs() const { return obs_descs; }
inline void SummaryObs::setSummaryInfo(const TimeSummaryInfo &summary_info)
{ summaryInfo = summary_info; }
inline TimeSummaryInfo SummaryObs::getSummaryInfo() { return summaryInfo; }
inline TimeSummaryInfo SummaryObs::getSummaryInfo() const { return summaryInfo; }

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

Expand Down
9 changes: 4 additions & 5 deletions src/libcode/vx_tc_util/pair_data_genesis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,14 @@ void PairDataGenesis::add_fcst_gen(const GenesisInfo *fgi) {

if(!fgi) return;

GenesisPairDiff diff;

// Add the unmatched forecast
NPair++;
BestStormId.add(na_str);
InitTime.add(fgi->init());
LeadTime.add(fgi->genesis_lead());
FcstGen.emplace_back(fgi);
BestGen.emplace_back((GenesisInfo *) 0);
BestGen.emplace_back(nullptr);
GenesisPairDiff diff;
GenDiff.emplace_back(diff);

return;
Expand Down Expand Up @@ -296,7 +295,7 @@ void PairDataGenesis::add_best_gen(const GenesisInfo *bgi,
BestStormId.add(bgi->storm_id());
InitTime.add(init_ut);
LeadTime.add(bgi->genesis_time() - init_ut);
FcstGen.emplace_back((GenesisInfo *) 0);
FcstGen.emplace_back(nullptr);
BestGen.emplace_back(bgi);
GenDiff.emplace_back(diff);
}
Expand All @@ -313,7 +312,6 @@ void PairDataGenesis::add_gen_pair(const GenesisInfo *fgi,
if(!fgi || !bgi) return;

int i_case;
GenesisPairDiff diff;

// Update an existing case
if(has_case(bgi->storm_id(), fgi->init(), i_case)) {
Expand All @@ -328,6 +326,7 @@ void PairDataGenesis::add_gen_pair(const GenesisInfo *fgi,
LeadTime.add(fgi->genesis_lead());
FcstGen.emplace_back(fgi);
BestGen.emplace_back(bgi);
GenesisPairDiff diff;
GenDiff.emplace_back(diff);
}

Expand Down
21 changes: 7 additions & 14 deletions src/libcode/vx_tc_util/track_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,10 @@ ConcatString TrackInfo::serialize() const {
ConcatString TrackInfo::serialize_r(int n, int indent_depth) const {
Indent prefix(indent_depth);
ConcatString s;
int i;

s << prefix << "[" << n << "] " << serialize() << ", Points:\n";

for(i=0; i<NPoints; i++)
for(int i=0; i<NPoints; i++)
s << Point[i].serialize_r(i+1, indent_depth+1);

return s;
Expand All @@ -206,7 +205,6 @@ ConcatString TrackInfo::serialize_r(int n, int indent_depth) const {
////////////////////////////////////////////////////////////////////////

void TrackInfo::assign(const TrackInfo &t) {
int i;

clear();

Expand Down Expand Up @@ -238,7 +236,7 @@ void TrackInfo::assign(const TrackInfo &t) {

extend(t.NPoints);

for(i=0; i<t.NPoints; i++) Point[i] = t.Point[i];
for(int i=0; i<t.NPoints; i++) Point[i] = t.Point[i];

NPoints = t.NPoints;

Expand Down Expand Up @@ -522,13 +520,12 @@ bool TrackInfo::add(const ATCFTrackLine &l, bool check_dup, bool check_anly) {

void TrackInfo::add_watch_warn(const ConcatString &ww_sid,
WatchWarnType ww_type, unixtime ww_ut) {
int i;

// Check for a matching storm id
if(storm_id() != ww_sid) return;

// Loop over the TrackPoints
for(i=0; i<NPoints; i++) Point[i].set_watch_warn(ww_type, ww_ut);
for(int i=0; i<NPoints; i++) Point[i].set_watch_warn(ww_type, ww_ut);

return;
}
Expand Down Expand Up @@ -784,11 +781,10 @@ void TrackInfoArray::clear() {

void TrackInfoArray::dump(ostream &out, int indent_depth) const {
Indent prefix(indent_depth);
int i;

out << prefix << "NTracks = " << Track.size() << "\n";

for(i=0; i<Track.size(); i++) {
for(int i=0; i<Track.size(); i++) {
out << prefix << "TrackInfo[" << i+1 << "]:" << "\n";
Track[i].dump(out, indent_depth+1);
}
Expand Down Expand Up @@ -816,11 +812,10 @@ ConcatString TrackInfoArray::serialize() const {
ConcatString TrackInfoArray::serialize_r(int indent_depth) const {
Indent prefix(indent_depth);
ConcatString s;
int i;

s << prefix << serialize() << ", Tracks:\n";

for(i=0; i<Track.size(); i++)
for(int i=0; i<Track.size(); i++)
s << Track[i].serialize_r(i+1, indent_depth+1) << "\n";

return s;
Expand All @@ -830,11 +825,10 @@ ConcatString TrackInfoArray::serialize_r(int indent_depth) const {
////////////////////////////////////////////////////////////////////////

void TrackInfoArray::assign(const TrackInfoArray &t) {
int i;

clear();

for(i=0; i<t.n(); i++) Track.emplace_back(t[i]);
for(int i=0; i<t.n(); i++) Track.emplace_back(t[i]);

return;
}
Expand Down Expand Up @@ -938,10 +932,9 @@ bool TrackInfoArray::has(const ATCFTrackLine &l) const {

bool TrackInfoArray::erase_storm_id(const ConcatString &s) {
bool status = false;
int i;

// Erase all tracks with this storm id
for(i=0; i<Track.size(); i++) {
for(int i=0; i<Track.size(); i++) {
if(Track[i].storm_id() == s) {
Track.erase(Track.begin()+i);
i--;
Expand Down
13 changes: 3 additions & 10 deletions src/tools/other/ascii2nc/file_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,10 @@ class FileHandler
void setSummaryInfo(const TimeSummaryInfo &summary_info);
void setValidTimeRange(const time_t &valid_beg, const time_t valid_end);

protected:

/////////////////////////
// Protected constants //
/////////////////////////
privte:

static const float FILL_VALUE;


///////////////////////
// Protected members //
///////////////////////

std::string _programName;

// Variables for writing output NetCDF file
Expand Down Expand Up @@ -119,6 +110,8 @@ class FileHandler
int num_observations_in_range;
int num_observations_out_of_range;

protected:

///////////////////////
// Protected methods //
///////////////////////
Expand Down
6 changes: 3 additions & 3 deletions src/tools/other/ascii2nc/uscrn_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class UscrnHandler : public FileHandler {
public:

explicit UscrnHandler(const std::string &program_name);
virtual ~UscrnHandler() final = default;
~UscrnHandler() final = default;

virtual bool isFileType(LineDataFile &ascii_file) const final;
bool isFileType(LineDataFile &ascii_file) const final;

static std::string getFormatString() { return "uscrn"; }

Expand All @@ -91,7 +91,7 @@ class UscrnHandler : public FileHandler {

// Read the observations and add them to the
// _observations vector
virtual bool _readObservations(LineDataFile &ascii_file) final;
bool _readObservations(LineDataFile &ascii_file) final;

};

Expand Down

0 comments on commit 65dd8ec

Please sign in to comment.