Skip to content

Commit 313e38f

Browse files
Merge pull request #38993 from mantidproject/38989-follow-up
Remove two CppCheck suppressions on ExperimentInfo
2 parents d8cc355 + 8c42ab2 commit 313e38f

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

Framework/API/inc/MantidAPI/FileLoaderRegistry.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,22 @@ class MANTID_API_DLL FileLoaderRegistryImpl {
9292
case LegacyNexus:
9393
if (!std::is_base_of<IFileLoader<Kernel::LegacyNexusDescriptor>, T>::value) {
9494
throw std::runtime_error(std::string("FileLoaderRegistryImpl::subscribe - Class '") + typeid(T).name() +
95-
"' registered as Nexus loader but it does not "
96-
"inherit from "
97-
"API::IFileLoader<Kernel::NexusDescriptor>");
95+
"' registered as LegacyNexus loader but it does not inherit from "
96+
"API::IFileLoader<Kernel::LegacyNexusDescriptor>");
9897
}
9998
break;
10099
case Nexus:
101100
if (!std::is_base_of<IFileLoader<Kernel::NexusDescriptor>, T>::value) {
102-
throw std::runtime_error(std::string("FileLoaderRegistryImpl::subscribe - Class '") + typeid(T).name() +
103-
"' registered as NexusHDF5 loader but it does not "
104-
"inherit from "
105-
"API::IFileLoader<Kernel::NexusDescriptor>");
101+
throw std::runtime_error(
102+
std::string("FileLoaderRegistryImpl::subscribe - Class '") + typeid(T).name() +
103+
"' registered as Nexus loader but it does not inherit from API::IFileLoader<Kernel::NexusDescriptor>");
106104
}
107105
break;
108106
case Generic:
109107
if (!std::is_base_of<IFileLoader<Kernel::FileDescriptor>, T>::value) {
110-
throw std::runtime_error(std::string("FileLoaderRegistryImpl::subscribe - Class '") + typeid(T).name() +
111-
"' registered as Generic loader but it does "
112-
"not inherit from "
113-
"API::IFileLoader<Kernel::FileDescriptor>");
108+
throw std::runtime_error(
109+
std::string("FileLoaderRegistryImpl::subscribe - Class '") + typeid(T).name() +
110+
"' registered as Generic loader but it does not inherit from API::IFileLoader<Kernel::FileDescriptor>");
114111
}
115112
break;
116113
default:

Framework/API/src/ExperimentInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ void ExperimentInfo::readParameterMap(const std::string &parameterStr) {
12241224
else { // defined, the paramValue has one too many entries, -1 to remove also the semicolon
12251225
paramVisibility =
12261226
paramVisibility.substr(paramVisibility.find(visibilityKey) + visibilityKey.size(), paramVisibility.size());
1227-
paramValue = paramValue.substr(0, paramValue.find(visibilityKey) - 1);
1227+
paramValue.erase(paramValue.find(visibilityKey) - 1, paramValue.size());
12281228
}
12291229
const auto paramDescr = std::string("");
12301230
if (paramName == "masked") {
@@ -1350,7 +1350,7 @@ IPropertyManager::getValue<Mantid::API::ExperimentInfo_sptr>(const std::string &
13501350
template <>
13511351
MANTID_API_DLL Mantid::API::ExperimentInfo_const_sptr
13521352
IPropertyManager::getValue<Mantid::API::ExperimentInfo_const_sptr>(const std::string &name) const {
1353-
auto *prop = dynamic_cast<PropertyWithValue<Mantid::API::ExperimentInfo_sptr> *>(getPointerToProperty(name));
1353+
auto const *prop = dynamic_cast<PropertyWithValue<Mantid::API::ExperimentInfo_sptr> *>(getPointerToProperty(name));
13541354
if (prop) {
13551355
return prop->operator()();
13561356
} else {

Framework/API/test/ExperimentInfoTest.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,27 @@ class ExperimentInfoTest : public CxxTest::TestSuite {
680680
auto &pmap = expInfo.instrumentParameters();
681681
auto det = expInfo.getInstrument()->getDetector(1);
682682
auto value = pmap.getString(det.get(), "par");
683+
TS_ASSERT_EQUALS(pmap.get(det.get(), "par")->visible(), true);
684+
TS_ASSERT_EQUALS(value, "11;22;33;44");
685+
}
686+
687+
void test_readParameterMap_visibility_key() {
688+
auto inst = ComponentCreationHelper::createMinimalInstrument(V3D{-2, 0, 0} /*source*/, V3D{10, 0, 0} /*sample*/,
689+
V3D{12, 0, 0} /*detector*/);
690+
ExperimentInfo expInfo;
691+
expInfo.setInstrument(inst);
692+
expInfo.readParameterMap("detID:1;string;par;11;22;33;44;visible:false");
693+
auto &pmap = expInfo.instrumentParameters();
694+
auto det = expInfo.getInstrument()->getDetector(1);
695+
auto value = pmap.getString(det.get(), "par");
696+
TS_ASSERT_EQUALS(pmap.get(det.get(), "par")->visible(), false);
697+
TS_ASSERT_EQUALS(value, "11;22;33;44");
698+
699+
expInfo.readParameterMap("detID:1;string;par;11;22;33;44;visible:true");
700+
auto &pmap2 = expInfo.instrumentParameters();
701+
det = expInfo.getInstrument()->getDetector(1);
702+
value = pmap2.getString(det.get(), "par");
703+
TS_ASSERT_EQUALS(pmap2.get(det.get(), "par")->visible(), true);
683704
TS_ASSERT_EQUALS(value, "11;22;33;44");
684705
}
685706

buildconfig/CMake/CppCheck_Suppressions.txt.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/CompositeFunction.cpp
123123
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/API/src/ExperimentInfo.cpp:140
124124
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/ExperimentInfo.cpp:579
125125
nullPointerRedundantCheck:${CMAKE_SOURCE_DIR}/Framework/API/src/ExperimentInfo.cpp:889
126-
uselessCallsSubstr:${CMAKE_SOURCE_DIR}/Framework/API/src/ExperimentInfo.cpp:1227
127-
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/ExperimentInfo.cpp:1353
128126
stlIfStrFind:${CMAKE_SOURCE_DIR}/Framework/API/src/FileFinder.cpp:148
129127
stlIfStrFind:${CMAKE_SOURCE_DIR}/Framework/API/src/FileFinder.cpp:160
130128
knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/API/src/FunctionFactory.cpp:267

0 commit comments

Comments
 (0)