Skip to content

Commit 6790db5

Browse files
committed
Improvements to clang-tidy checks
* Checks are now applied to .h and .imp files * The C++17 extension of directly specifying nested namespaces via the :: notation is now enforced. * Checks are not applied to the GUI for now (due to challenges with excluding headers, and flagging issues that ultimately arise from the design of wxWidgets) .
1 parent 8994b3a commit 6790db5

133 files changed

Lines changed: 1121 additions & 1237 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-tidy

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ Checks: |
77
-modernize-avoid-c-arrays,
88
-modernize-pass-by-value,
99
-modernize-use-nodiscard,
10-
-modernize-concat-nested-namespaces,
1110
cppcoreguidelines-pro-type-cstyle-cast,
1211
cppcoreguidelines-pro-type-member-init,
1312
cppcoreguidelines-prefer-member-initializer,
1413
misc-const-correctness
1514
WarningsAsErrors: '*'
16-
# Don't bother with wxWidgets headers
17-
HeaderFilterRegex: '^((?!labenski).)*$'
18-
AnalyzeTemporaryDtors: false
15+
HeaderFilterRegex: '.*'
1916
FormatStyle: none
2017
User: arbiter
2118
CheckOptions:

Makefile.am

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,7 @@ msw-msi:
636636
light -ext WixUIExtension gambit.wixobj
637637

638638
clang-tidy:
639-
clang-tidy ${top_srcdir}/src/core/*.cc -- --std=c++17 -I ${top_srcdir}/src -I ${top_srcdir}/src/labenski/include -DVERSION="" ${WX_CXXFLAGS}
640-
clang-tidy ${top_srcdir}/src/games/*.cc ${top_srcdir}/src/games/*/*.cc -- --std=c++17 -I ${top_srcdir}/src -I ${top_srcdir}/src/labenski/include -DVERSION="" ${WX_CXXFLAGS}
641-
clang-tidy ${top_srcdir}/src/solvers/*/*.cc -- --std=c++17 -I ${top_srcdir}/src -I ${top_srcdir}/src/labenski/include -DVERSION="" ${WX_CXXFLAGS}
642-
clang-tidy ${top_srcdir}/src/tools/*/*.cc -- --std=c++17 -I ${top_srcdir}/src -I ${top_srcdir}/src/labenski/include -DVERSION="" ${WX_CXXFLAGS}
643-
clang-tidy ${top_srcdir}/src/gui/*.cc -- --std=c++17 -I ${top_srcdir}/src -I ${top_srcdir}/src/labenski/include -DVERSION="" ${WX_CXXFLAGS}
639+
clang-tidy ${top_srcdir}/src/core/*.cc -- --std=c++17 -I ${top_srcdir}/src -DVERSION=""
640+
clang-tidy ${top_srcdir}/src/games/*.cc ${top_srcdir}/src/games/*/*.cc -- --std=c++17 -I ${top_srcdir}/src -DVERSION=""
641+
clang-tidy ${top_srcdir}/src/solvers/*/*.cc -- --std=c++17 -I ${top_srcdir}/src -DVERSION=""
642+
clang-tidy ${top_srcdir}/src/tools/*/*.cc -- --std=c++17 -I ${top_srcdir}/src -DVERSION=""

src/core/function.cc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void ConjugatePRMinimizer::IntermediatePoint(const Function &fdf, const Vector<d
9696
double stepb, fb;
9797

9898
trial:
99-
double u = fabs(pg * lambda * stepc);
99+
const double u = fabs(pg * lambda * stepc);
100100
if ((fc - fa) + u == 0) {
101101
// TLT: Added this check 2002/08/31 due to floating point exceptions
102102
// under MSW. Not really sure how to handle this correctly.
@@ -160,12 +160,12 @@ void ConjugatePRMinimizer::Minimize(const Function &fdf, const Vector<double> &x
160160
return; /* MAX ITERATIONS */
161161
}
162162

163-
double dw = w - u;
164-
double dv = v - u;
163+
const double dw = w - u;
164+
const double dv = v - u;
165165
double du = 0.0;
166166

167-
double e1 = ((fv - fu) * dw * dw + (fu - fw) * dv * dv);
168-
double e2 = 2.0 * ((fv - fu) * dw + (fu - fw) * dv);
167+
const double e1 = ((fv - fu) * dw * dw + (fu - fw) * dv * dv);
168+
const double e2 = 2.0 * ((fv - fu) * dw + (fu - fw) * dv);
169169

170170
if (e2 != 0.0) {
171171
du = e1 / e2;
@@ -272,7 +272,7 @@ void ConjugatePRMinimizer::Set(const Function &fdf, const Vector<double> &x, dou
272272
p = gradient;
273273
g0 = gradient;
274274

275-
double gnorm = std::sqrt(gradient.NormSquared());
275+
const double gnorm = std::sqrt(gradient.NormSquared());
276276
pnorm = gnorm;
277277
g0norm = gnorm;
278278
}
@@ -282,9 +282,12 @@ void ConjugatePRMinimizer::Restart() { iter = 0; }
282282
bool ConjugatePRMinimizer::Iterate(const Function &fdf, Vector<double> &x, double &f,
283283
Vector<double> &gradient, Vector<double> &dx)
284284
{
285-
double fa = f, fb, fc;
285+
const double fa = f;
286+
double fb, fc;
286287
double dir;
287-
double stepa = 0.0, stepb, stepc = step, tol = m_tol;
288+
const double stepa = 0.0;
289+
double stepb;
290+
const double stepc = step, tol = m_tol;
288291

289292
double g1norm;
290293
double pg;

0 commit comments

Comments
 (0)