Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
39a6998d
Commit
39a6998d
authored
Mar 20, 2020
by
David Fairbrother
Browse files
Fix Cppcheck warnings for 1.90
parent
a200387f
Changes
117
Show whitespace changes
Inline
Side-by-side
Framework/API/src/Expression.cpp
View file @
39a6998d
...
...
@@ -117,8 +117,8 @@ Expression &Expression::operator=(const Expression &expr) {
m_funct
=
expr
.
m_funct
;
m_op
=
expr
.
m_op
;
m_terms
=
expr
.
m_terms
;
//
m_expr = expr.m_expr;
//
m_tokens = expr.m_tokens;
m_expr
=
expr
.
m_expr
;
m_tokens
=
expr
.
m_tokens
;
return
*
this
;
}
...
...
Framework/API/src/IFunction.cpp
View file @
39a6998d
...
...
@@ -559,10 +559,11 @@ std::vector<std::string> IFunction::getParameterNames() const {
* @param handler :: A new handler
*/
void
IFunction
::
setHandler
(
std
::
unique_ptr
<
FunctionHandler
>
handler
)
{
m_handler
=
std
::
move
(
handler
);
if
(
handler
&&
handler
->
function
().
get
()
!=
this
)
{
throw
std
::
runtime_error
(
"Function handler points to a different function"
);
}
m_handler
=
std
::
move
(
handler
);
m_handler
->
init
();
}
...
...
@@ -661,6 +662,7 @@ private:
/// @param attr :: The attribute to copy from.
IFunction
::
Attribute
&
IFunction
::
Attribute
::
operator
=
(
const
Attribute
&
attr
)
{
m_data
=
attr
.
m_data
;
m_quoteValue
=
attr
.
m_quoteValue
;
return
*
this
;
}
...
...
Framework/API/src/IndexProperty.cpp
View file @
39a6998d
...
...
@@ -78,7 +78,6 @@ Indexing::SpectrumIndexSet IndexProperty::getIndices() const {
static_cast
<
Indexing
::
SpectrumNumber
>
(
static_cast
<
int32_t
>
(
max
)));
}
}
else
{
// cppcheck-suppress constArgument
MSVC_DIAG_OFF
(
4244
);
switch
(
type
)
{
case
IndexType
::
WorkspaceIndex
:
...
...
Framework/API/src/MatrixWorkspace.cpp
View file @
39a6998d
...
...
@@ -1940,8 +1940,6 @@ MatrixWorkspace::findY(double value,
if
(
std
::
isnan
(
value
))
{
for
(
int64_t
i
=
idx
.
first
;
i
<
numHists
;
++
i
)
{
const
auto
&
Y
=
this
->
y
(
i
);
// https://trac.cppcheck.net/ticket/9237 if init buggy with cppcheck
// cppcheck-suppress stlIfFind
if
(
auto
it
=
std
::
find_if
(
std
::
next
(
Y
.
begin
(),
idx
.
second
),
Y
.
end
(),
[](
double
v
)
{
return
std
::
isnan
(
v
);
});
it
!=
Y
.
end
())
{
...
...
@@ -1952,7 +1950,6 @@ MatrixWorkspace::findY(double value,
}
else
{
for
(
int64_t
i
=
idx
.
first
;
i
<
numHists
;
++
i
)
{
const
auto
&
Y
=
this
->
y
(
i
);
// cppcheck-suppress stlIfFind
if
(
auto
it
=
std
::
find
(
std
::
next
(
Y
.
begin
(),
idx
.
second
),
Y
.
end
(),
value
);
it
!=
Y
.
end
())
{
out
=
{
i
,
std
::
distance
(
Y
.
begin
(),
it
)};
...
...
Framework/API/src/ParamFunction.cpp
View file @
39a6998d
...
...
@@ -150,7 +150,7 @@ double ParamFunction::getParameter(const std::string &name) const {
*/
bool
ParamFunction
::
hasParameter
(
const
std
::
string
&
name
)
const
{
return
std
::
find
(
m_parameterNames
.
cbegin
(),
m_parameterNames
.
cend
(),
name
)
!=
m_parameterNames
.
end
();
m_parameterNames
.
c
end
();
}
/**
...
...
Framework/API/test/AlgorithmFactoryTest.h
View file @
39a6998d
...
...
@@ -186,7 +186,7 @@ public:
foundAlg
=
(
"Cat"
==
descItr
->
category
)
&&
(
"ToyAlgorithm"
==
descItr
->
name
)
&&
(
"Dog"
==
descItr
->
alias
)
&&
(
1
==
descItr
->
version
);
descItr
++
;
++
descItr
;
}
TS_ASSERT
(
foundAlg
);
...
...
Framework/API/test/FunctionPropertyTest.h
View file @
39a6998d
...
...
@@ -104,7 +104,6 @@ public:
void
test_Shared_Pointer
()
{
FunctionProperty
prop
(
"fun"
);
std
::
string
error
;
boost
::
shared_ptr
<
FunctionPropertyTest_Function
>
fun_p
(
new
FunctionPropertyTest_Function
);
TS_ASSERT
(
fun_p
);
...
...
Framework/API/test/LogManagerTest.h
View file @
39a6998d
...
...
@@ -555,8 +555,7 @@ private:
LogManager
runInfo
;
const
std
::
string
name
=
"T_prop"
;
runInfo
.
addProperty
<
T
>
(
name
,
value
);
int
result
(
-
1
);
result
=
runInfo
.
getPropertyAsIntegerValue
(
name
);
int
result
=
runInfo
.
getPropertyAsIntegerValue
(
name
);
TS_ASSERT_THROWS_NOTHING
(
result
=
runInfo
.
getPropertyAsIntegerValue
(
name
));
TS_ASSERT_EQUALS
(
value
,
static_cast
<
T
>
(
result
));
}
...
...
@@ -580,12 +579,11 @@ public:
}
void
test_Accessing_Single_Value_From_Times_Series_A_Large_Number_Of_Times
()
{
double
value
(
0.0
);
for
(
size_t
i
=
0
;
i
<
20000
;
++
i
)
{
value
=
m_testRun
.
getPropertyAsSingleValue
(
m_propName
);
// This has an observable side-effect of calling, so we don't need
// to store its return value
m_testRun
.
getPropertyAsSingleValue
(
m_propName
);
}
// Enure variable is used so that it is not optimised away by the compiler
value
+=
1.0
;
}
LogManager
m_testRun
;
...
...
Framework/API/test/MultiDomainFunctionTest.h
View file @
39a6998d
...
...
@@ -324,7 +324,6 @@ public:
void
test_attribute_domain_range
()
{
multi
.
clearDomainIndices
();
multi
.
setLocalAttributeValue
(
0
,
"domains"
,
"0-2"
);
return
;
multi
.
setLocalAttributeValue
(
1
,
"domains"
,
"i"
);
multi
.
setLocalAttributeValue
(
2
,
"domains"
,
"i"
);
...
...
Framework/API/test/RunTest.h
View file @
39a6998d
...
...
@@ -632,10 +632,8 @@ public:
void
test_Accessing_Single_Value_From_Times_Series_A_Large_Number_Of_Times
()
{
double
value
(
0.0
);
for
(
size_t
i
=
0
;
i
<
20000
;
++
i
)
{
value
=
m_testRun
.
getPropertyAsSingleValue
(
m_propName
);
m_testRun
.
getPropertyAsSingleValue
(
m_propName
);
}
// Enure variable is used so that it is not optimised away by the compiler
value
+=
1.0
;
}
Run
m_testRun
;
...
...
Framework/Algorithms/src/ConjoinXRuns.cpp
View file @
39a6998d
...
...
@@ -404,7 +404,7 @@ void ConjoinXRuns::exec() {
<<
". Reason:
\"
"
<<
e
.
what
()
<<
"
\"
. Skipping.
\n
"
;
sampleLogsBehaviour
.
resetSampleLogs
(
temp
);
// remove the skipped one from the list
m_inputWS
.
erase
(
it
);
it
=
m_inputWS
.
erase
(
it
);
--
it
;
}
else
{
throw
std
::
invalid_argument
(
e
);
...
...
Framework/Algorithms/src/CorrectKiKf.cpp
View file @
39a6998d
...
...
@@ -220,11 +220,10 @@ void CorrectKiKf::execEvent() {
PARALLEL_FOR_IF
(
Kernel
::
threadSafe
(
*
outputWS
))
for
(
int64_t
i
=
0
;
i
<
numHistograms
;
++
i
)
{
PARALLEL_START_INTERUPT_REGION
double
Efi
=
0
;
// Now get the detector object for this histogram to check if monitor
// or to get Ef for indirect geometry
if
(
emodeStr
==
"Indirect"
)
{
double
Efi
=
0
;
if
(
efixedProp
!=
EMPTY_DBL
())
{
Efi
=
efixedProp
;
// If a DetectorGroup is present should provide a value as a property
...
...
Framework/Algorithms/src/CreateGroupingWorkspace.cpp
View file @
39a6998d
...
...
@@ -432,7 +432,6 @@ void CreateGroupingWorkspace::exec() {
sortnames
=
true
;
GroupNames
=
""
;
int
maxRecurseDepth
=
this
->
getProperty
(
"MaxRecursionDepth"
);
// cppcheck-suppress syntaxError
PRAGMA_OMP
(
parallel
for
schedule
(
dynamic
,
1
)
)
for
(
int
num
=
0
;
num
<
300
;
++
num
)
{
...
...
Framework/Algorithms/src/DiffractionFocussing2.cpp
View file @
39a6998d
...
...
@@ -590,11 +590,10 @@ void DiffractionFocussing2::determineRebinParameters() {
nGroups
=
group2minmax
.
size
();
// Number of unique groups
double
Xmin
,
Xmax
,
step
;
const
int64_t
xPoints
=
nPoints
+
1
;
// Iterator over all groups to create the new X vectors
for
(
gpit
=
group2minmax
.
begin
();
gpit
!=
group2minmax
.
end
();
gpit
++
)
{
for
(
gpit
=
group2minmax
.
begin
();
gpit
!=
group2minmax
.
end
();
++
gpit
)
{
double
Xmin
,
Xmax
,
step
;
Xmin
=
(
gpit
->
second
).
first
;
Xmax
=
(
gpit
->
second
).
second
;
...
...
Framework/Algorithms/src/FitPeaks.cpp
View file @
39a6998d
...
...
@@ -1771,7 +1771,6 @@ double FitPeaks::fitFunctionSD(
errorid
<<
": "
<<
e
.
what
();
g_log
.
warning
()
<<
"While fitting "
+
errorid
.
str
();
return
DBL_MAX
;
// probably the wrong thing to do
throw
std
::
runtime_error
(
"While fitting "
+
errorid
.
str
());
}
// Retrieve result
...
...
@@ -1847,7 +1846,6 @@ double FitPeaks::fitFunctionMD(API::IFunction_sptr fit_function,
double
chi2
=
DBL_MAX
;
if
(
fitStatus
==
"success"
)
{
chi2
=
fit
->
getProperty
(
"OutputChi2overDoF"
);
fit_function
=
fit
->
getProperty
(
"Function"
);
}
return
chi2
;
...
...
@@ -1883,9 +1881,8 @@ double FitPeaks::fitFunctionHighBackground(
createMatrixWorkspace
(
vec_x
,
vec_y
,
vec_e
);
// Fit peak with background
double
cost
=
fitFunctionSD
(
fit
,
peakfunction
,
bkgdfunc
,
reduced_bkgd_ws
,
0
,
vec_x
.
front
(),
vec_x
.
back
(),
expected_peak_center
,
observe_peak_shape
,
false
);
fitFunctionSD
(
fit
,
peakfunction
,
bkgdfunc
,
reduced_bkgd_ws
,
0
,
vec_x
.
front
(),
vec_x
.
back
(),
expected_peak_center
,
observe_peak_shape
,
false
);
// add the reduced background back
bkgdfunc
->
setParameter
(
0
,
bkgdfunc
->
getParameter
(
0
)
+
...
...
@@ -1893,9 +1890,9 @@ double FitPeaks::fitFunctionHighBackground(
bkgdfunc
->
setParameter
(
1
,
bkgdfunc
->
getParameter
(
1
)
+
high_bkgd_function
->
getParameter
(
1
));
cost
=
fitFunctionSD
(
fit
,
peakfunction
,
bkgdfunc
,
m_inputMatrixWS
,
ws_index
,
vec_x
.
front
(),
vec_x
.
back
(),
expected_peak_center
,
false
,
false
);
double
cost
=
fitFunctionSD
(
fit
,
peakfunction
,
bkgdfunc
,
m_inputMatrixWS
,
ws_index
,
vec_x
.
front
(),
vec_x
.
back
(),
expected_peak_center
,
false
,
false
);
return
cost
;
}
...
...
Framework/Algorithms/src/GenerateEventsFilter.cpp
View file @
39a6998d
...
...
@@ -456,10 +456,9 @@ void GenerateEventsFilter::setFilterByTimeOnly() {
int64_t
curtime_ns
=
m_startTime
.
totalNanoseconds
();
int
wsindex
=
0
;
while
(
curtime_ns
<
m_stopTime
.
totalNanoseconds
())
{
int64_t
deltatime_ns
;
for
(
size_t
id
=
0
;
id
<
numtimeintervals
;
++
id
)
{
// get next time interval value
deltatime_ns
=
vec_dtimens
[
id
];
int64_t
deltatime_ns
=
vec_dtimens
[
id
];
// Calculate next.time
int64_t
nexttime_ns
=
curtime_ns
+
deltatime_ns
;
bool
breaklater
=
false
;
...
...
@@ -831,7 +830,6 @@ void GenerateEventsFilter::makeFilterBySingleValue(
// Initialize control parameters
bool
lastGood
=
false
;
bool
isGood
=
false
;
time_duration
tol
=
DateAndTime
::
durationFromSeconds
(
TimeTolerance
);
int
numgood
=
0
;
DateAndTime
lastTime
,
currT
;
...
...
@@ -844,8 +842,8 @@ void GenerateEventsFilter::makeFilterBySingleValue(
currT
=
m_dblLog
->
nthTime
(
i
);
// A good value?
isGood
=
identifyLogEntry
(
i
,
currT
,
lastGood
,
min
,
max
,
startTime
,
stopTime
,
filterIncrease
,
filterDecrease
);
bool
isGood
=
identifyLogEntry
(
i
,
currT
,
lastGood
,
min
,
max
,
startTime
,
stopTime
,
filterIncrease
,
filterDecrease
);
if
(
isGood
)
numgood
++
;
...
...
@@ -1219,7 +1217,6 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog(
double
currValue
=
m_dblLog
->
nthValue
(
i
);
// Filter out by time and direction (optional)
bool
intime
=
true
;
if
(
currTime
<
startTime
)
{
// case i. Too early, do nothing
createsplitter
=
false
;
...
...
@@ -1254,7 +1251,6 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog(
prevDirection
=
direction
;
// Examine log value for filter
if
(
intime
)
{
// Determine whether direction is fine
bool
correctdir
=
true
;
if
(
filterIncrease
&&
filterDecrease
)
{
...
...
@@ -1285,9 +1281,8 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog(
if
(
g_log
.
is
(
Logger
::
Priority
::
PRIO_DEBUG
))
{
stringstream
dbss
;
dbss
<<
"[DBx257] Examine Log Index "
<<
i
<<
", Value = "
<<
currValue
<<
", Data Range Index = "
<<
index
<<
"; "
dbss
<<
"[DBx257] Examine Log Index "
<<
i
<<
", Value = "
<<
currValue
<<
", Data Range Index = "
<<
index
<<
"; "
<<
"Group Index = "
<<
indexwsindexmap
[
index
/
2
]
<<
" (log value range vector size = "
<<
logvalueranges
.
size
()
<<
"): "
;
...
...
@@ -1345,8 +1340,8 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog(
else
{
// [Situation] Fall between interval (which is not likley happen)
currindex
=
-
1
;
g_log
.
warning
()
<<
"Not likely to happen! Current value = "
<<
currValue
g_log
.
warning
()
<<
"Not likely to happen! Current value = "
<<
currValue
<<
" is within value range but its index = "
<<
index
<<
" has no map to group index. "
<<
"
\n
"
;
...
...
@@ -1377,7 +1372,6 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog(
createsplitter
=
true
;
}
}
}
// ENDIF (log entry in specified time)
// d) Create Splitter
if
(
createsplitter
)
{
...
...
Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp
View file @
39a6998d
...
...
@@ -721,7 +721,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset(
// Set up GSL minimzer
const
gsl_multimin_fminimizer_type
*
T
=
gsl_multimin_fminimizer_nmsimplex
;
gsl_multimin_fminimizer
*
s
=
nullptr
;
gsl_vector
*
ss
,
*
x
;
gsl_multimin_function
minex_func
;
...
...
@@ -729,7 +729,6 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset(
size_t
nopt
=
1
;
size_t
iter
=
0
;
int
status
=
0
;
double
size
;
/* Starting point */
x
=
gsl_vector_alloc
(
nopt
);
...
...
@@ -744,7 +743,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset(
minex_func
.
f
=
&
gsl_costFunction
;
minex_func
.
params
=
&
params
;
s
=
gsl_multimin_fminimizer_alloc
(
T
,
nopt
);
gsl_multimin_fminimizer
*
s
=
gsl_multimin_fminimizer_alloc
(
T
,
nopt
);
gsl_multimin_fminimizer_set
(
s
,
&
minex_func
,
x
,
ss
);
do
{
...
...
@@ -753,7 +752,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset(
if
(
status
)
break
;
size
=
gsl_multimin_fminimizer_size
(
s
);
double
size
=
gsl_multimin_fminimizer_size
(
s
);
status
=
gsl_multimin_test_size
(
size
,
1e-4
);
}
while
(
status
==
GSL_CONTINUE
&&
iter
<
50
);
...
...
Framework/Algorithms/src/PDCalibration.cpp
View file @
39a6998d
...
...
@@ -755,14 +755,13 @@ double fitDIFCtZeroDIFA(std::vector<double> &peaks, double &difc, double &t0,
size_t
iter
=
0
;
// number of iterations
const
size_t
MAX_ITER
=
75
*
numParams
;
int
status
=
0
;
double
size
;
do
{
iter
++
;
status
=
gsl_multimin_fminimizer_iterate
(
minimizer
);
if
(
status
)
break
;
size
=
gsl_multimin_fminimizer_size
(
minimizer
);
double
size
=
gsl_multimin_fminimizer_size
(
minimizer
);
status
=
gsl_multimin_test_size
(
size
,
1e-4
);
}
while
(
status
==
GSL_CONTINUE
&&
iter
<
MAX_ITER
);
...
...
Framework/Algorithms/src/PolarizationCorrectionWildes.cpp
View file @
39a6998d
...
...
@@ -96,30 +96,22 @@ void fourInputsCorrectedAndErrors(
const
auto
diag1
=
1.
/
f1
;
const
auto
off1
=
(
f1
-
1.
)
/
f1
;
Eigen
::
Matrix4d
F1m
;
// Suppress warnings about suspicious init with Eigen
// cppcheck-suppress constStatement
F1m
<<
1.
,
0.
,
0.
,
0.
,
0.
,
1.
,
0.
,
0.
,
off1
,
0.
,
diag1
,
0.
,
0.
,
off1
,
0.
,
diag1
;
const
auto
diag2
=
1.
/
f2
;
const
auto
off2
=
(
f2
-
1.
)
/
f2
;
Eigen
::
Matrix4d
F2m
;
// cppcheck-suppress constStatement
F2m
<<
1.
,
0.
,
0.
,
0.
,
off2
,
diag2
,
0.
,
0.
,
0.
,
0.
,
1.
,
0.
,
0.
,
0.
,
off2
,
diag2
;
const
auto
diag3
=
(
p1
-
1.
)
/
(
2.
*
p1
-
1.
);
const
auto
off3
=
p1
/
(
2.
*
p1
-
1
);
Eigen
::
Matrix4d
P1m
;
// cppcheck-suppress constStatement
P1m
<<
diag3
,
0
,
off3
,
0
,
0
,
diag3
,
0
,
off3
,
off3
,
0
,
diag3
,
0
,
0
,
off3
,
0
,
diag3
;
const
auto
diag4
=
(
p2
-
1.
)
/
(
2.
*
p2
-
1.
);
const
auto
off4
=
p2
/
(
2.
*
p2
-
1.
);
Eigen
::
Matrix4d
P2m
;
// cppcheck-suppress constStatement
P2m
<<
diag4
,
off4
,
0.
,
0.
,
off4
,
diag4
,
0.
,
0.
,
0.
,
0.
,
diag4
,
off4
,
0.
,
0.
,
off4
,
diag4
;
const
Eigen
::
Vector4d
intensities
(
ppy
,
pmy
,
mpy
,
mmy
);
...
...
@@ -131,26 +123,18 @@ void fourInputsCorrectedAndErrors(
// the matrices above, multiplied by the error.
const
auto
elemE1
=
-
1.
/
pow
<
2
>
(
f1
)
*
f1E
;
Eigen
::
Matrix4d
F1Em
;
// cppcheck-suppress constStatement
F1Em
<<
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
-
elemE1
,
0.
,
elemE1
,
0.
,
0.
,
-
elemE1
,
0.
,
elemE1
;
const
auto
elemE2
=
-
1.
/
pow
<
2
>
(
f2
)
*
f2E
;
Eigen
::
Matrix4d
F2Em
;
// cppcheck-suppress constStatement
F2Em
<<
0.
,
0.
,
0.
,
0.
,
-
elemE2
,
elemE2
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
-
elemE2
,
elemE2
;
const
auto
elemE3
=
1.
/
pow
<
2
>
(
2.
*
p1
-
1.
)
*
p1E
;
Eigen
::
Matrix4d
P1Em
;
// cppcheck-suppress constStatement
P1Em
<<
elemE3
,
0.
,
-
elemE3
,
0.
,
0.
,
elemE3
,
0.
,
-
elemE3
,
-
elemE3
,
0.
,
elemE3
,
0.
,
0.
,
-
elemE3
,
0.
,
elemE3
;
const
auto
elemE4
=
1.
/
pow
<
2
>
(
2.
*
p2
-
1.
)
*
p2E
;
Eigen
::
Matrix4d
P2Em
;
// cppcheck-suppress constStatement
P2Em
<<
elemE4
,
-
elemE4
,
0.
,
0.
,
-
elemE4
,
elemE4
,
0.
,
0.
,
0.
,
0.
,
elemE4
,
-
elemE4
,
0.
,
0.
,
-
elemE4
,
elemE4
;
const
Eigen
::
Vector4d
yErrors
(
ppyE
,
pmyE
,
mpyE
,
mmyE
);
...
...
Framework/Algorithms/test/AnyShapeAbsorptionTest.h
View file @
39a6998d
...
...
@@ -257,7 +257,6 @@ public:
constexpr
double
WL_DELTA
=
(
2.9
-
WL_MIN
)
/
static_cast
<
double
>
(
NUM_VALS
);
// create the input workspace
const
std
::
string
IN_WS
{
"AbsorptionCorrection_Input"
};
auto
inputWS
=
WorkspaceCreationHelper
::
create2DWorkspaceBinned
(
1
,
NUM_VALS
,
WL_MIN
,
WL_DELTA
);
auto
testInst
=
...
...
Prev
1
2
3
4
5
6
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment