From a085d0685e151bf23b80167dc30e918cd7aefb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= <offringa@gmail.com> Date: Thu, 10 Aug 2023 19:31:13 +0000 Subject: [PATCH] Cpplint linting --- algorithms/antennaselector.cpp | 2 + algorithms/antennaselector.h | 1 + algorithms/applybandpass.h | 1 + algorithms/bandpassfile.h | 6 +- algorithms/baselineselector.cpp | 1 + algorithms/baselinetimeplaneimager.cpp | 4 +- algorithms/fringestoppingfitter.cpp | 8 +-- algorithms/fringestoppingfitter.h | 4 +- algorithms/localfitmethod.cpp | 9 +-- algorithms/medianwindow.h | 1 + algorithms/morphologicalflagger.cpp | 2 + algorithms/noisestatistics.h | 16 +++--- algorithms/resampling.h | 4 ++ algorithms/restorechannelrange.h | 3 + algorithms/siroperator.h | 2 + algorithms/sumthreshold.cpp | 4 +- algorithms/sumthresholdmissing.cpp | 1 + algorithms/svdmitigater.h | 4 +- algorithms/testsetgenerator.cpp | 1 + algorithms/testsetgenerator.h | 1 + algorithms/thresholdconfig.cpp | 3 +- algorithms/thresholdtools.cpp | 1 + aoluarunner/baselineiterator.h | 4 +- aoluarunner/runner.cpp | 15 ++--- aoluarunner/runner.h | 3 +- aoqplot/aoqplotwindow.h | 2 +- aoqplot/baselineplotpage.h | 2 +- aoqplot/blengthplotpage.h | 2 +- aoqplot/datawindow.cpp | 3 +- aoqplot/frequencyplotpage.h | 2 +- aoqplot/grayscaleplotpage.h | 6 +- aoqplot/histogrampage.h | 2 +- aoqplot/summarypage.h | 3 +- aoqplot/timefrequencyplotpage.h | 2 +- aoqplot/twodimensionalplotpage.h | 2 +- applications/aoflagger.cpp | 8 +-- applications/aoqplot.cpp | 3 +- applications/aoquality.cpp | 24 ++++---- applications/badstations.cpp | 7 ++- applications/rfigui.cpp | 4 +- imagesets/imageset.cpp | 26 ++++----- imagesets/imagesetindex.h | 3 +- imagesets/indexableset.cpp | 4 +- imagesets/msimageset.cpp | 7 ++- imagesets/msimageset.h | 2 +- imagesets/multibandmsimageset.h | 2 +- imagesets/rfibaselineset.cpp | 3 +- imagesets/sdhdfimageset.cpp | 3 +- imaging/model.cpp | 4 +- imaging/uvimager.cpp | 4 +- interface/qualitystatistics.cpp | 4 +- lua/data.h | 2 +- lua/datawrapper.cpp | 12 ++-- lua/functions.cpp | 3 +- lua/luathreadgroup.h | 2 +- msio/baselinereader.cpp | 6 +- msio/directbaselinereader.h | 8 +-- msio/memorybaselinereader.cpp | 56 ++++++++++--------- msio/memorybaselinereader.h | 8 +-- msio/msstatreader.cpp | 3 +- msio/parmtable.h | 2 +- msio/reorderingbaselinereader.cpp | 4 +- msio/singlebaselinefile.cpp | 10 ++-- plot/colormap.h | 2 +- plot/heatmap.cpp | 3 +- plot/horizontalplotscale.cpp | 4 +- plot/plotpropertieswindow.cpp | 10 ++-- plot/ticksets/logarithmictickset.h | 3 +- plot/ticksets/numerictickset.h | 8 +-- plot/ticksets/timetickset.h | 39 ++++++------- plot/vectorimage.cpp | 4 +- plot/xyplot.cpp | 24 ++++---- plot/xypointset.h | 7 +-- python/pyinterface.cpp | 4 -- quality/histogramtablesformatter.h | 12 ++-- quality/qualitytablesformatter.cpp | 4 +- quality/qualitytablesformatter.h | 22 ++++---- .../controllers/imagecomparisoncontroller.cpp | 23 ++++---- .../controllers/imagecomparisoncontroller.h | 14 +++-- rfigui/controllers/rfiguicontroller.cpp | 4 +- rfigui/maskedheatmap.cpp | 3 +- rfigui/plotframe.cpp | 4 +- rfigui/plotwindow.cpp | 1 - rfigui/progresswindow.cpp | 2 +- rfigui/progresswindow.h | 2 +- rfigui/rfiguiwindow.cpp | 16 +++--- rfigui/settings.h | 7 ++- rfigui/strategyeditor.cpp | 3 +- rfigui/timefrequencywidget.h | 2 +- scripts/run-cpplint.sh | 3 + structures/msmetadata.h | 12 ++-- structures/timefrequencydata.cpp | 16 +++--- structures/timefrequencydata.h | 28 +++++----- structures/versionstring.h | 5 +- test/lua/flagnanstest.cpp | 2 +- util/numberparser.h | 9 ++- util/process.h | 2 +- 97 files changed, 349 insertions(+), 306 deletions(-) create mode 100755 scripts/run-cpplint.sh diff --git a/algorithms/antennaselector.cpp b/algorithms/antennaselector.cpp index bffd50d9..21572e05 100644 --- a/algorithms/antennaselector.cpp +++ b/algorithms/antennaselector.cpp @@ -1,5 +1,7 @@ #include "antennaselector.h" +#include <utility> + #include "../quality/statisticscollection.h" #include "../quality/statisticsderivator.h" diff --git a/algorithms/antennaselector.h b/algorithms/antennaselector.h index 84ab0f24..459f9f7c 100644 --- a/algorithms/antennaselector.h +++ b/algorithms/antennaselector.h @@ -5,6 +5,7 @@ class StatisticsCollection; class DefaultStatistics; #include <map> +#include <set> #include <vector> namespace algorithms { diff --git a/algorithms/applybandpass.h b/algorithms/applybandpass.h index f853bf49..579bcedc 100644 --- a/algorithms/applybandpass.h +++ b/algorithms/applybandpass.h @@ -6,6 +6,7 @@ #include "bandpassfile.h" #include <string> +#include <utility> namespace algorithms { diff --git a/algorithms/bandpassfile.h b/algorithms/bandpassfile.h index 64b3cfd6..6a82215c 100644 --- a/algorithms/bandpassfile.h +++ b/algorithms/bandpassfile.h @@ -10,7 +10,7 @@ class BandpassFile { public: - BandpassFile(const std::string& filename) { + explicit BandpassFile(const std::string& filename) { std::ifstream file(filename); if (!file) throw std::runtime_error("Can not find bandpass file: '" + filename + @@ -49,9 +49,9 @@ class BandpassFile { size_t channel; bool operator<(const BandpassIndex& rhs) const { - if (channel < rhs.channel) + if (channel < rhs.channel) { return true; - else if (channel == rhs.channel) { + } else if (channel == rhs.channel) { if (polarization < rhs.polarization) return true; else if (polarization == rhs.polarization && antenna < rhs.antenna) diff --git a/algorithms/baselineselector.cpp b/algorithms/baselineselector.cpp index a04ab2d5..c3641af9 100644 --- a/algorithms/baselineselector.cpp +++ b/algorithms/baselineselector.cpp @@ -9,6 +9,7 @@ #include <algorithm> #include <map> +#include <memory> namespace algorithms { diff --git a/algorithms/baselinetimeplaneimager.cpp b/algorithms/baselinetimeplaneimager.cpp index 15613f78..9408b345 100644 --- a/algorithms/baselinetimeplaneimager.cpp +++ b/algorithms/baselinetimeplaneimager.cpp @@ -6,6 +6,7 @@ #include <boost/iterator/iterator_concepts.hpp> +#include <algorithm> #include <cmath> namespace algorithms { @@ -107,9 +108,6 @@ void BaselineTimePlaneImager<NumType>::Image( *destPtr += fftOut[srcXIndex - fftCentre]; } ++destPtr; - // else - // output.SetValue(x, y, 0.0); - // if(x==0 && y==0) Logger::Debug << "srcX=" << srcX << '\n'; } } diff --git a/algorithms/fringestoppingfitter.cpp b/algorithms/fringestoppingfitter.cpp index ecb6cc02..2890da4c 100644 --- a/algorithms/fringestoppingfitter.cpp +++ b/algorithms/fringestoppingfitter.cpp @@ -24,9 +24,9 @@ FringeStoppingFitter::FringeStoppingFitter() FringeStoppingFitter::~FringeStoppingFitter() {} void FringeStoppingFitter::PerformFit(unsigned taskNumber) { - if (_fringeFit) + if (_fringeFit) { PerformDynamicFrequencyFitOnOneChannel(taskNumber, _maxWindowSize); - else { + } else { const size_t x = taskNumber; if (_fitChannelsIndividually) { @@ -140,9 +140,9 @@ void FringeStoppingFitter::CalculateFitValue(const Image2D& real, size_t xLeft, xRight; xRight = x + windowWidth / 2; - if (x >= (windowWidth / 2)) + if (x >= (windowWidth / 2)) { xLeft = x - (windowWidth / 2); - else { + } else { xLeft = 0; xRight += (windowWidth / 2) - x; } diff --git a/algorithms/fringestoppingfitter.h b/algorithms/fringestoppingfitter.h index 7cd043b2..d1f5207e 100644 --- a/algorithms/fringestoppingfitter.h +++ b/algorithms/fringestoppingfitter.h @@ -23,7 +23,7 @@ class FringeStoppingFitter final : public SurfaceFitMethod { _antenna2Info = &metaData->Antenna2(); _observationTimes = &metaData->ObservationTimes(); } - virtual void Initialize(const TimeFrequencyData& input) final override { + void Initialize(const TimeFrequencyData& input) override { _originalData = &input; _realBackground = Image2D::CreateZeroImagePtr(_originalData->ImageWidth(), _originalData->ImageHeight()); @@ -35,7 +35,7 @@ class FringeStoppingFitter final : public SurfaceFitMethod { return _fringeFit ? _originalData->ImageHeight() : _originalData->ImageWidth(); } - virtual void PerformFit(unsigned taskNumber) final override; + void PerformFit(unsigned taskNumber) override; void PerformStaticFrequencyFitOnOneChannel(unsigned y); void PerformFringeStop(); class TimeFrequencyData Background() const { diff --git a/algorithms/localfitmethod.cpp b/algorithms/localfitmethod.cpp index 9c44f85e..1cacc4a1 100644 --- a/algorithms/localfitmethod.cpp +++ b/algorithms/localfitmethod.cpp @@ -9,6 +9,7 @@ #include <cmath> #include <iostream> +#include <vector> namespace algorithms { @@ -201,9 +202,9 @@ long double LocalFitMethod::CalculateWeightedAverage(unsigned x, unsigned y, } } } - if (totalWeight != 0.0) + if (totalWeight != 0.0) { return sum / totalWeight; - else { + } else { sum = 0.0; totalWeight = 0.0; for (unsigned j = local.startY; j <= local.endY; ++j) { @@ -216,9 +217,9 @@ long double LocalFitMethod::CalculateWeightedAverage(unsigned x, unsigned y, } } } - if (totalWeight != 0.0) + if (totalWeight != 0.0) { return sum / totalWeight; - else { + } else { sum = 0.0; totalWeight = 0.0; for (unsigned j = local.startY; j <= local.endY; ++j) { diff --git a/algorithms/medianwindow.h b/algorithms/medianwindow.h index fa1ef56f..6f69b77f 100644 --- a/algorithms/medianwindow.h +++ b/algorithms/medianwindow.h @@ -2,6 +2,7 @@ #define MEDIANWINDOW_H #include <algorithm> +#include <limits> #include <vector> #include "../structures/samplerow.h" diff --git a/algorithms/morphologicalflagger.cpp b/algorithms/morphologicalflagger.cpp index 74daa3fc..ff25764b 100644 --- a/algorithms/morphologicalflagger.cpp +++ b/algorithms/morphologicalflagger.cpp @@ -1,5 +1,7 @@ #include "morphologicalflagger.h" +#include <utility> + namespace algorithms { bool MorphologicalFlagger::SquareContainsFlag(const Mask2D* mask, size_t xLeft, diff --git a/algorithms/noisestatistics.h b/algorithms/noisestatistics.h index bd75b2c6..4691d753 100644 --- a/algorithms/noisestatistics.h +++ b/algorithms/noisestatistics.h @@ -78,9 +78,9 @@ class NoiseStatistics { stat_t StdDevEstimator() const { return std::sqrt(VarianceEstimator()); } stat_t VarianceEstimator() const { - if (_count <= 1) + if (_count <= 1) { return 0.0; - else { + } else { const stat_t n = _count; const stat_t sumMeanSquared = (_sum * _sum) / n; return (_sum2 + sumMeanSquared - (_sum * 2.0 * _sum / n)) / (n - 1.0); @@ -88,9 +88,9 @@ class NoiseStatistics { } stat_t SecondMoment() const { - if (_count == 0) + if (_count == 0) { return 0.0; - else { + } else { const stat_t n = _count; const stat_t sumMeanSquared = (_sum * _sum) / n; return (_sum2 + sumMeanSquared - (_sum * 2.0 * _sum / n)) / n; @@ -98,9 +98,9 @@ class NoiseStatistics { } stat_t FourthMoment() const { - if (_count == 0) + if (_count == 0) { return 0.0; - else { + } else { const stat_t n = _count, mean = _sum / n, mean2 = mean * mean; return (_sum4 - 4.0 * (_sum3 * mean + _sum * mean2 * mean) + 6.0 * _sum2 * mean2) / @@ -111,9 +111,9 @@ class NoiseStatistics { stat_t VarianceOfVarianceEstimator() const { const long double n = _count; - if (n <= 1) + if (n <= 1) { return 0.0; - else { + } else { const long double moment2 = SecondMoment(); return (FourthMoment() - moment2 * moment2 * (n - 3.0) / (n - 1.0)) / n; } diff --git a/algorithms/resampling.h b/algorithms/resampling.h index b9b7f939..5e316aa9 100644 --- a/algorithms/resampling.h +++ b/algorithms/resampling.h @@ -1,6 +1,10 @@ #ifndef AOFLAGGER_ALGORITHMS_RESAMPLING_H #define AOFLAGGER_ALGORITHMS_RESAMPLING_H +#include <algorithm> +#include <utility> +#include <vector> + #include "../structures/timefrequencydata.h" #include "../structures/timefrequencymetadata.h" diff --git a/algorithms/restorechannelrange.h b/algorithms/restorechannelrange.h index bfa2355e..6521787a 100644 --- a/algorithms/restorechannelrange.h +++ b/algorithms/restorechannelrange.h @@ -1,6 +1,9 @@ #ifndef RESTORE_CHANNEL_RANGE_H #define RESTORE_CHANNEL_RANGE_H +#include <utility> +#include <vector> + #include "../structures/timefrequencydata.h" #include "../structures/timefrequencymetadata.h" diff --git a/algorithms/siroperator.h b/algorithms/siroperator.h index d7134553..f980a8c5 100644 --- a/algorithms/siroperator.h +++ b/algorithms/siroperator.h @@ -1,6 +1,8 @@ #ifndef SIROPERATOR_H #define SIROPERATOR_H +#include <memory> + #include "../structures/mask2d.h" #include "../structures/types.h" #include "../structures/xyswappedmask2d.h" diff --git a/algorithms/sumthreshold.cpp b/algorithms/sumthreshold.cpp index 46de1eef..e0d86c4b 100644 --- a/algorithms/sumthreshold.cpp +++ b/algorithms/sumthreshold.cpp @@ -12,6 +12,8 @@ #include <xmmintrin.h> #include <emmintrin.h> +#include <utility> + #endif namespace algorithms { @@ -848,7 +850,7 @@ __attribute__((target("avx2"))) void SumThreshold::VerticalLargeAVX( // if sum/count > threshold || sum/count < -threshold const __m256 avg8 = _mm256_div_ps(sum8, _mm256_cvtepi32_ps(count8)); // float a[8]; - //_mm256_storeu_ps(a, avg8); + // _mm256_storeu_ps(a, avg8); // std::cout << a[0] << '\n'; const int flagConditions = _mm256_movemask_ps(_mm256_cmp_ps(avg8, threshold8Pos, _CMP_GT_OQ)) | diff --git a/algorithms/sumthresholdmissing.cpp b/algorithms/sumthresholdmissing.cpp index 9b274167..2019ef7e 100644 --- a/algorithms/sumthresholdmissing.cpp +++ b/algorithms/sumthresholdmissing.cpp @@ -3,6 +3,7 @@ #include "../structures/xyswappedmask2d.h" #include <vector> +#include <utility> #include "sumthreshold.h" diff --git a/algorithms/svdmitigater.h b/algorithms/svdmitigater.h index 725d8df8..f03e6f3d 100644 --- a/algorithms/svdmitigater.h +++ b/algorithms/svdmitigater.h @@ -19,7 +19,7 @@ class SVDMitigater final : public SurfaceFitMethod { SVDMitigater(); ~SVDMitigater(); - virtual void Initialize(const TimeFrequencyData& data) final override { + void Initialize(const TimeFrequencyData& data) override { Clear(); _data = data; _iteration = 0; @@ -28,7 +28,7 @@ class SVDMitigater final : public SurfaceFitMethod { _iteration++; RemoveSingularValues(_removeCount); } - virtual void PerformFit(unsigned) final override { PerformFit(); } + void PerformFit(unsigned) override { PerformFit(); } void RemoveSingularValues(unsigned singularValueCount) { if (!IsDecomposed()) Decompose(); diff --git a/algorithms/testsetgenerator.cpp b/algorithms/testsetgenerator.cpp index e1490dab..4651e926 100644 --- a/algorithms/testsetgenerator.cpp +++ b/algorithms/testsetgenerator.cpp @@ -2,6 +2,7 @@ #include <cmath> #include <vector> +#include <utility> #include "../structures/image2d.h" #include "../msio/pngfile.h" diff --git a/algorithms/testsetgenerator.h b/algorithms/testsetgenerator.h index bd8e7388..ee202a35 100644 --- a/algorithms/testsetgenerator.h +++ b/algorithms/testsetgenerator.h @@ -4,6 +4,7 @@ #include <cstddef> #include <fstream> #include <random> +#include <string> #include "../structures/image2d.h" #include "../structures/mask2d.h" diff --git a/algorithms/thresholdconfig.cpp b/algorithms/thresholdconfig.cpp index 491668da..24b7a8f6 100644 --- a/algorithms/thresholdconfig.cpp +++ b/algorithms/thresholdconfig.cpp @@ -1,7 +1,8 @@ #include "thresholdconfig.h" +#include <algorithm> +#include <cmath> #include <iostream> -#include <math.h> #include "../structures/image2d.h" diff --git a/algorithms/thresholdtools.cpp b/algorithms/thresholdtools.cpp index 7ee69289..95ad951f 100644 --- a/algorithms/thresholdtools.cpp +++ b/algorithms/thresholdtools.cpp @@ -1,6 +1,7 @@ #include <algorithm> #include <deque> #include <limits> +#include <memory> #include <boost/numeric/conversion/bounds.hpp> diff --git a/aoluarunner/baselineiterator.h b/aoluarunner/baselineiterator.h index 00c234dc..9dd2582d 100644 --- a/aoluarunner/baselineiterator.h +++ b/aoluarunner/baselineiterator.h @@ -50,9 +50,9 @@ class BaselineIterator { !_finishedBaselines) _dataAvailable.wait(lock); if ((_finishedBaselines && _baselineBuffer.size() == 0) || - _exceptionOccured) + _exceptionOccured) { return nullptr; - else { + } else { std::unique_ptr<imagesets::BaselineData> next = std::move(_baselineBuffer.top()); _baselineBuffer.pop(); diff --git a/aoluarunner/runner.cpp b/aoluarunner/runner.cpp index 184f0d60..33568d43 100644 --- a/aoluarunner/runner.cpp +++ b/aoluarunner/runner.cpp @@ -25,7 +25,10 @@ #include <algorithm> #include <fstream> -using namespace imagesets; +using imagesets::H5ImageSet; +using imagesets::ImageSet; +using imagesets::JoinedSPWSet; +using imagesets::MSImageSet; // The order of initialization: // 1. If Lua strategy given, load Lua strategy @@ -200,10 +203,10 @@ std::unique_ptr<ImageSet> Runner::initializeImageSet(const Options& options, fileOptions.nIntervals = 1; } } - if (fileOptions.nIntervals == 1) + if (fileOptions.nIntervals == 1) { msImageSet->SetInterval(fileOptions.intervalStart, fileOptions.intervalEnd); - else { + } else { const size_t nTimes = fileOptions.resolvedIntEnd - fileOptions.resolvedIntStart; size_t start = fileOptions.resolvedIntStart + fileOptions.intervalIndex * @@ -386,11 +389,9 @@ void Runner::writeHistory(const Options& options, const std::string& filename) { Logger::Debug << "Adding strategy to history table of MS...\n"; try { std::string strategyFilename; - if (options.strategyFilename.empty()) - /// TODO - ; - else + if (!options.strategyFilename.empty()) { strategyFilename = options.strategyFilename; + } // std::ifstream strategyFile(strategyFilename); // std::string content((std::istreambuf_iterator<char>(strategyFile)), // (std::istreambuf_iterator<char>()) ); diff --git a/aoluarunner/runner.h b/aoluarunner/runner.h index 2ee40813..484c8254 100644 --- a/aoluarunner/runner.h +++ b/aoluarunner/runner.h @@ -11,7 +11,8 @@ struct ChunkInfo; class Runner { public: - Runner(const Options& cmdLineOptions) : _cmdLineOptions(cmdLineOptions) {} + explicit Runner(const Options& cmdLineOptions) + : _cmdLineOptions(cmdLineOptions) {} void Run(); diff --git a/aoqplot/aoqplotwindow.h b/aoqplot/aoqplotwindow.h index fca84419..379bd39e 100644 --- a/aoqplot/aoqplotwindow.h +++ b/aoqplot/aoqplotwindow.h @@ -23,7 +23,7 @@ class AOQPlotWindow : public Gtk::Window { public: - AOQPlotWindow(class AOQPlotController* controller); + explicit AOQPlotWindow(class AOQPlotController* controller); void Open(const std::vector<std::string>& files); void Open(const std::string& file) { diff --git a/aoqplot/baselineplotpage.h b/aoqplot/baselineplotpage.h index ec2edb9e..8858807d 100644 --- a/aoqplot/baselineplotpage.h +++ b/aoqplot/baselineplotpage.h @@ -12,7 +12,7 @@ class BaselinePlotPage : public GrayScalePlotPage { public: - BaselinePlotPage(class BaselinePageController* controller); + explicit BaselinePlotPage(class BaselinePageController* controller); virtual ~BaselinePlotPage(); protected: diff --git a/aoqplot/blengthplotpage.h b/aoqplot/blengthplotpage.h index 50a22f33..94931b3d 100644 --- a/aoqplot/blengthplotpage.h +++ b/aoqplot/blengthplotpage.h @@ -9,7 +9,7 @@ class BLengthPlotPage : public TwoDimensionalPlotPage { public: - BLengthPlotPage(BLengthPageController* controller) + explicit BLengthPlotPage(BLengthPageController* controller) : TwoDimensionalPlotPage(controller), _controller(controller), _includeAutoCorrelationsButton("Auto-correlations") {} diff --git a/aoqplot/datawindow.cpp b/aoqplot/datawindow.cpp index 9ffae0d9..481c56fc 100644 --- a/aoqplot/datawindow.cpp +++ b/aoqplot/datawindow.cpp @@ -42,8 +42,9 @@ void DataWindow::loadData(size_t plotSetIndex) { if (_plot->XAxis().Type() == AxisType::kText) { const std::string& label = _plot->XAxis().TickLabels()[i].second; _dataStream << i << '\t' << label << '\t' << y << '\n'; - } else + } else { _dataStream << i << '\t' << x << '\t' << y << '\n'; + } } } SetData(_dataStream.str()); diff --git a/aoqplot/frequencyplotpage.h b/aoqplot/frequencyplotpage.h index 952cf6ff..901ad6f8 100644 --- a/aoqplot/frequencyplotpage.h +++ b/aoqplot/frequencyplotpage.h @@ -10,7 +10,7 @@ class FrequencyPlotPage : public TwoDimensionalPlotPage { public: - FrequencyPlotPage(FrequencyPageController* controller) + explicit FrequencyPlotPage(FrequencyPageController* controller) : TwoDimensionalPlotPage(controller), _controller(controller), _ftButton("FT") {} diff --git a/aoqplot/grayscaleplotpage.h b/aoqplot/grayscaleplotpage.h index 66d0ab45..630708ea 100644 --- a/aoqplot/grayscaleplotpage.h +++ b/aoqplot/grayscaleplotpage.h @@ -15,11 +15,9 @@ #include "plotsheet.h" -using namespace aocommon; - class GrayScalePlotPage : public PlotSheet { public: - GrayScalePlotPage(class HeatMapPageController* controller); + explicit GrayScalePlotPage(class HeatMapPageController* controller); virtual ~GrayScalePlotPage(); virtual void InitializeToolbar(Gtk::Toolbar& toolbar) override final; @@ -44,7 +42,7 @@ class GrayScalePlotPage : public PlotSheet { void initPhaseButtons(Gtk::Toolbar& toolbar); void initPlotOptions(Gtk::Toolbar& toolbar); - PolarizationEnum getSelectedPolarization() const; + aocommon::PolarizationEnum getSelectedPolarization() const; enum TimeFrequencyData::ComplexRepresentation getSelectedPhase() const; void onSelectCount() { diff --git a/aoqplot/histogrampage.h b/aoqplot/histogrampage.h index d3f133bf..fb632bac 100644 --- a/aoqplot/histogrampage.h +++ b/aoqplot/histogrampage.h @@ -18,7 +18,7 @@ class HistogramPage : public PlotSheet { public: - HistogramPage(class HistogramPageController* controller); + explicit HistogramPage(class HistogramPageController* controller); ~HistogramPage(); void updatePlot(); diff --git a/aoqplot/summarypage.h b/aoqplot/summarypage.h index 78f99b9d..5c3bdf31 100644 --- a/aoqplot/summarypage.h +++ b/aoqplot/summarypage.h @@ -124,7 +124,8 @@ class SummaryPageController : public AOQPageController { class SummaryPage : public PlotSheet { public: - SummaryPage(SummaryPageController* controller) : _controller(controller) { + explicit SummaryPage(SummaryPageController* controller) + : _controller(controller) { add(_textView); _textView.show(); diff --git a/aoqplot/timefrequencyplotpage.h b/aoqplot/timefrequencyplotpage.h index d2513bd7..7231f73d 100644 --- a/aoqplot/timefrequencyplotpage.h +++ b/aoqplot/timefrequencyplotpage.h @@ -5,7 +5,7 @@ class TimeFrequencyPlotPage : public GrayScalePlotPage { public: - TimeFrequencyPlotPage(class TFPageController* controller); + explicit TimeFrequencyPlotPage(class TFPageController* controller); private: void onMouseMoved(double x, double y); diff --git a/aoqplot/twodimensionalplotpage.h b/aoqplot/twodimensionalplotpage.h index c4155761..c716a455 100644 --- a/aoqplot/twodimensionalplotpage.h +++ b/aoqplot/twodimensionalplotpage.h @@ -19,7 +19,7 @@ class TwoDimensionalPlotPage : public PlotSheet { public: - TwoDimensionalPlotPage(AOQPlotPageController* _controller); + explicit TwoDimensionalPlotPage(AOQPlotPageController* _controller); virtual ~TwoDimensionalPlotPage(); virtual void InitializeToolbar(Gtk::Toolbar& toolbar) override final; diff --git a/applications/aoflagger.cpp b/applications/aoflagger.cpp index dc1fdbdd..6e754a24 100644 --- a/applications/aoflagger.cpp +++ b/applications/aoflagger.cpp @@ -170,13 +170,13 @@ formats and some more. See the documentation for support of other file types. } else if (flag == "baselines") { ++parameterIndex; const std::string bTypes = argv[parameterIndex]; - if (bTypes == "all") + if (bTypes == "all") { options.baselineSelection = BaselineSelection::All; - else if (bTypes == "cross") + } else if (bTypes == "cross") { options.baselineSelection = BaselineSelection::CrossCorrelations; - else if (bTypes == "auto") + } else if (bTypes == "auto") { options.baselineSelection = BaselineSelection::AutoCorrelations; - else { + } else { Logger::Error << "Incorrect usage; baselines parameter should be set " "to 'all', 'cross' or 'auto'.\n"; return RETURN_CMDLINE_ERROR; diff --git a/applications/aoqplot.cpp b/applications/aoqplot.cpp index 7a06f725..a08c8f90 100644 --- a/applications/aoqplot.cpp +++ b/applications/aoqplot.cpp @@ -29,8 +29,9 @@ bool SelectFile(AOQPlotWindow& window, std::string& filename) { if (fileDialog.run() == Gtk::RESPONSE_OK) { filename = fileDialog.get_filename(); return true; - } else + } else { return false; + } } int main(int argc, char* argv[]) { diff --git a/applications/aoquality.cpp b/applications/aoquality.cpp index 3a33a8d7..fb0e50ab 100644 --- a/applications/aoquality.cpp +++ b/applications/aoquality.cpp @@ -157,20 +157,21 @@ int main(int argc, char* argv[]) { size_t intervalStart = 0, intervalEnd = 0; while (argi < argc && argv[argi][0] == '-') { const std::string p = &argv[argi][1]; - if (p == "h") + if (p == "h") { histograms = true; - else if (p == "d") { + } else if (p == "d") { ++argi; dataColumnName = argv[argi]; - } else if (p == "tf") + } else if (p == "tf") { timeFrequency = true; - else if (p == "interval") { + } else if (p == "interval") { intervalStart = atoi(argv[argi + 1]); intervalEnd = atoi(argv[argi + 2]); argi += 2; - } else + } else { throw std::runtime_error( "Bad parameter given to aoquality collect"); + } ++argi; } const std::string filename = argv[argi]; @@ -272,8 +273,9 @@ int main(int argc, char* argv[]) { if (p == "downsample") { ++argi; downsample = std::atoi(argv[argi]); - } else + } else { throw std::runtime_error("Invalid parameter: " + p); + } ++argi; } quality::PrintPerFrequencyStatistics( @@ -283,19 +285,19 @@ int main(int argc, char* argv[]) { } else if (action == "query_fr") { if (argc == 5) { const std::string range = argv[4]; - if (range == "DVB4") + if (range == "DVB4") { quality::PrintFrequencyRangeStatistic( argv[2], AsVector(argv, 3, argc), 167, 174); - else if (range == "DVB5") + } else if (range == "DVB5") { quality::PrintFrequencyRangeStatistic( argv[2], AsVector(argv, 3, argc), 174, 181); - else if (range == "DVB6") + } else if (range == "DVB6") { quality::PrintFrequencyRangeStatistic( argv[2], AsVector(argv, 3, argc), 181, 188); - else if (range == "DVB7") + } else if (range == "DVB7") { quality::PrintFrequencyRangeStatistic( argv[2], AsVector(argv, 3, argc), 188, 195); - else { + } else { std::cerr << "Syntax for query times: 'aoquality query_fr <KIND> " "<MS> <START MHZ> <END MHZ>'\n"; return -1; diff --git a/applications/badstations.cpp b/applications/badstations.cpp index f8d7dffc..9c0f1ed4 100644 --- a/applications/badstations.cpp +++ b/applications/badstations.cpp @@ -170,9 +170,9 @@ int main(int argc, char* argv[]) { enum Method { StddevMethod, RFIPercentangeMethod } method = StddevMethod; while (argi < argc && argv[argi][0] == '-') { const std::string p(argv[argi] + 1); - if (p == "flag") + if (p == "flag") { doFlag = true; - else if (p == "method") { + } else if (p == "method") { ++argi; const std::string m = argv[argi]; if (m == "stddev") @@ -181,8 +181,9 @@ int main(int argc, char* argv[]) { method = RFIPercentangeMethod; else throw std::runtime_error("Unknown method given"); - } else + } else { throw std::runtime_error("Unknown parameter"); + } ++argi; } if (argi >= argc) { diff --git a/applications/rfigui.cpp b/applications/rfigui.cpp index bb564b61..661a4766 100644 --- a/applications/rfigui.cpp +++ b/applications/rfigui.cpp @@ -132,9 +132,9 @@ static void run(int argc, char* argv[]) { try { if (!filenames.empty()) { - if (interactive) + if (interactive) { window->OpenPaths(filenames); - else { + } else { Pango::init(); MSOptions options; options.ioMode = DirectReadMode; diff --git a/imagesets/imageset.cpp b/imagesets/imageset.cpp index 1eae9bf6..0b43fcb5 100644 --- a/imagesets/imageset.cpp +++ b/imagesets/imageset.cpp @@ -22,31 +22,31 @@ std::unique_ptr<ImageSet> ImageSet::Create( using P = std::unique_ptr<ImageSet>; if (files.size() == 1) { const std::string& file = files.front(); - if (IsFitsFile(file)) + if (IsFitsFile(file)) { return P(new FitsImageSet(file)); - else if (IsBHFitsFile(file)) + } else if (IsBHFitsFile(file)) { return P(new BHFitsImageSet(file)); - else if (IsH5File(file)) + } else if (IsH5File(file)) { return P(new H5ImageSet(file)); - else if (IsRCPRawFile(file)) + } else if (IsRCPRawFile(file)) { throw std::runtime_error("Don't know how to open RCP raw files"); - else if (IsTKPRawFile(file)) + } else if (IsTKPRawFile(file)) { throw std::runtime_error("Don't know how to open TKP raw files"); - else if (IsRawDescFile(file)) + } else if (IsRawDescFile(file)) { throw std::runtime_error("Don't know how to open RCP desc files"); - else if (IsParmFile(file)) + } else if (IsParmFile(file)) { return P(new ParmImageSet(file)); - else if (IsPngFile(file)) + } else if (IsPngFile(file)) { return P(new PngReader(file)); - else if (IsFilterBankFile(file)) + } else if (IsFilterBankFile(file)) { return P(new FilterBankSet(file)); - else if (IsQualityStatSet(file)) + } else if (IsQualityStatSet(file)) { return P(new QualityStatImageSet(file)); - else if (IsRFIBaselineSet(file)) + } else if (IsRFIBaselineSet(file)) { return P(new RFIBaselineSet(file)); - else if (IsSdhdfFile(file)) + } else if (IsSdhdfFile(file)) { return P(new SdhdfImageSet(file)); - else { // it's an MS + } else { // it's an MS if (options.baselineIntegration.enable.value_or(false)) return P(new MSStatSet( file, options.dataColumnName, diff --git a/imagesets/imagesetindex.h b/imagesets/imagesetindex.h index 1380fe93..4b207b86 100644 --- a/imagesets/imagesetindex.h +++ b/imagesets/imagesetindex.h @@ -18,8 +18,9 @@ class ImageSetIndex final { if (_value == 0) { _value = _n - 1; _hasWrapped = true; - } else + } else { --_value; + } } bool Empty() const { return _n == 0; } diff --git a/imagesets/indexableset.cpp b/imagesets/indexableset.cpp index 57437773..e696d596 100644 --- a/imagesets/indexableset.cpp +++ b/imagesets/indexableset.cpp @@ -77,9 +77,9 @@ bool IndexableSet::FindMedianBaseline(imagesets::ImageSet* imageSet, loopIndex.Next(); } const size_t n = distances.size(); - if (n == 0) + if (n == 0) { return false; - else { + } else { std::nth_element( distances.begin(), distances.begin() + n / 2, distances.end(), [](const std::pair<double, imagesets::ImageSetIndex>& l, diff --git a/imagesets/msimageset.cpp b/imagesets/msimageset.cpp index 3ad36220..868d9f7c 100644 --- a/imagesets/msimageset.cpp +++ b/imagesets/msimageset.cpp @@ -184,18 +184,19 @@ void MSImageSet::AddWriteFlagsTask(const ImageSetIndex& index, const size_t s = _sequences[seqIndex].sequenceId; std::vector<Mask2DCPtr> allFlags; - if (flags.size() > _reader->Polarizations().size()) + if (flags.size() > _reader->Polarizations().size()) { throw std::runtime_error( "Trying to write more polarizations to image set than available"); - else if (flags.size() < _reader->Polarizations().size()) { + } else if (flags.size() < _reader->Polarizations().size()) { if (flags.size() == 1) for (size_t i = 0; i < _reader->Polarizations().size(); ++i) allFlags.emplace_back(flags[0]); else throw std::runtime_error( "Incorrect number of polarizations in write action"); - } else + } else { allFlags = flags; + } _reader->AddWriteTask(allFlags, a1, a2, b, s); } diff --git a/imagesets/msimageset.h b/imagesets/msimageset.h index 5a6d60a5..34299912 100644 --- a/imagesets/msimageset.h +++ b/imagesets/msimageset.h @@ -147,7 +147,7 @@ class MSImageSet final : public IndexableSet { _readUVW(false), _ioMode(AutoReadMode) {} void initReader(); - const static size_t not_found = std::numeric_limits<size_t>::max(); + static const size_t not_found = std::numeric_limits<size_t>::max(); size_t findBaselineIndex(size_t antenna1, size_t antenna2, size_t band, size_t sequenceId) const; diff --git a/imagesets/multibandmsimageset.h b/imagesets/multibandmsimageset.h index 06c7f419..443ba57d 100644 --- a/imagesets/multibandmsimageset.h +++ b/imagesets/multibandmsimageset.h @@ -133,7 +133,7 @@ class MultiBandMsImageSet final : public IndexableSet { void ProcessMetaData(); std::unique_ptr<BaselineData> CombineData(const ImageSetIndex& index); - const static size_t kNotFound; + static const size_t kNotFound; std::vector<std::string> ms_names_; // TODO Other readers use a vector and call pop_front, if the vector contains diff --git a/imagesets/rfibaselineset.cpp b/imagesets/rfibaselineset.cpp index e9fff19b..d82526d2 100644 --- a/imagesets/rfibaselineset.cpp +++ b/imagesets/rfibaselineset.cpp @@ -36,8 +36,9 @@ std::string RFIBaselineSet::BaselineDescription() { << " x " << _metaData.Antenna2().station << ' ' << _metaData.Antenna2().name; return sstream.str(); - } else + } else { return Files().front(); + } } void RFIBaselineSet::Write(const std::vector<Mask2DCPtr>& masks) { diff --git a/imagesets/sdhdfimageset.cpp b/imagesets/sdhdfimageset.cpp index fc617949..061111ab 100644 --- a/imagesets/sdhdfimageset.cpp +++ b/imagesets/sdhdfimageset.cpp @@ -91,8 +91,9 @@ bool SdhdfImageSet::tryOpen(H5::DataSet& dataSet, H5::H5File& file, if (file.exists(name)) { dataSet = file.openDataSet(name); return true; - } else + } else { return false; + } #else // file.exists(name) doesn't work in older HDF5 libs, so use trial // and error. Unfortunately this generates output on the cmdline diff --git a/imaging/model.cpp b/imaging/model.cpp index 66bba31c..f4e54be4 100644 --- a/imaging/model.cpp +++ b/imaging/model.cpp @@ -215,9 +215,9 @@ void Model::GetUVPosition(num_t& u, num_t& v, num_t earthLattitudeAngle, sqrtn(dxProjected * dxProjected + dyProjected * dyProjected); long double baselineAngle; - if (baselineLength == 0.0) + if (baselineLength == 0.0) { baselineAngle = 0.0; - else { + } else { baselineLength /= 299792458.0L * wavelength; if (dxProjected > 0.0L) baselineAngle = atann(dyProjected / dxProjected); diff --git a/imaging/uvimager.cpp b/imaging/uvimager.cpp index c0298bae..c60ff86b 100644 --- a/imaging/uvimager.cpp +++ b/imaging/uvimager.cpp @@ -454,9 +454,9 @@ void UVImager::GetUVPosition(num_t& u, num_t& v, sqrtn(dxProjected * dxProjected + dyProjected * dyProjected); num_t baselineAngle; - if (baselineLength == 0.0L) + if (baselineLength == 0.0L) { baselineAngle = 0.0L; - else { + } else { baselineLength /= cache.wavelength; if (dxProjected > 0.0L) baselineAngle = atann(dyProjected / dxProjected); diff --git a/interface/qualitystatistics.cpp b/interface/qualitystatistics.cpp index a95c8458..9abdd201 100644 --- a/interface/qualitystatistics.cpp +++ b/interface/qualitystatistics.cpp @@ -36,9 +36,9 @@ QualityStatistics& QualityStatistics::operator=( if (sourceQS._data != nullptr) _data.reset(new QualityStatisticsData(sourceQS._data->_implementation)); } else { - if (sourceQS._data != nullptr) + if (sourceQS._data != nullptr) { _data->_implementation = sourceQS._data->_implementation; - else { + } else { _data.reset(); } } diff --git a/lua/data.h b/lua/data.h index afc99a8e..82a26c37 100644 --- a/lua/data.h +++ b/lua/data.h @@ -20,7 +20,7 @@ class Data { Context& operator=(Context&&) = default; }; - Data(Context& context) : _context(&context), _persistent(false) { + explicit Data(Context& context) : _context(&context), _persistent(false) { context.list.emplace_back(this); } diff --git a/lua/datawrapper.cpp b/lua/datawrapper.cpp index 252d5785..9da31ae3 100644 --- a/lua/datawrapper.cpp +++ b/lua/datawrapper.cpp @@ -21,17 +21,17 @@ int Data::convert_to_complex(lua_State* L) { try { enum TimeFrequencyData::ComplexRepresentation complexRepresentation; // PhasePart, AmplitudePart, RealPart, ImaginaryPart, ComplexParts - if (reprStr == "phase") + if (reprStr == "phase") { complexRepresentation = TimeFrequencyData::PhasePart; - else if (reprStr == "amplitude") + } else if (reprStr == "amplitude") { complexRepresentation = TimeFrequencyData::AmplitudePart; - else if (reprStr == "real") + } else if (reprStr == "real") { complexRepresentation = TimeFrequencyData::RealPart; - else if (reprStr == "imaginary") + } else if (reprStr == "imaginary") { complexRepresentation = TimeFrequencyData::ImaginaryPart; - else if (reprStr == "complex") + } else if (reprStr == "complex") { complexRepresentation = TimeFrequencyData::ComplexParts; - else { + } else { return luaL_error( L, "Unknown complex representation specified in convert_to_complex(): " diff --git a/lua/functions.cpp b/lua/functions.cpp index 23943611..faa21af0 100644 --- a/lua/functions.cpp +++ b/lua/functions.cpp @@ -446,9 +446,10 @@ Data trim_frequencies(const Data& data, double start_frequency, const std::pair<size_t, size_t> channelRange = data.MetaData()->Band().GetChannelRange(start_frequency, end_frequency); return trim_channels(data, channelRange.first, channelRange.second); - } else + } else { throw std::runtime_error( "trim_frequency(): No spectral band information available!"); + } } void visualize(Data& data, const std::string& label, size_t sortingIndex, diff --git a/lua/luathreadgroup.h b/lua/luathreadgroup.h index 99c806e8..51031172 100644 --- a/lua/luathreadgroup.h +++ b/lua/luathreadgroup.h @@ -7,7 +7,7 @@ class LuaThreadGroup { public: - LuaThreadGroup(size_t nThreads) : _strategies(nThreads) {} + explicit LuaThreadGroup(size_t nThreads) : _strategies(nThreads) {} void LoadFile(const char* filename) { for (LuaStrategy& s : _strategies) { diff --git a/msio/baselinereader.cpp b/msio/baselinereader.cpp index a525f882..4b61c3a1 100644 --- a/msio/baselinereader.cpp +++ b/msio/baselinereader.cpp @@ -18,8 +18,6 @@ #include "../util/logger.h" -using namespace aocommon; - DummyProgressListener BaselineReader::dummy_progress_; BaselineReader::BaselineReader(const std::string& msFile) @@ -96,8 +94,8 @@ void BaselineReader::initializePolarizations() { const casacore::Array<int>::iterator iterend(corType.end()); for (casacore::Array<int>::iterator iter = corType.begin(); iter != iterend; ++iter) { - const PolarizationEnum polarization = - Polarization::AipsIndexToEnum(*iter); + const aocommon::PolarizationEnum polarization = + aocommon::Polarization::AipsIndexToEnum(*iter); _polarizations.push_back(polarization); } } diff --git a/msio/directbaselinereader.h b/msio/directbaselinereader.h index fe75f361..0a1280d6 100644 --- a/msio/directbaselinereader.h +++ b/msio/directbaselinereader.h @@ -52,12 +52,12 @@ class DirectBaselineReader final : public BaselineReader { sequenceId == rhs.sequenceId; } bool operator<(const BaselineCacheIndex& rhs) const { - if (antenna1 < rhs.antenna1) + if (antenna1 < rhs.antenna1) { return true; - else if (antenna1 == rhs.antenna1) { - if (antenna2 < rhs.antenna2) + } else if (antenna1 == rhs.antenna1) { + if (antenna2 < rhs.antenna2) { return true; - else if (antenna2 == rhs.antenna2) { + } else if (antenna2 == rhs.antenna2) { if (spectralWindow < rhs.spectralWindow) return true; else if (spectralWindow == rhs.spectralWindow) diff --git a/msio/memorybaselinereader.cpp b/msio/memorybaselinereader.cpp index e8ce442e..337cb6cf 100644 --- a/msio/memorybaselinereader.cpp +++ b/msio/memorybaselinereader.cpp @@ -14,8 +14,6 @@ #include <vector> -using namespace casacore; - void MemoryBaselineReader::PrepareReadWrite(ProgressListener& progress) { if (!_isRead) { progress.OnStartTask("Reading measurement set into memory"); @@ -44,8 +42,9 @@ void MemoryBaselineReader::PerformReadRequests(ProgressListener& progress) { << request.spectralWindow << ", sequenceId=" << request.sequenceId << ")"; throw std::runtime_error(errorStr.str()); - } else + } else { _results.push_back(*requestedBaselineIter->second); + } } _readRequests.clear(); @@ -59,17 +58,18 @@ void MemoryBaselineReader::readSet(ProgressListener& progress) { const casacore::MeasurementSet table(OpenMS()); - ScalarColumn<int> ant1Column( - table, casacore::MeasurementSet::columnName(MSMainEnums::ANTENNA1)), - ant2Column(table, - casacore::MeasurementSet::columnName(MSMainEnums::ANTENNA2)), + casacore::ScalarColumn<int> ant1Column( + table, + casacore::MeasurementSet::columnName(casacore::MSMainEnums::ANTENNA1)), + ant2Column(table, casacore::MeasurementSet::columnName( + casacore::MSMainEnums::ANTENNA2)), dataDescIdColumn(table, casacore::MeasurementSet::columnName( - MSMainEnums::DATA_DESC_ID)); - ArrayColumn<casacore::Complex> dataColumn(table, DataColumnName()); - ArrayColumn<bool> flagColumn( - table, casacore::MeasurementSet::columnName(MSMainEnums::FLAG)); - ArrayColumn<double> uvwColumn( - table, casacore::MeasurementSet::columnName(MSMainEnums::UVW)); + casacore::MSMainEnums::DATA_DESC_ID)); + casacore::ArrayColumn<casacore::Complex> dataColumn(table, DataColumnName()); + casacore::ArrayColumn<bool> flagColumn( + table, casacore::MeasurementSet::columnName(casacore::MSMainEnums::FLAG)); + casacore::ArrayColumn<double> uvwColumn( + table, casacore::MeasurementSet::columnName(casacore::MSMainEnums::UVW)); size_t antennaCount = MetaData().AntennaCount(), polarizationCount = Polarizations().size(), @@ -141,8 +141,8 @@ void MemoryBaselineReader::readSet(ProgressListener& progress) { dataArray = dataColumn.get(rowIndex); flagArray = flagColumn.get(rowIndex); - Array<double> uvwArray = uvwColumn.get(rowIndex); - Array<double>::const_contiter uvwPtr = uvwArray.cbegin(); + casacore::Array<double> uvwArray = uvwColumn.get(rowIndex); + casacore::Array<double>::const_contiter uvwPtr = uvwArray.cbegin(); UVW uvw; uvw.u = *uvwPtr; ++uvwPtr; @@ -152,8 +152,9 @@ void MemoryBaselineReader::readSet(ProgressListener& progress) { result->_uvw[timeIndexInSequence] = uvw; for (size_t p = 0; p != polarizationCount; ++p) { - Array<Complex>::const_contiter dataPtr = dataArray.cbegin(); - Array<bool>::const_contiter flagPtr = flagArray.cbegin(); + casacore::Array<casacore::Complex>::const_contiter dataPtr = + dataArray.cbegin(); + casacore::Array<bool>::const_contiter flagPtr = flagArray.cbegin(); Image2D& real = *result->_realImages[p]; Image2D& imag = *result->_imaginaryImages[p]; @@ -226,14 +227,15 @@ void MemoryBaselineReader::PerformFlagWriteRequests() { void MemoryBaselineReader::WriteToMs() { casacore::MeasurementSet ms(OpenMS(true)); - ScalarColumn<int> ant1Column( - ms, casacore::MeasurementSet::columnName(MSMainEnums::ANTENNA1)), - ant2Column(ms, - casacore::MeasurementSet::columnName(MSMainEnums::ANTENNA2)), - dataDescIdColumn( - ms, casacore::MeasurementSet::columnName(MSMainEnums::DATA_DESC_ID)); - ArrayColumn<bool> flagColumn( - ms, casacore::MeasurementSet::columnName(MSMainEnums::FLAG)); + casacore::ScalarColumn<int> ant1Column( + ms, + casacore::MeasurementSet::columnName(casacore::MSMainEnums::ANTENNA1)), + ant2Column(ms, casacore::MeasurementSet::columnName( + casacore::MSMainEnums::ANTENNA2)), + dataDescIdColumn(ms, casacore::MeasurementSet::columnName( + casacore::MSMainEnums::DATA_DESC_ID)); + casacore::ArrayColumn<bool> flagColumn( + ms, casacore::MeasurementSet::columnName(casacore::MSMainEnums::FLAG)); std::vector<size_t> dataIdToSpw; MetaData().GetDataDescToBandVector(dataIdToSpw); @@ -251,7 +253,7 @@ void MemoryBaselineReader::WriteToMs() { if (ant1 > ant2) std::swap(ant1, ant2); const size_t frequencyCount = MetaData().FrequencyCount(spw); - IPosition flagShape = IPosition(2); + casacore::IPosition flagShape = casacore::IPosition(2); flagShape[0] = polarizationCount; flagShape[1] = frequencyCount; casacore::Array<bool> flagArray(flagShape); @@ -261,7 +263,7 @@ void MemoryBaselineReader::WriteToMs() { _baselines.find(baselineID); std::unique_ptr<Result>& result = resultIter->second; - Array<bool>::contiter flagPtr = flagArray.cbegin(); + casacore::Array<bool>::contiter flagPtr = flagArray.cbegin(); std::vector<Mask2D*> masks(polarizationCount); for (size_t p = 0; p != polarizationCount; ++p) diff --git a/msio/memorybaselinereader.h b/msio/memorybaselinereader.h index 970e825d..0a8173a3 100644 --- a/msio/memorybaselinereader.h +++ b/msio/memorybaselinereader.h @@ -68,12 +68,12 @@ class MemoryBaselineReader final : public BaselineReader { unsigned antenna1, antenna2, spw, sequenceId; bool operator<(const BaselineID& other) const { - if (antenna1 < other.antenna1) + if (antenna1 < other.antenna1) { return true; - else if (antenna1 == other.antenna1) { - if (antenna2 < other.antenna2) + } else if (antenna1 == other.antenna1) { + if (antenna2 < other.antenna2) { return true; - else if (antenna2 == other.antenna2) { + } else if (antenna2 == other.antenna2) { if (spw < other.spw) return true; else if (spw == other.spw) diff --git a/msio/msstatreader.cpp b/msio/msstatreader.cpp index a62de2d1..aaad021b 100644 --- a/msio/msstatreader.cpp +++ b/msio/msstatreader.cpp @@ -12,7 +12,8 @@ #include <casacore/tables/Tables/ArrayColumn.h> #include <casacore/tables/Tables/ScalarColumn.h> -using namespace aocommon; +using aocommon::Polarization; +using aocommon::PolarizationEnum; MSStatReader::MSStatReader(const std::string& filename, const std::string& dataColumn) diff --git a/msio/parmtable.h b/msio/parmtable.h index d8504a42..92c3270b 100644 --- a/msio/parmtable.h +++ b/msio/parmtable.h @@ -39,7 +39,7 @@ class ParmTable { } }; - ParmTable(const std::string& path) : _path(path) { readNames(); } + explicit ParmTable(const std::string& path) : _path(path) { readNames(); } std::set<std::string> GetAntennas() const { std::set<std::string> antennas; diff --git a/msio/reorderingbaselinereader.cpp b/msio/reorderingbaselinereader.cpp index b81f0e22..9cbaa24e 100644 --- a/msio/reorderingbaselinereader.cpp +++ b/msio/reorderingbaselinereader.cpp @@ -82,11 +82,11 @@ void ReorderingBaselineReader::PerformReadRequests( width, MetaData().FrequencyCount(request.spectralWindow))); } } - if (read_uvw_) + if (read_uvw_) { _results[i]._uvw = direct_reader_.ReadUVW(request.antenna1, request.antenna2, request.spectralWindow, request.sequenceId); - else { + } else { _results[i]._uvw.clear(); for (unsigned j = 0; j < width; ++j) _results[i]._uvw.emplace_back(0.0, 0.0, 0.0); diff --git a/msio/singlebaselinefile.cpp b/msio/singlebaselinefile.cpp index 7788ef82..ab783f5b 100644 --- a/msio/singlebaselinefile.cpp +++ b/msio/singlebaselinefile.cpp @@ -6,8 +6,6 @@ #define FILE_FORMAT_VERSION 1 -using namespace aocommon; - void SingleBaselineFile::Read(std::istream& stream, ProgressListener& progress) { if (!stream) throw std::runtime_error("Could not open file"); @@ -73,7 +71,8 @@ TimeFrequencyData SingleBaselineFile::UnserializeTFData( for (size_t i = 0; i != polCount; ++i) { TimeFrequencyData polData; const size_t polCode = Serializable::UnserializeUInt32(stream); - const PolarizationEnum pol = Polarization::AipsIndexToEnum(polCode); + const aocommon::PolarizationEnum pol = + aocommon::Polarization::AipsIndexToEnum(polCode); const uint32_t imageFlagBitset = Serializable::UnserializeUInt32(stream); const size_t imageCount = imageFlagBitset & 0x03; const size_t maskCount = (imageFlagBitset & 0x04) ? 1 : 0; @@ -183,8 +182,9 @@ void SingleBaselineFile::Serialize(std::ostream& stream, } Serializable::SerializeToUInt32(stream, complCode); for (size_t i = 0; i != data.PolarizationCount(); ++i) { - const PolarizationEnum p = data.GetPolarization(i); - Serializable::SerializeToUInt32(stream, Polarization::EnumToAipsIndex(p)); + const aocommon::PolarizationEnum p = data.GetPolarization(i); + Serializable::SerializeToUInt32(stream, + aocommon::Polarization::EnumToAipsIndex(p)); unsigned int imageFlagBitset = 0; const TimeFrequencyData polData = data.MakeFromPolarizationIndex(i); if (polData.ImageCount() == 2) imageFlagBitset = imageFlagBitset | 0x02; diff --git a/plot/colormap.h b/plot/colormap.h index 1d5af07d..e98e9af2 100644 --- a/plot/colormap.h +++ b/plot/colormap.h @@ -634,7 +634,7 @@ class ViridisMap : public ColorMap { return (size_t)d; } - const static double DATA_R[256], DATA_G[256], DATA_B[256]; + static const double DATA_R[256], DATA_G[256], DATA_B[256]; }; template <int Saturation> diff --git a/plot/heatmap.cpp b/plot/heatmap.cpp index 8e7d1c0b..77a4ab6a 100644 --- a/plot/heatmap.cpp +++ b/plot/heatmap.cpp @@ -401,8 +401,9 @@ void HeatMap::drawAll(const Cairo::RefPtr<Cairo::Context>& cairo, size_t width, else val = (std::log10(val) - minLog10) * 2.0 / (maxLog10 - minLog10) - 1.0; - } else + } else { val = (val - _derivedMin) * 2.0 / (_derivedMax - _derivedMin) - 1.0; + } if (val < -1.0) val = -1.0; else if (val > 1.0) diff --git a/plot/horizontalplotscale.cpp b/plot/horizontalplotscale.cpp index db6e1023..57f72092 100644 --- a/plot/horizontalplotscale.cpp +++ b/plot/horizontalplotscale.cpp @@ -211,10 +211,10 @@ void HorizontalPlotScale::initializeLocalMetrics( } void HorizontalPlotScale::InitializeTicks() { - if (_isLogarithmic) + if (_isLogarithmic) { _tickSet = std::make_unique<LogarithmicTickSet>(_tickRange[0], _tickRange[1], 25); - else { + } else { switch (_axisType) { case AxisType::kNumeric: _tickSet = diff --git a/plot/plotpropertieswindow.cpp b/plot/plotpropertieswindow.cpp index 3b0122e2..6f285cb7 100644 --- a/plot/plotpropertieswindow.cpp +++ b/plot/plotpropertieswindow.cpp @@ -224,19 +224,19 @@ void PlotPropertiesWindow::updateVMinMaxEntries() { void PlotPropertiesWindow::onApplyClicked() { _plot.SetTitle(_titleEntry.get_text()); - if (_minMaxVRangeButton.get_active()) + if (_minMaxVRangeButton.get_active()) { _plot.YAxis().SetRangeDetermination(RangeDetermination::MinMaxRange); - else if (_winsorizedVRangeButton.get_active()) + } else if (_winsorizedVRangeButton.get_active()) { _plot.YAxis().SetRangeDetermination(RangeDetermination::WinsorizedRange); - else if (_specifiedVRangeButton.get_active()) { + } else if (_specifiedVRangeButton.get_active()) { _plot.YAxis().SetRangeDetermination(RangeDetermination::SpecifiedRange); _plot.YAxis().SetMin(atof(_vRangeMinEntry.get_text().c_str())); _plot.YAxis().SetMax(atof(_vRangeMaxEntry.get_text().c_str())); } - if (_automaticHRangeButton.get_active()) + if (_automaticHRangeButton.get_active()) { _plot.XAxis().SetRangeDetermination(RangeDetermination::MinMaxRange); - else { + } else { _plot.XAxis().SetRangeDetermination(RangeDetermination::SpecifiedRange); _plot.XAxis().SetMin(atof(_hRangeMinEntry.get_text().c_str())); _plot.XAxis().SetMax(atof(_hRangeMaxEntry.get_text().c_str())); diff --git a/plot/ticksets/logarithmictickset.h b/plot/ticksets/logarithmictickset.h index 43e65cd4..e491c4eb 100644 --- a/plot/ticksets/logarithmictickset.h +++ b/plot/ticksets/logarithmictickset.h @@ -66,8 +66,9 @@ class LogarithmicTickSet : public TickSet { out << kToSuperTable[c - '0']; } else if (c == '-') { out << "⁻"; - } else + } else { out << c; + } } return out.str(); } diff --git a/plot/ticksets/numerictickset.h b/plot/ticksets/numerictickset.h index 298756eb..1e6fa7e2 100644 --- a/plot/ticksets/numerictickset.h +++ b/plot/ticksets/numerictickset.h @@ -51,9 +51,9 @@ class NumericTickSet final : public TickSet { void set(size_t sizeRequest) { if (std::isfinite(_min) && std::isfinite(_max)) { - if (_max == _min) + if (_max == _min) { _ticks.push_back(_min); - else { + } else { if (sizeRequest == 0) return; double tickWidth = roundUpToNiceNumber(std::fabs(_max - _min) / (double)sizeRequest); @@ -86,9 +86,9 @@ class NumericTickSet final : public TickSet { if (!std::isfinite(number)) return number; double roundedNumber = 1.0; if (number <= 0.0) { - if (number == 0.0) + if (number == 0.0) { return 0.0; - else { + } else { roundedNumber = -1.0; number *= -1.0; } diff --git a/plot/ticksets/timetickset.h b/plot/ticksets/timetickset.h index bb9455cc..f051e647 100644 --- a/plot/ticksets/timetickset.h +++ b/plot/ticksets/timetickset.h @@ -43,9 +43,9 @@ class TimeTickSet final : public TickSet { private: void set(size_t sizeRequest) { - if (_max == _min) + if (_max == _min) { _ticks.push_back(_min); - else { + } else { if (sizeRequest == 0) return; double tickWidth = calculateTickWidth((_max - _min) / (double)sizeRequest); @@ -64,29 +64,25 @@ class TimeTickSet final : public TickSet { // number is in units of seconds - // In days? - if (lowerLimit >= 60.0 * 60.0 * 24.0) { + if (lowerLimit >= 60.0 * 60.0 * 24.0) { // In days? double width = 60.0 * 60.0 * 24.0; while (width < lowerLimit) width *= 2.0; return width; - } - // in hours? - else if (lowerLimit > 60.0 * 30.0) { - if (lowerLimit <= 60.0 * 60.0) + } else if (lowerLimit > 60.0 * 30.0) { // in hours? + if (lowerLimit <= 60.0 * 60.0) { return 60.0 * 60.0; // hours - else if (lowerLimit <= 60.0 * 60.0 * 2.0) + } else if (lowerLimit <= 60.0 * 60.0 * 2.0) { return 60.0 * 60.0 * 2.0; // two hours - else if (lowerLimit <= 60.0 * 60.0 * 3.0) + } else if (lowerLimit <= 60.0 * 60.0 * 3.0) { return 60.0 * 60.0 * 3.0; // three hours - else if (lowerLimit <= 60.0 * 60.0 * 4.0) + } else if (lowerLimit <= 60.0 * 60.0 * 4.0) { return 60.0 * 60.0 * 4.0; // four hours - else if (lowerLimit <= 60.0 * 60.0 * 6.0) + } else if (lowerLimit <= 60.0 * 60.0 * 6.0) { return 60.0 * 60.0 * 6.0; // six hours - else + } else { return 60.0 * 60.0 * 12.0; // twelve hours - } - // in minutes? - else if (lowerLimit > 30.0) { + } + } else if (lowerLimit > 30.0) { // in minutes? if (lowerLimit <= 60.0) return 60.0; // in minutes else if (lowerLimit <= 60.0 * 2.0) @@ -98,10 +94,8 @@ class TimeTickSet final : public TickSet { else if (lowerLimit <= 60.0 * 15.0) return 60.0 * 15.0; // quarter hours else - return 60.0 * 30.0; // half hours - } - // in seconds? - else if (lowerLimit > 0.5) { + return 60.0 * 30.0; // half hours + } else if (lowerLimit > 0.5) { // in seconds? if (lowerLimit <= 1.0) return 1.0; // in seconds else if (lowerLimit <= 2.0) @@ -114,10 +108,9 @@ class TimeTickSet final : public TickSet { return 15.0; // quarter minute else return 30.0; // half a minute - } else if (lowerLimit == 0.0) + } else if (lowerLimit == 0.0) { return 0.0; - // in 10th of seconds or lower? - else { + } else { // in 10th of seconds or lower? double factor = 1.0; while (lowerLimit <= 0.1 && std::isfinite(lowerLimit)) { factor *= 0.1; diff --git a/plot/vectorimage.cpp b/plot/vectorimage.cpp index 4cc13f36..c5e62b20 100644 --- a/plot/vectorimage.cpp +++ b/plot/vectorimage.cpp @@ -2,9 +2,9 @@ std::unique_ptr<VectorImage> ShrinkHorizontally(const ImageInterface& source, size_t shrinkFactor) { - if (source.Width() == 0) + if (source.Width() == 0) { return std::unique_ptr<VectorImage>(new VectorImage()); - else { + } else { const size_t newWidth = (source.Width() + shrinkFactor - 1) / shrinkFactor; const size_t height = source.Height(); diff --git a/plot/xyplot.cpp b/plot/xyplot.cpp index a7014b56..d454b528 100644 --- a/plot/xyplot.cpp +++ b/plot/xyplot.cpp @@ -337,11 +337,11 @@ void XYPlot::DrawPointSet(const Cairo::RefPtr<Cairo::Context>& cr, std::pair<double, double> XYPlot::RangeX(bool second_axis) const { const XYPlotAxis& axis = second_axis ? x2_axis_ : x_axis_; - if (axis.GetRangeDetermination() == RangeDetermination::SpecifiedRange) + if (axis.GetRangeDetermination() == RangeDetermination::SpecifiedRange) { return std::make_pair(axis.SpecifiedMin(), axis.SpecifiedMax()); - else if (_pointSets.empty()) + } else if (_pointSets.empty()) { return std::make_pair(0.0, 1.0); - else { + } else { const double maxX = _system.XRangeMax(second_axis); const double minX = _system.XRangeMin(second_axis); return std::make_pair(minX, maxX); @@ -349,11 +349,11 @@ std::pair<double, double> XYPlot::RangeX(bool second_axis) const { } std::pair<double, double> XYPlot::RangePositiveX(bool second_axis) const { - if (x_axis_.GetRangeDetermination() == RangeDetermination::SpecifiedRange) + if (x_axis_.GetRangeDetermination() == RangeDetermination::SpecifiedRange) { return std::make_pair(x_axis_.SpecifiedMin(), x_axis_.SpecifiedMax()); - else if (_pointSets.empty()) + } else if (_pointSets.empty()) { return std::make_pair(0.1, 1.0); - else { + } else { const double maxX = _system.XRangePositiveMax(second_axis); const double minX = _system.XRangePositiveMin(second_axis); return std::make_pair(minX, maxX); @@ -362,11 +362,11 @@ std::pair<double, double> XYPlot::RangePositiveX(bool second_axis) const { std::pair<double, double> XYPlot::RangeY(bool second_axis) const { const XYPlotAxis& axis = second_axis ? y2_axis_ : y_axis_; - if (axis.GetRangeDetermination() == RangeDetermination::SpecifiedRange) + if (axis.GetRangeDetermination() == RangeDetermination::SpecifiedRange) { return std::make_pair(axis.SpecifiedMin(), axis.SpecifiedMax()); - else if (_pointSets.empty()) + } else if (_pointSets.empty()) { return std::make_pair(0.0, 1.0); - else { + } else { double minY = _system.YRangeMin(second_axis), maxY = _system.YRangeMax(second_axis), extMin = minY * 1.07 - maxY * 0.07, @@ -380,11 +380,11 @@ std::pair<double, double> XYPlot::RangeY(bool second_axis) const { } std::pair<double, double> XYPlot::RangePositiveY(bool second_axis) const { - if (y_axis_.GetRangeDetermination() == RangeDetermination::SpecifiedRange) + if (y_axis_.GetRangeDetermination() == RangeDetermination::SpecifiedRange) { return std::make_pair(y_axis_.SpecifiedMin(), y_axis_.SpecifiedMax()); - else if (_pointSets.empty()) + } else if (_pointSets.empty()) { return std::make_pair(0.1, 1.0); - else { + } else { const double maxY = std::log(_system.YRangePositiveMax(second_axis)); const double minY = std::log(_system.YRangePositiveMin(second_axis)); const double extMin = std::exp(minY * 1.07 - maxY * 0.07); diff --git a/plot/xypointset.h b/plot/xypointset.h index 02960140..84cbc623 100644 --- a/plot/xypointset.h +++ b/plot/xypointset.h @@ -8,8 +8,7 @@ class XYPointSet { public: - XYPointSet(size_t colorIndex) : color_index_(colorIndex) {} - ~XYPointSet() {} + explicit XYPointSet(size_t colorIndex) : color_index_(colorIndex) {} enum DrawingStyle { DrawLines, DrawPoints, DrawColumns }; @@ -130,9 +129,9 @@ class XYPointSet { } double XRangePositiveMin() const { - if (points_.empty()) + if (points_.empty()) { return 1.0; - else { + } else { std::vector<Point2D>::const_iterator iter = std::upper_bound(points_.begin(), points_.end(), Point2D(0.0, 0.0)); if (iter == points_.end() || iter->x < 0.0 || !std::isfinite(iter->x)) diff --git a/python/pyinterface.cpp b/python/pyinterface.cpp index bac240da..0d516df1 100644 --- a/python/pyinterface.cpp +++ b/python/pyinterface.cpp @@ -3,8 +3,6 @@ #include "pyfunctions.h" -#include <aocommon/polarization.h> - #include <pybind11/pybind11.h> #include <pybind11/operators.h> @@ -12,8 +10,6 @@ namespace py = pybind11; -using namespace aocommon; - PYBIND11_MODULE(aoflagger, m) { m.doc() = "AOFlagger module for detection of radio-frequency interference"; diff --git a/quality/histogramtablesformatter.h b/quality/histogramtablesformatter.h index 9e5b7634..f07e1cea 100644 --- a/quality/histogramtablesformatter.h +++ b/quality/histogramtablesformatter.h @@ -109,13 +109,13 @@ class HistogramTablesFormatter { void operator=(const HistogramTablesFormatter&) = delete; // don't allow assignment - const static std::string ColumnNameType; - const static std::string ColumnNameName; - const static std::string ColumnNamePolarization; + static const std::string ColumnNameType; + static const std::string ColumnNameName; + static const std::string ColumnNamePolarization; - const static std::string ColumnNameBinStart; - const static std::string ColumnNameBinEnd; - const static std::string ColumnNameCount; + static const std::string ColumnNameBinStart; + static const std::string ColumnNameBinEnd; + static const std::string ColumnNameCount; std::unique_ptr<casacore::Table> _measurementSet; const std::string _measurementSetName; diff --git a/quality/qualitytablesformatter.cpp b/quality/qualitytablesformatter.cpp index ee18db94..768f7bdf 100644 --- a/quality/qualitytablesformatter.cpp +++ b/quality/qualitytablesformatter.cpp @@ -125,9 +125,9 @@ void QualityTablesFormatter::InitializeEmptyStatistic( if (!TableExists(KindNameTable)) createKindNameTable(); const QualityTable table = DimensionToTable(dimension); - if (!TableExists(table)) + if (!TableExists(table)) { InitializeEmptyTable(table, polarizationCount); - else { + } else { removeStatisticFromStatTable(table, kind); } } diff --git a/quality/qualitytablesformatter.h b/quality/qualitytablesformatter.h index 093108c5..36e08a26 100644 --- a/quality/qualitytablesformatter.h +++ b/quality/qualitytablesformatter.h @@ -202,17 +202,17 @@ class QualityTablesFormatter { void operator=(const QualityTablesFormatter&) = delete; // don't allow assignment - const static std::string _kindToNameTable[]; - const static std::string _tableToNameTable[]; - const static enum QualityTable _dimensionToTableTable[]; - - const static std::string ColumnNameAntenna1; - const static std::string ColumnNameAntenna2; - const static std::string ColumnNameFrequency; - const static std::string ColumnNameKind; - const static std::string ColumnNameName; - const static std::string ColumnNameTime; - const static std::string ColumnNameValue; + static const std::string _kindToNameTable[]; + static const std::string _tableToNameTable[]; + static const QualityTable _dimensionToTableTable[]; + + static const std::string ColumnNameAntenna1; + static const std::string ColumnNameAntenna2; + static const std::string ColumnNameFrequency; + static const std::string ColumnNameKind; + static const std::string ColumnNameName; + static const std::string ColumnNameTime; + static const std::string ColumnNameValue; std::unique_ptr<casacore::Table> _measurementSet; const std::string _measurementSetName; diff --git a/rfigui/controllers/imagecomparisoncontroller.cpp b/rfigui/controllers/imagecomparisoncontroller.cpp index b763e564..47f1ba0e 100644 --- a/rfigui/controllers/imagecomparisoncontroller.cpp +++ b/rfigui/controllers/imagecomparisoncontroller.cpp @@ -167,11 +167,11 @@ void ImageComparisonController::TryVisualizePolarizations(bool& pp, bool& pq, Mask2DCPtr ImageComparisonController::getSelectedPolarizationMask( const TimeFrequencyData& data) const { - if (data.MaskCount() == 0) + if (data.MaskCount() == 0) { return Mask2DCPtr(); - else if (data.MaskCount() == 1) + } else if (data.MaskCount() == 1) { return data.GetSingleMask(); - else { + } else { if (data.MaskCount() == 4) { if (_showPP && _showQQ) { Mask2DPtr mask = Mask2D::MakePtr(*data.GetMask(0)); @@ -181,24 +181,25 @@ Mask2DCPtr ImageComparisonController::getSelectedPolarizationMask( Mask2DPtr mask = Mask2D::MakePtr(*data.GetMask(1)); mask->Join(*data.GetMask(2)); return mask; - } else if (_showPP) + } else if (_showPP) { return data.GetMask(0); - else if (_showPQ) + } else if (_showPQ) { return data.GetMask(1); - else if (_showQP) + } else if (_showQP) { return data.GetMask(2); - else // if(_showQQ) + } else { // if(_showQQ) return data.GetMask(3); - } else // data->MaskCount() == 2 - { + } + } else { // data->MaskCount() == 2 if (_showPP && _showQQ) { Mask2DPtr mask = Mask2D::MakePtr(*data.GetMask(0)); mask->Join(*data.GetMask(1)); return mask; - } else if (_showPP) + } else if (_showPP) { return data.GetMask(0); - else // if(_showQQ) + } else { // if(_showQQ) return data.GetMask(1); + } } } } diff --git a/rfigui/controllers/imagecomparisoncontroller.h b/rfigui/controllers/imagecomparisoncontroller.h index c48f0af3..5d5c1adb 100644 --- a/rfigui/controllers/imagecomparisoncontroller.h +++ b/rfigui/controllers/imagecomparisoncontroller.h @@ -53,15 +53,16 @@ class ImageComparisonController { */ TimeFrequencyData AltMaskData() const { if (_visualizedImage == 0) { - if (_dataList.size() > 1) + if (_dataList.size() > 1) { return _dataList.back().data; - else { + } else { TimeFrequencyData empty = _dataList.back().data; empty.SetNoMask(); return empty; } - } else + } else { return _dataList[_visualizedImage].data; + } } size_t AddVisualization(const std::string& label, @@ -150,12 +151,13 @@ class ImageComparisonController { if (orActive && altActive) { data.SetMask(_dataList[0].data); data.JoinMask(_dataList[altMaskIndex].data); - } else if (orActive) + } else if (orActive) { data.SetMask(_dataList[0].data); - else if (altActive) + } else if (altActive) { data.SetMask(_dataList[altMaskIndex].data); - else + } else { data.SetMasksToValue<false>(); + } } MaskedHeatMap _plot; bool _showPP, _showPQ, _showQP, _showQQ; diff --git a/rfigui/controllers/rfiguicontroller.cpp b/rfigui/controllers/rfiguicontroller.cpp index 10e7310d..12c442d7 100644 --- a/rfigui/controllers/rfiguicontroller.cpp +++ b/rfigui/controllers/rfiguicontroller.cpp @@ -163,9 +163,9 @@ void RFIGuiController::PlotPowerSpectrum() { const TimeFrequencyData data = ActiveData(); std::array<Image2DCPtr, 2> images; - if (data.ComplexRepresentation() == TimeFrequencyData::ComplexParts) + if (data.ComplexRepresentation() == TimeFrequencyData::ComplexParts) { images = data.GetSingleComplexImage(); - else { + } else { images[0] = data.GetSingleImage(); images[1] = images[0]; } diff --git a/rfigui/maskedheatmap.cpp b/rfigui/maskedheatmap.cpp index e5716717..b7a6b09b 100644 --- a/rfigui/maskedheatmap.cpp +++ b/rfigui/maskedheatmap.cpp @@ -46,8 +46,9 @@ Mask2DCPtr MaskedHeatMap::GetActiveMask() const { Mask2DPtr mask = Mask2D::MakePtr(*_originalMask); mask->Join(*_alternativeMask); return mask; - } else + } else { return _originalMask; + } } else { if (altActive) return _alternativeMask; diff --git a/rfigui/plotframe.cpp b/rfigui/plotframe.cpp index 56f14c05..20fd957e 100644 --- a/rfigui/plotframe.cpp +++ b/rfigui/plotframe.cpp @@ -4,7 +4,7 @@ #include "plotframe.h" -using namespace aocommon; +using aocommon::Polarization; PlotFrame::PlotFrame() : _plotData(nullptr), @@ -53,7 +53,7 @@ void PlotFrame::plot() { void PlotFrame::plotTimeGraph(const TimeFrequencyData& data, const std::string& label, - PolarizationEnum polarisation) { + aocommon::PolarizationEnum polarisation) { plotTimeGraph(data.Make(polarisation), label); } diff --git a/rfigui/plotwindow.cpp b/rfigui/plotwindow.cpp index 0ac61e1d..a51827db 100644 --- a/rfigui/plotwindow.cpp +++ b/rfigui/plotwindow.cpp @@ -106,7 +106,6 @@ void PlotWindow::onEditPlottingPropertiesPressed() { _plotPropertiesWindow = new PlotPropertiesWindow(plot, "Plot properties"); _plotPropertiesWindow->OnChangesApplied = std::bind(&PlotWindow::onPlotPropertiesChanged, this); - ; _plotPropertiesWindow->show(); _plotPropertiesWindow->raise(); } diff --git a/rfigui/progresswindow.cpp b/rfigui/progresswindow.cpp index 4b024d69..9ec68e56 100644 --- a/rfigui/progresswindow.cpp +++ b/rfigui/progresswindow.cpp @@ -50,7 +50,7 @@ ProgressWindow::ProgressWindow() sigc::mem_fun(*this, &ProgressWindow::updateProgress)); } -ProgressWindow::~ProgressWindow() {} +ProgressWindow::~ProgressWindow() = default; void ProgressWindow::updateProgress() { if (!_blockProgressSignal) { diff --git a/rfigui/progresswindow.h b/rfigui/progresswindow.h index 250f539b..79feca72 100644 --- a/rfigui/progresswindow.h +++ b/rfigui/progresswindow.h @@ -17,7 +17,7 @@ class ProgressWindow : public Gtk::Window, public ProgressListener { public: - explicit ProgressWindow(); + ProgressWindow(); ~ProgressWindow(); virtual void OnStartTask(const std::string& description) final override; diff --git a/rfigui/rfiguiwindow.cpp b/rfigui/rfiguiwindow.cpp index 15ed0262..2fbcebd8 100644 --- a/rfigui/rfiguiwindow.cpp +++ b/rfigui/rfiguiwindow.cpp @@ -280,11 +280,11 @@ bool RFIGuiWindow::askToSaveChanges() { dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_YES); const int result = dialog.run(); - if (result == Gtk::RESPONSE_CANCEL) + if (result == Gtk::RESPONSE_CANCEL) { return false; - else if (result == Gtk::RESPONSE_CLOSE) + } else if (result == Gtk::RESPONSE_CLOSE) { return true; - else { + } else { onStrategySave(); // In case the strategy had no name yet, the onStrategySave() call will // show a file dialog where the user might press cancel. In that case, @@ -504,8 +504,9 @@ void RFIGuiWindow::onViewTimePlot() { if (viewTime) { _timeFrequencyWidget.EnableTimePlot(); _controller->DrawTimeMean(_timeFrequencyWidget.TimePlot()); - } else + } else { _timeFrequencyWidget.DisableTimePlot(); + } } void RFIGuiWindow::onExecuteLuaStrategy() { @@ -1305,10 +1306,10 @@ void RFIGuiWindow::onStrategyOpenDefault(const std::string& name) { const TelescopeFile::TelescopeId id = TelescopeFile::TelescopeIdFromName(name); const std::string filename = TelescopeFile::FindStrategy(id); - if (filename.empty()) + if (filename.empty()) { showError("Could not find default strategy file for telescope '" + name + "' -- aoflagger is probably not installed properly"); - else { + } else { _controller->OpenStrategy(filename); _strategyEditor.SetText(_controller->GetWorkStrategyText()); _strategyEditor.ResetChangedStatus(); @@ -1322,8 +1323,9 @@ void RFIGuiWindow::onStrategySave() { _controller->SetWorkStrategyText(_strategyEditor.GetText()); _controller->SaveStrategy(); _strategyEditor.ResetChangedStatus(); - } else + } else { onStrategySaveAs(); + } } void RFIGuiWindow::onStrategySaveAs() { diff --git a/rfigui/settings.h b/rfigui/settings.h index 748f891f..3aa66f9b 100644 --- a/rfigui/settings.h +++ b/rfigui/settings.h @@ -35,7 +35,7 @@ class StringSetting final : public SettingValue { class SettingItem { public: - SettingItem(std::unique_ptr<SettingValue> defaultValue) + explicit SettingItem(std::unique_ptr<SettingValue> defaultValue) : _defaultValue(std::move(defaultValue)) {} bool HasValue() const { return _value != nullptr; } SettingValue& Value() { return *_value; } @@ -112,9 +112,10 @@ class Settings { void setStr(const std::string& key, const std::string& value) { SettingItem& item = _settings.find(key)->second; - if (static_cast<const StringSetting&>(item.DefaultValue()).Value() == value) + if (static_cast<const StringSetting&>(item.DefaultValue()).Value() == + value) { item.MakeDefault(); - else { + } else { if (!item.HasValue()) item.SetValue(item.DefaultValue().Create()); static_cast<StringSetting&>(item.Value()).Value() = value; } diff --git a/rfigui/strategyeditor.cpp b/rfigui/strategyeditor.cpp index a5d60337..47083581 100644 --- a/rfigui/strategyeditor.cpp +++ b/rfigui/strategyeditor.cpp @@ -124,8 +124,9 @@ void StrategyEditor::updateHighlighting() { _text.get_buffer()->apply_tag(_tagComment, wordStart, iter); mode = Clear; p.state = ParseInfo::Clear; - } else if (c == '[') + } else if (c == '[') { mode = LongCommentStart; + } break; case LongCommentStart: if (c == '[') diff --git a/rfigui/timefrequencywidget.h b/rfigui/timefrequencywidget.h index 04b57f30..f69f637b 100644 --- a/rfigui/timefrequencywidget.h +++ b/rfigui/timefrequencywidget.h @@ -10,7 +10,7 @@ class TimeFrequencyWidget : public Gtk::VBox { public: - TimeFrequencyWidget(MaskedHeatMap& plot) : _heatMap() { + explicit TimeFrequencyWidget(MaskedHeatMap& plot) : _heatMap() { _heatMap.SetPlot(plot); _timePlotWidget.SetPlot(_timePlot); _timePlotWidget.set_size_request(200, 60); diff --git a/scripts/run-cpplint.sh b/scripts/run-cpplint.sh new file mode 100755 index 00000000..0644290f --- /dev/null +++ b/scripts/run-cpplint.sh @@ -0,0 +1,3 @@ +cd .. +cpplint --verbose=4 --filter=-legal/copyright,-build/header_guard,-build/c++11,-build/include_subdir,-build/include_order,-readability/casting,-runtime/int --recursive --exclude=build --exclude=external --extensions=cpp,h . +cd scripts diff --git a/structures/msmetadata.h b/structures/msmetadata.h index 4604b6f6..4feb3bdf 100644 --- a/structures/msmetadata.h +++ b/structures/msmetadata.h @@ -155,15 +155,15 @@ class MSMetaData { unsigned fieldId; bool operator<(const Sequence& rhs) const { - if (antenna1 < rhs.antenna1) + if (antenna1 < rhs.antenna1) { return true; - else if (antenna1 == rhs.antenna1) { - if (antenna2 < rhs.antenna2) + } else if (antenna1 == rhs.antenna1) { + if (antenna2 < rhs.antenna2) { return true; - else if (antenna2 == rhs.antenna2) { - if (spw < rhs.spw) + } else if (antenna2 == rhs.antenna2) { + if (spw < rhs.spw) { return true; - else if (spw == rhs.spw) { + } else if (spw == rhs.spw) { return sequenceId < rhs.sequenceId; } } diff --git a/structures/timefrequencydata.cpp b/structures/timefrequencydata.cpp index 5be7b077..760e257c 100644 --- a/structures/timefrequencydata.cpp +++ b/structures/timefrequencydata.cpp @@ -75,11 +75,11 @@ Image2DCPtr TimeFrequencyData::getSinglePhaseFromTwoPolPhase( } Mask2DCPtr TimeFrequencyData::GetCombinedMask() const { - if (MaskCount() == 0) + if (MaskCount() == 0) { return GetSetMask<false>(); - else if (MaskCount() == 1) + } else if (MaskCount() == 1) { return GetMask(0); - else { + } else { Mask2DPtr mask(new Mask2D(*GetMask(0))); size_t i = 0; while (i != MaskCount()) { @@ -114,9 +114,9 @@ TimeFrequencyData TimeFrequencyData::MakeZeroLinearData(size_t width, TimeFrequencyData TimeFrequencyData::Make( enum ComplexRepresentation representation) const { - if (representation == _complexRepresentation) + if (representation == _complexRepresentation) { return TimeFrequencyData(*this); - else if (_complexRepresentation == ComplexParts) { + } else if (_complexRepresentation == ComplexParts) { TimeFrequencyData data; data._complexRepresentation = representation; data._data.resize(_data.size()); @@ -148,10 +148,11 @@ TimeFrequencyData TimeFrequencyData::Make( } else if (representation == ComplexParts && _complexRepresentation == AmplitudePart) { return MakeFromComplexCombination(*this, *this); - } else + } else { throw std::runtime_error( "Request for time/frequency data with a phase representation that can " "not be extracted from the source (source is not complex)"); + } } TimeFrequencyData TimeFrequencyData::MakeFromComplexCombination( @@ -271,9 +272,10 @@ void TimeFrequencyData::JoinMask(const TimeFrequencyData& other) { } else if (MaskCount() == 0 && _data.size() == other._data.size()) { for (size_t i = 0; i != _data.size(); ++i) _data[i]._flagging = other._data[i]._flagging; - } else + } else { throw std::runtime_error( "Joining time frequency flagging with incompatible structures"); + } } std::vector<std::complex<num_t>> ToComplexVector( diff --git a/structures/timefrequencydata.h b/structures/timefrequencydata.h index 6c43a02b..80533f9d 100644 --- a/structures/timefrequencydata.h +++ b/structures/timefrequencydata.h @@ -313,8 +313,7 @@ class TimeFrequencyData { throw std::runtime_error( "Polarization not available or not implemented"); } - } else // _complexRepresentation != ComplexParts - { + } else { // _complexRepresentation != ComplexParts // TODO should be done on only real or imaginary switch (polarization) { case aocommon::Polarization::StokesI: @@ -388,10 +387,11 @@ class TimeFrequencyData { "polarizations"); } } - } else + } else { throw std::runtime_error( "Trying to convert the polarization in time frequency data in an " "invalid way"); + } } newData.SetGlobalMask(GetMask(polarization)); return newData; @@ -713,9 +713,9 @@ class TimeFrequencyData { case ComplexParts: break; } - if (_data.empty()) + if (_data.empty()) { s << "empty"; - else { + } else { s << "(" << aocommon::Polarization::TypeToFullString(_data[0]._polarization); for (size_t i = 1; i != _data.size(); ++i) @@ -745,13 +745,13 @@ class TimeFrequencyData { } void SetPolarizationData(size_t polarizationIndex, TimeFrequencyData&& data) { - if (data.PolarizationCount() != 1) + if (data.PolarizationCount() != 1) { throw std::runtime_error( "Trying to set multiple polarizations by single polarization index"); - else if (data.ComplexRepresentation() != ComplexRepresentation()) + } else if (data.ComplexRepresentation() != ComplexRepresentation()) { throw std::runtime_error( "Trying to combine TFData's with different complex representations"); - else { + } else { _data[polarizationIndex] = std::move(data._data[0]); data._data.clear(); } @@ -835,22 +835,24 @@ class TimeFrequencyData { return getSinglePhaseFromTwoPolPhase(0, 1); else return getFirstSum(0, 1); - } else // if(_data.size() == 1) + } else { // if(_data.size() == 1) return _data[0]._images[0]; + } } void CopyFlaggingTo(TimeFrequencyData* data) const { - if (MaskCount() == 0) + if (MaskCount() == 0) { data->SetNoMask(); - else if (MaskCount() == 1) + } else if (MaskCount() == 1) { data->SetGlobalMask(GetMask(0)); - else { + } else { if (_data.size() == data->_data.size()) { for (size_t i = 0; i != _data.size(); ++i) data->_data[i]._flagging = _data[i]._flagging; - } else + } else { throw std::runtime_error( "Trying to copy flagging from incompatible time frequency data"); + } } } diff --git a/structures/versionstring.h b/structures/versionstring.h index 1c7a16c1..1ad2685d 100644 --- a/structures/versionstring.h +++ b/structures/versionstring.h @@ -9,7 +9,7 @@ class VersionString { VersionString() : _major(0), _minor(0), _subminor(0), _hasMinor(0), _hasSubminor(0) {} - VersionString(const std::string& str) { + explicit VersionString(const std::string& str) { if (str.empty()) throw std::runtime_error("Empty version string specified"); for (size_t i = 0; i != str.size(); ++i) if (str[i] != '.' && (str[i] < '0' || str[i] > '9')) @@ -51,8 +51,9 @@ class VersionString { } else { return std::to_string(_major) + '.' + std::to_string(_minor); } - } else + } else { return std::to_string(_major); + } } private: diff --git a/test/lua/flagnanstest.cpp b/test/lua/flagnanstest.cpp index 9ac9fda8..645faf7b 100644 --- a/test/lua/flagnanstest.cpp +++ b/test/lua/flagnanstest.cpp @@ -7,7 +7,7 @@ #include "../../algorithms/testsetgenerator.h" -using namespace aocommon; +using aocommon::Polarization; BOOST_AUTO_TEST_SUITE(lua_flagnans, *boost::unit_test::label("lua")) diff --git a/util/numberparser.h b/util/numberparser.h index 73d38d1f..875e59b8 100644 --- a/util/numberparser.h +++ b/util/numberparser.h @@ -47,8 +47,9 @@ class NumberParser { } else if (isPositiveSymbol(*str)) { isNegative = false; ++str; - } else + } else { isNegative = false; + } // Read everything before decimal point if (!isDigit(*str)) @@ -111,8 +112,9 @@ class NumberParser { } else if (isPositiveSymbol(*str)) { isNegative = false; ++str; - } else + } else { isNegative = false; + } // Read digits if (!isDigit(*str)) @@ -132,9 +134,10 @@ class NumberParser { return -val; else return val; - } else + } else { throw NumberParsingException( "The integer contains invalid characters after its digits"); + } } static double intPow10(int par) { diff --git a/util/process.h b/util/process.h index 4d162b31..6c018c2a 100644 --- a/util/process.h +++ b/util/process.h @@ -7,7 +7,7 @@ class Process { public: - Process(const std::string& cmdLine) { + explicit Process(const std::string& cmdLine) { _pid = vfork(); switch (_pid) { case -1: // Error -- GitLab