Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
a200387f
Commit
a200387f
authored
Mar 20, 2020
by
David Fairbrother
Browse files
Update suppressions list for cppcheck 1.9
parent
0228a728
Changes
11
Hide whitespace changes
Inline
Side-by-side
Framework/Crystal/src/LoadIsawPeaks.cpp
View file @
a200387f
...
...
@@ -68,7 +68,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const {
throw
std
::
logic_error
(
std
::
string
(
"No Version for Peaks file"
));
getWord
(
in
,
false
);
// tag
std
::
string
C_Facility
=
getWord
(
in
,
false
);
getWord
(
in
,
false
);
// C_Facility
getWord
(
in
,
false
);
// tag
std
::
string
C_Instrument
=
getWord
(
in
,
false
);
...
...
@@ -142,7 +142,7 @@ std::string LoadIsawPeaks::readHeader(const PeaksWorkspace_sptr &outWS,
throw
std
::
logic_error
(
std
::
string
(
"No Version for Peaks file"
));
getWord
(
in
,
false
);
// tag
std
::
string
C_Facility
=
getWord
(
in
,
false
);
getWord
(
in
,
false
);
// C_Facility
getWord
(
in
,
false
);
// tag
std
::
string
C_Instrument
=
getWord
(
in
,
false
);
...
...
Framework/DataHandling/src/LoadRaw/isisraw.cpp
View file @
a200387f
...
...
@@ -715,10 +715,10 @@ int ISISRAW::ioRAW(FILE *file, LOG_STRUCT *s, int len, bool from_file) {
int
ISISRAW
::
ioRAW
(
FILE
*
file
,
LOG_LINE
*
s
,
int
len
,
bool
from_file
)
{
char
padding
[
5
];
memset
(
padding
,
' '
,
sizeof
(
padding
));
int
i
,
nbytes_rounded
;
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
ioRAW
(
file
,
&
(
s
[
i
].
len
),
1
,
from_file
);
nbytes_rounded
=
4
*
(
1
+
(
s
[
i
].
len
-
1
)
/
4
);
int
nbytes_rounded
=
4
*
(
1
+
(
s
[
i
].
len
-
1
)
/
4
);
ioRAW
(
file
,
&
(
s
[
i
].
data
),
s
[
i
].
len
,
from_file
);
ioRAW
(
file
,
padding
,
nbytes_rounded
-
s
[
i
].
len
,
from_file
);
}
...
...
@@ -731,12 +731,11 @@ int ISISRAW::ioRAW(FILE *file, char *s, int len, bool from_file) {
return
0
;
}
size_t
n
;
if
(
from_file
)
{
n
=
fread
(
s
,
sizeof
(
char
),
len
,
file
);
size_t
n
=
fread
(
s
,
sizeof
(
char
),
len
,
file
);
return
static_cast
<
int
>
(
n
-
len
);
}
else
{
n
=
fwrite
(
s
,
sizeof
(
char
),
len
,
file
);
fwrite
(
s
,
sizeof
(
char
),
len
,
file
);
}
return
0
;
...
...
@@ -748,12 +747,11 @@ int ISISRAW::ioRAW(FILE *file, int *s, int len, bool from_file) {
return
0
;
}
size_t
n
;
if
(
from_file
)
{
n
=
fread
(
s
,
sizeof
(
int
),
len
,
file
);
size_t
n
=
fread
(
s
,
sizeof
(
int
),
len
,
file
);
return
static_cast
<
int
>
(
n
-
len
);
}
else
{
n
=
fwrite
(
s
,
sizeof
(
int
),
len
,
file
);
fwrite
(
s
,
sizeof
(
int
),
len
,
file
);
}
return
0
;
...
...
@@ -765,12 +763,11 @@ int ISISRAW::ioRAW(FILE *file, uint32_t *s, int len, bool from_file) {
return
0
;
}
size_t
n
;
if
(
from_file
)
{
n
=
fread
(
s
,
sizeof
(
uint32_t
),
len
,
file
);
size_t
n
=
fread
(
s
,
sizeof
(
uint32_t
),
len
,
file
);
return
static_cast
<
int
>
(
n
-
len
);
}
else
{
n
=
fwrite
(
s
,
sizeof
(
uint32_t
),
len
,
file
);
fwrite
(
s
,
sizeof
(
uint32_t
),
len
,
file
);
}
return
0
;
}
...
...
@@ -782,14 +779,13 @@ int ISISRAW::ioRAW(FILE *file, float *s, int len, bool from_file) {
return
0
;
}
size_t
n
;
if
(
from_file
)
{
n
=
fread
(
s
,
sizeof
(
float
),
len
,
file
);
size_t
n
=
fread
(
s
,
sizeof
(
float
),
len
,
file
);
vaxf_to_local
(
s
,
&
len
,
&
errcode
);
return
static_cast
<
int
>
(
n
-
len
);
}
else
{
local_to_vaxf
(
s
,
&
len
,
&
errcode
);
n
=
fwrite
(
s
,
sizeof
(
float
),
len
,
file
);
fwrite
(
s
,
sizeof
(
float
),
len
,
file
);
vaxf_to_local
(
s
,
&
len
,
&
errcode
);
}
return
0
;
...
...
@@ -942,6 +938,7 @@ int ISISRAW::vmstime(char *timbuf, int len, time_t time_value) {
* get time in VMS format 01-JAN-1970 00:00:00
*/
size_t
i
,
n
;
// cppcheck-suppress redundantAssignment
struct
tm
*
tmstruct
=
nullptr
;
#ifdef MS_VISUAL_STUDIO
errno_t
err
=
localtime_s
(
tmstruct
,
&
time_value
);
...
...
Framework/ICat/inc/MantidICat/ICat4/ICat4Catalog.h
View file @
a200387f
...
...
@@ -79,7 +79,7 @@ private:
void
saveDataFiles
(
std
::
vector
<
ICat4
::
xsd__anyType
*>
response
,
API
::
ITableWorkspace_sptr
&
outputws
);
// Saves "DataSets" information to the output workspace.
void
saveDataSets
(
const
std
::
vector
<
ICat4
::
xsd__anyType
*>
&
response
,
void
saveDataSets
(
std
::
vector
<
ICat4
::
xsd__anyType
*>
response
,
API
::
ITableWorkspace_sptr
&
outputws
);
// Convert a file size to human readable file format.
std
::
string
bytesToString
(
int64_t
&
fileSize
);
...
...
Framework/ICat/src/CatalogLogin.cpp
View file @
a200387f
...
...
@@ -24,7 +24,7 @@ namespace {
std
::
vector
<
std
::
string
>
namesOfFacilitiesWithICAT
()
{
const
auto
&
config
=
Kernel
::
ConfigService
::
Instance
();
const
auto
facilityDoesNotHaveICAT
=
[
&
](
const
std
::
string
&
name
)
{
const
auto
facilityDoesNotHaveICAT
=
[
&
](
std
::
string
name
)
{
return
config
.
getFacility
(
name
).
catalogInfo
().
soapEndPoint
().
empty
();
};
...
...
Framework/ICat/src/ICat4/ICat4Catalog.cpp
View file @
a200387f
...
...
@@ -435,7 +435,7 @@ void ICat4Catalog::getDataSets(const std::string &investigationId,
* @param response :: A vector containing the results of the search query.
* @param outputws :: Shared pointer to output workspace.
*/
void
ICat4Catalog
::
saveDataSets
(
const
std
::
vector
<
xsd__anyType
*>
&
response
,
void
ICat4Catalog
::
saveDataSets
(
std
::
vector
<
xsd__anyType
*>
response
,
API
::
ITableWorkspace_sptr
&
outputws
)
{
if
(
outputws
->
getColumnNames
().
empty
())
{
// Add rows headers to the output workspace.
...
...
Framework/LiveData/src/ISIS/DAE/isisds_command.cpp
View file @
a200387f
...
...
@@ -86,10 +86,10 @@ typedef struct {
/* wait until read len bytes, return <=0 on error */
static
int
recv_all
(
SOCKET
s
,
void
*
buffer
,
int
len
,
int
flags
)
{
auto
*
cbuffer
=
reinterpret_cast
<
char
*>
(
buffer
);
int
n
,
ntot
;
int
ntot
;
ntot
=
0
;
while
(
len
>
0
)
{
n
=
recv
(
s
,
cbuffer
,
len
,
flags
);
int
n
=
recv
(
s
,
cbuffer
,
len
,
flags
);
if
(
n
<=
0
)
{
return
n
;
/* error */
}
...
...
@@ -283,7 +283,7 @@ int isisds_send_command(SOCKET s, const char *command, const void *data,
static
int
isisds_recv_command_helper
(
SOCKET
s
,
char
**
command
,
void
**
data
,
ISISDSDataType
*
type
,
int
dims_array
[],
int
*
ndims
,
int
do_alloc
)
{
int
n
,
len_data
,
size_in
,
i
;
int
n
,
len_data
,
i
;
isisds_command_header_t
comm
;
n
=
recv_all
(
s
,
reinterpret_cast
<
char
*>
(
&
comm
),
sizeof
(
comm
),
0
);
if
(
n
!=
sizeof
(
comm
))
{
...
...
@@ -308,7 +308,7 @@ static int isisds_recv_command_helper(SOCKET s, char **command, void **data,
*
data
=
malloc
(
len_data
+
1
);
(
reinterpret_cast
<
char
*>
(
*
data
))[
len_data
]
=
'\0'
;
}
else
{
size_in
=
1
;
int
size_in
=
1
;
for
(
i
=
0
;
i
<
*
ndims
;
i
++
)
{
size_in
*=
dims_array
[
i
];
}
...
...
buildconfig/CMake/CppCheckSetup.cmake
View file @
a200387f
...
...
@@ -11,8 +11,10 @@ if ( CPPCHECK_EXECUTABLE )
# setup the standard arguments
set
(
CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120
--suppressions-list=
${
CMAKE_BINARY_DIR
}
/CppCheck_Suppressions.txt
--suppress=*:*
${
CMAKE_BINARY_DIR
}
/*
--project=
${
CMAKE_BINARY_DIR
}
/compile_commands.json
# Force cppcheck to check when we use project-wide macros
-DDLLExport=
-DMANTID_ALGORITHMS_DLL=
)
set
(
_cppcheck_args
"
${
CPPCHECK_ARGS
}
"
)
...
...
buildconfig/CMake/CppCheck_Suppressions.txt.in
View file @
a200387f
// suppress specific rule in specific files
// NOTE this needs the full path to the file, so would need this file to be generated by cmake
// as different build servers have different starts to the file path
// Example:
// memsetClassFloat:/Users/builder/Jenkins/workspace/cppcheck-1.72/
// -------- Project Wide ------------------
// Hide warnings about using explicit keyword constructors as we have "too many"
noExplicitConstructor
\ No newline at end of file
// and automated clang-tidy breaks a couple of implicit conversions we use widely
noExplicitConstructor
// Hide warnings about shadowed members for inheritance. Typically "m_log" with Algorithm
duplInheritedMember
// We have some potentially uninitialized member vars but too many to fix at the moment
uninitMemberVar
// Cppcheck struggles with some inheritance chains, some of these might be true though
unusedPrivateFunction
// Nice to have, not need to have at the moment
useInitializationList
// A large number of copying instead of pass by ref were picked up by clang-tidy, but around 200 remain
passedByValue
// Around 100 of these exist where noConstructor is present
noConstructor
// Pre-processor Directives, such as #error, which are upstream anyway
preprocessorErrorDirective
// ---------- cppcheck 1.90 Transition -------
// If-init not supported
syntaxError:${CMAKE_SOURCE_DIR}/Framework/API/src/MatrixWorkspace.cpp
// ---------- Individual suppressions -----------------
// Mantid Plot specific ones we probably won't fix before removal
cstyleCase:*${CMAKE_SOURCE_DIR}/MantidPlot
*:${CMAKE_SOURCE_DIR}/MantidPlot/src/origin/tree.hh
*:${CMAKE_SOURCE_DIR}/MantidPlot/src/nrutil.cpp
// Macro expansion means this is incorrectly flagged on Unix
redundantAssignment:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.cpp
// Ones below was beyond the Cppcheck 1.90 migration scope
pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp
// Ref binding means Cppcheck can't see these are used
unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/MaskBinsIf.cpp
// --------- Missing copy assignment / constructors -------------------
// We don't want more creeping in so just mark these one by one
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/BoxController.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/ExperimentInfo.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/IFunction.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/MDGeometry.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/SingleValueParameter.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/VectorParameter.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ONCat.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ONCatEntity.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceBinData.h
copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceSpectrumData.h
noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h
noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.h
// ----------------- Upstream libs ---------------
// Always ignore bin dir
*:*${CMAKE_BINARY_DIR}/*
// For some reason upstream libs sometimes end up in the check results
*:*/usr/include/*
// All ANN files as they are upstream anyway
*:*${CMAKE_SOURCE_DIR}/Framework/Kernel/src/ANN/*
// Libs we have in-source
*:*${CMAKE_SOURCE_DIR}/Framework/DataObjects/inc/MantidDataObjects/MortonIndex/*
*:*${CMAKE_SOURCE_DIR}/Framework/ICat/src/GSoap/*
*:*${CMAKE_SOURCE_DIR}/ICat/src/ICat3/GSoapGenerated/*
*:*${CMAKE_SOURCE_DIR}/ICat/src/ICat4/GSoapGenerated/*
*:*${CMAKE_SOURCE_DIR}/MantidPlot/src/zlib123/*
qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp
View file @
a200387f
...
...
@@ -13,7 +13,9 @@ IndirectBayesTab::IndirectBayesTab(QWidget *parent)
:
IndirectTab
(
parent
),
m_propTree
(
new
QtTreePropertyBrowser
())
{
m_propTree
->
setFactoryForManager
(
m_dblManager
,
m_dblEdFac
);
// cppcheck-suppress pureVirtualCall
connect
(
m_dblManager
,
SIGNAL
(
valueChanged
(
QtProperty
*
,
double
)),
this
,
// cppcheck-suppress pureVirtualCall
SLOT
(
updateProperties
(
QtProperty
*
,
double
)));
}
...
...
qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp
View file @
a200387f
...
...
@@ -216,11 +216,11 @@ IndirectDataTablePresenter::getSpectra(TableRowIndex start,
while
(
start
<
end
)
{
WorkspaceIndex
minimum
=
getWorkspaceIndex
(
start
);
WorkspaceIndex
maximum
=
minimum
;
start
++
;
++
start
;
while
(
start
<
end
&&
getWorkspaceIndex
(
start
)
==
maximum
+
WorkspaceIndex
{
1
})
{
++
maximum
;
start
++
;
++
start
;
}
spectraPairs
.
emplace_back
(
minimum
,
maximum
);
}
...
...
qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp
View file @
a200387f
...
...
@@ -308,15 +308,12 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) {
}
else
{
WidgetItem
*
par
=
parentItem
->
parent
;
QGridLayout
*
l
=
nullptr
;
int
oldRow
=
-
1
;
if
(
!
par
)
{
l
=
m_mainLayout
;
oldRow
=
m_children
.
indexOf
(
parentItem
);
m_children
.
indexOf
(
parentItem
);
}
else
{
l
=
par
->
layout
;
oldRow
=
par
->
children
.
indexOf
(
parentItem
);
if
(
hasHeader
(
par
))
oldRow
+=
2
;
par
->
children
.
indexOf
(
parentItem
);
}
if
(
parentItem
->
widget
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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