diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 34f1ac56f..9808b9acb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,6 +63,16 @@ jobs: run: git diff > clang_tidy.patch && echo -e "if \n [ -s clang_tidy.patch ] \nthen \n echo "clang_tidy not applied:"; echo ""; more clang_tidy.patch; exit 1 \nfi \n" > detect && chmod +x ./detect && ./detect + cpplint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: install-dependencies + run: sudo apt-get install python3-pip && sudo pip3 install cpplint + - name: run checks + run: find ./src/ -iname *.h -o -iname *.cc | xargs cpplint --filter=-,+build/class,+build/c++14,+build/deprecated,+build/explicit_make_pair,+build/include_what_you_use,+build/printf_format,+build/storage_class,+readability/constructors,+readability/namespace,+readability/newline,+readability/utf8,+runtime/casting,+runtime/explicit,+runtime/indentation_namespace,+runtime/init,+runtime/invalid_increment,+runtime/member_string_references,+runtime/memset,+runtime/operator,+runtime/printf,+runtime/printf_format,+whitespace/blank_line,+whitespace/comma,+whitespace/comments,+whitespace/empty_conditional_body,+whitespace/end-of-line,+whitespace/ending-newline,+whitespace/semicolon,+whitespace/tab + + volk-gnsssdr-windows: runs-on: windows-latest steps: diff --git a/docs/changelog b/docs/changelog index f08b35892..178b3d861 100644 --- a/docs/changelog +++ b/docs/changelog @@ -44,12 +44,15 @@ SPDX-License-Identifier: GPL-3.0-or-later - Rewriting of acquisition and tracking adapters, thus avoiding a lot of code duplication. - New CMake option ENABLE_ARMA_NO_DEBUG defines the macro ARMA_NO_DEBUG, which disables all run-time checks, such as bounds checking, in the Armadillo library. This will result in faster code. This option is disabled by default during development, but automatically set to ON if the option ENABLE_PACKAGING is set to ON. - Apply more clang-tidy checks related to readability: readability-avoid-const-params-in-decls, readability-braces-around-statements, readability-isolate-declaration, readability-redundant-control-flow, readability-uppercase-literal-suffix. Fixed raised warnings. -- Fixed cpplint.py build/include_what_you_use, whitespace/tab, whitespace/blank_line errors. +- Fixed a number of defects detected by cpplint.py. Filters applied: +build/class,+build/c++14,+build/deprecated,+build/explicit_make_pair,+build/include_what_you_use,+build/printf_format,+build/storage_class,+readability/constructors,+readability/namespace,+readability/newline,+readability/utf8,+runtime/casting,+runtime/explicit,+runtime/indentation_namespace,+runtime/init,+runtime/invalid_increment,+runtime/member_string_references,+runtime/memset,+runtime/operator,+runtime/printf,+runtime/printf_format,+whitespace/blank_line. - clang-format can now be applied to the whole code tree without breaking compilation. - Added more check options to .clang-tidy file. - Default Python version is now >= 3.4. Python 2.7 still can be used in systems where Python 3 is not available (e.g., CentOS 7, Debian 8, Ubuntu 10.04). - CMake now passes the CMAKE_BUILD_TYPE (or configuration in multi-configuration generators like Xcode) to modules built along gnss-sdr (e.g, the volk_gnsssdr library and googletest). Build types available: None, Release (by default), Debug, RelWithDebInfo, MinSizeRel, Coverage, NoOptWithASM, O2WithASM, O3WithASM, ASAN. - Updated links in comments along the source code and in CMake scripts. +- Create a CI job in GitHub to ensure that clang-tidy has been applied in most of the source code (some optional blocks and tests are left apart). +- Create a CI job in GitHub to ensure that clang-format has been applied. +- Create a CI job in GitHub to ensure that cpplint filters have been applied. - Create a CI job in GitHub to ensure compliance with REUSE Specification (see https://reuse.software) diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc index a4a27f8e8..63f3324d4 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc @@ -158,7 +158,6 @@ double adjcp(rtcm_t *rtcm, int sat, int freq, double cp) { if (rtcm->cp[sat - 1][freq] == 0.0) { - ; } else if (cp < rtcm->cp[sat - 1][freq] - 750.0) { @@ -1860,7 +1859,6 @@ int decode_type1047(rtcm_t *rtcm) eph_t eph = {0, -1, -1, 0, 0, 0, 0, 0, {0, 0.0}, {0, 0.0}, {0, 0.0}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {0.0}, {0.0}, 0.0, 0.0}; - ; double toc; double sqrtA; char *msg; diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 041423f87..5d98db38c 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -3142,7 +3142,6 @@ int readblq(const char *file, const char *sta, double *odisp) sscanf(sta, "%16s", staname); for (p = staname; (*p = static_cast(toupper(static_cast(*p)))); p++) { - ; } if (!(fp = fopen(file, "re"))) @@ -3163,7 +3162,6 @@ int readblq(const char *file, const char *sta, double *odisp) } for (p = name; (*p = static_cast(toupper(static_cast(*p)))); p++) { - ; } if (strcmp(name, staname) != 0) { diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index 7430695e6..6f4944f82 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -1002,35 +1002,35 @@ void detslp_gf_L1L5(rtk_t *rtk, const obsd_t *obs, int i, int j, void detslp_dop(rtk_t *rtk __attribute__((unused)), const obsd_t *obs __attribute__((unused)), int i __attribute__((unused)), int rcv __attribute__((unused)), const nav_t *nav __attribute__((unused))) { -/* detection with doppler disabled because of clock-jump issue (v.2.3.0) */ + /* detection with doppler disabled because of clock-jump issue (v.2.3.0) */ #if 0 - int f,sat = obs[i].sat; - double tt,dph,dpt,lam,thres; + int f, sat = obs[i].sat; + double tt, dph, dpt, lam, thres; - trace(3,"detslp_dop: i=%d rcv=%d\n",i,rcv); + trace(3, "detslp_dop: i=%d rcv=%d\n", i, rcv); - for (f = 0;fopt.nf;f++) + for (f = 0; f < rtk->opt.nf; f++) { - if (obs[i].L[f] == 0.0 || obs[i].D[f] == 0.0 || rtk->ph[rcv-1][sat-1][f] == 0.0) + if (obs[i].L[f] == 0.0 || obs[i].D[f] == 0.0 || rtk->ph[rcv - 1][sat - 1][f] == 0.0) { continue; } - if (fabs(tt = timediff(obs[i].time,rtk->pt[rcv-1][sat-1][f]))lam[sat-1][f])<=0.0) continue; + if (fabs(tt = timediff(obs[i].time, rtk->pt[rcv - 1][sat - 1][f])) < DTTOL) continue; + if ((lam = nav->lam[sat - 1][f]) <= 0.0) continue; /* cycle slip threshold (cycle) */ - thres = MAXACC*tt*tt/2.0/lam+rtk->opt.err[4]*fabs(tt)*4.0; + thres = MAXACC * tt * tt / 2.0 / lam + rtk->opt.err[4] * fabs(tt) * 4.0; /* phase difference and doppler x time (cycle) */ - dph = obs[i].L[f]-rtk->ph[rcv-1][sat-1][f]; - dpt = -obs[i].D[f]*tt; + dph = obs[i].L[f] - rtk->ph[rcv - 1][sat - 1][f]; + dpt = -obs[i].D[f] * tt; - if (fabs(dph-dpt)<=thres) continue; + if (fabs(dph - dpt) <= thres) continue; - rtk->slip[sat-1][f]| = 1; + rtk->slip[sat - 1][f] | = 1; - errmsg(rtk,"slip detected (sat=%2d rcv=%d L%d=%.3f %.3f thres=%.3f)\n", - sat,rcv,f+1,dph,dpt,thres); + errmsg(rtk, "slip detected (sat=%2d rcv=%d L%d=%.3f %.3f thres=%.3f)\n", + sat, rcv, f + 1, dph, dpt, thres); } #endif } @@ -1814,26 +1814,26 @@ int ddres(rtk_t *rtk, const nav_t *nav, double dt, const double *x, nb[b]++; } #if 0 /* residuals referenced to reference satellite (2.4.2 p11) */ - /* restore single-differenced residuals assuming sum equal zero */ - if (fssat[j].resc[f]; - s/=nb[b]+1; - for (j=0;jssat[j].resc[f]!=0.0) rtk->ssat[j].resc[f]-=s; - } - } - else - { - for (j=0,s=0.0;jssat[j].resp[f-nf]; - s/=nb[b]+1; - for (j=0;jssat[j].resp[f-nf]!=0.0) - rtk->ssat[j].resp[f-nf]-=s; - } - } + /* restore single-differenced residuals assuming sum equal zero */ + if (f < nf) + { + for (j = 0, s = 0.0; j < MAXSAT; j++) s += rtk->ssat[j].resc[f]; + s /= nb[b] + 1; + for (j = 0; j < MAXSAT; j++) + { + if (j == sat[i] - 1 || rtk->ssat[j].resc[f] != 0.0) rtk->ssat[j].resc[f] -= s; + } + } + else + { + for (j = 0, s = 0.0; j < MAXSAT; j++) s += rtk->ssat[j].resp[f - nf]; + s /= nb[b] + 1; + for (j = 0; j < MAXSAT; j++) + { + if (j == sat[i] - 1 || rtk->ssat[j].resp[f - nf] != 0.0) + rtk->ssat[j].resp[f - nf] -= s; + } + } #endif b++; } @@ -2323,21 +2323,21 @@ int valpos(rtk_t *rtk, const double *v, const double *R, const int *vflg, sat1, sat2, stype, freq + 1, v[i], std::sqrt(R[i + i * nv])); } #if 0 /* omitted v.2.4.0 */ - if (stat&&nv>NP(opt)) + if (stat && nv > NP(opt)) { /* chi-square validation */ - for (i = 0; i chisqr[nv-NP(opt)-1]) + if (vv > chisqr[nv - NP(opt) - 1]) { - errmsg(rtk,"residuals validation failed (nv=%d np=%d vv=%.2f cs=%.2f)\n", - nv, NP(opt), vv, chisqr[nv-NP(opt)-1]); + errmsg(rtk, "residuals validation failed (nv=%d np=%d vv=%.2f cs=%.2f)\n", + nv, NP(opt), vv, chisqr[nv - NP(opt) - 1]); stat = 0; } else { - trace(3,"valpos : validation ok (%s nv=%d np=%d vv=%.2f cs=%.2f)\n", - rtk->tstr, nv, NP(opt), vv, chisqr[nv-NP(opt)-1]); + trace(3, "valpos : validation ok (%s nv=%d np=%d vv=%.2f cs=%.2f)\n", + rtk->tstr, nv, NP(opt), vv, chisqr[nv - NP(opt) - 1]); } } #endif @@ -2790,11 +2790,9 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) /* count rover/base station observations */ for (nu = 0; nu < n && obs[nu].rcv == 1; nu++) { - ; } for (nr = 0; nu + nr < n && obs[nu + nr].rcv == 2; nr++) { - ; } time = rtk->sol.time; /* previous epoch */ diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index b614ff40e..760535bc9 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -1157,7 +1157,6 @@ int waittcpsvr(tcpsvr_t *tcpsvr, char *msg) } while (accsock(tcpsvr, msg)) { - ; } updatetcpsvr(tcpsvr, msg); return tcpsvr->svr.state == 2; @@ -2848,7 +2847,6 @@ void strsendcmd(stream_t *str, const char *cmd) if (!*msg || *msg == '#') { /* null or comment */ - ; } else if (*msg == '!') { /* binary escape */ diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h index 224a3f192..58eead7e1 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.h @@ -29,10 +29,11 @@ #include // for block #include // for gr_vector_int #include // for int32_t -#include // for string, ofstream -#include // for shared_ptr -#include -#include +#include // for std::ofstream +#include // for std::map +#include // for std:shared_ptr +#include // for std::string +#include // for std::vector class Gnss_Synchro; class hybrid_observables_gs; @@ -58,7 +59,7 @@ public: private: friend hybrid_observables_gs_sptr hybrid_observables_gs_make(const Obs_Conf& conf_); - hybrid_observables_gs(const Obs_Conf& conf_); + explicit hybrid_observables_gs(const Obs_Conf& conf_); Obs_Conf d_conf; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc index f06363308..0d99cefcf 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc @@ -315,7 +315,7 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t // 2. Viterbi decoder // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) - // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180� + // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180 degrees for (int32_t i = 0; i < frame_length; i++) { if ((i + 1) % 2 == 0) diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc index 053c07c58..d8c2a0b04 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -244,7 +244,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; d_carrier_frequency_hz = d_acq_carrier_doppler_hz + (DFRQ1_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); - ; + d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc index b798f2115..6e395f596 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -242,7 +242,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; d_carrier_frequency_hz = d_acq_carrier_doppler_hz + (DFRQ2_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); - ; + d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 46c16db32..c53141728 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -205,7 +205,7 @@ bool Fpga_Multicorrelator_8sc::free() void Fpga_Multicorrelator_8sc::set_channel(uint32_t channel) { - char device_io_name[max_length_deviceio_name]; // driver io name + char device_io_name[max_length_deviceio_name] = ""; // driver io name d_channel = channel; // open the device corresponding to the assigned channel diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 62910b295..07c065c25 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -1723,8 +1723,7 @@ bool HybridObservablesTestFpga::ReadRinexObs(std::vector* obs_vec, Gn } } } // end while - - } // End of 'try' block + } // End of 'try' block catch (const gpstk::FFStreamError& e) { diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index e44c71536..3b62c374f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -1240,9 +1240,8 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } } } // end plot - - } // end acquisition Delay errors loop - } // end acquisition Doppler errors loop + } // end acquisition Delay errors loop + } // end acquisition Doppler errors loop pull_in_results_v_v.push_back(pull_in_results_v); } // end CN0 LOOP diff --git a/src/utils/rinex-tools/obsdiff.cc b/src/utils/rinex-tools/obsdiff.cc index 88bdef894..ee2fdb6fe 100644 --- a/src/utils/rinex-tools/obsdiff.cc +++ b/src/utils/rinex-tools/obsdiff.cc @@ -125,11 +125,11 @@ std::map ReadRinexObs(std::string rinex_file, char system, std:: { obs_mat.at(obs_mat.n_rows - 1, 0) = sow; dataobj = r_ref_data.getObs(prn, "C1C", r_ref_header); - obs_mat.at(obs_mat.n_rows - 1, 1) = dataobj.data; //C1C P1 (psudorange L1) + obs_mat.at(obs_mat.n_rows - 1, 1) = dataobj.data; // C1C P1 (pseudorange L1) dataobj = r_ref_data.getObs(prn, "D1C", r_ref_header); - obs_mat.at(obs_mat.n_rows - 1, 2) = dataobj.data; //D1C Carrier Doppler + obs_mat.at(obs_mat.n_rows - 1, 2) = dataobj.data; // D1C Carrier Doppler dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header); - obs_mat.at(obs_mat.n_rows - 1, 3) = dataobj.data; //L1C Carrier Phase + obs_mat.at(obs_mat.n_rows - 1, 3) = dataobj.data; // L1C Carrier Phase } else if (strcmp("1B\0", signal.c_str()) == 0) { @@ -141,7 +141,7 @@ std::map ReadRinexObs(std::string rinex_file, char system, std:: dataobj = r_ref_data.getObs(prn, "L1B", r_ref_header); obs_mat.at(obs_mat.n_rows - 1, 3) = dataobj.data; } - else if (strcmp("2S\0", signal.c_str()) == 0) //L2M + else if (strcmp("2S\0", signal.c_str()) == 0) // L2M { obs_mat.at(obs_mat.n_rows - 1, 0) = sow; dataobj = r_ref_data.getObs(prn, "C2S", r_ref_header);