summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamroot.jam1
-rw-r--r--slicer/Jamfile.jam3
-rw-r--r--slicer/db/sqlInsertSerializer.cpp2
-rw-r--r--slicer/db/sqlSelectDeserializer.cpp3
-rw-r--r--slicer/db/sqlTablePatchSerializer.cpp4
-rw-r--r--slicer/db/sqlTablePatchSerializer.h1
-rw-r--r--slicer/json/serializer.cpp30
-rw-r--r--slicer/slicer/modelPartsTypes.cpp4
-rw-r--r--slicer/test/conversions.cpp26
-rw-r--r--slicer/tool/parser.cpp20
-rw-r--r--slicer/xml/serializer.cpp32
11 files changed, 65 insertions, 61 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 3a0762e..f3d42e8 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -21,6 +21,7 @@ project
<toolset>tidy:<checkxx>bugprone-*
<toolset>tidy:<checkxx>clang-*
<toolset>tidy:<checkxx>misc-*
+ <toolset>tidy:<checkxx>hicpp-*
;
build-project slicer ;
diff --git a/slicer/Jamfile.jam b/slicer/Jamfile.jam
index 387a313..d6f47ff 100644
--- a/slicer/Jamfile.jam
+++ b/slicer/Jamfile.jam
@@ -8,7 +8,8 @@ build-project db ;
build-project ice ;
build-project test ;
-lib boost_utf : : <name>boost_unit_test_framework ;
+lib boost_utf : : <name>boost_unit_test_framework : :
+ <toolset>tidy:<xcheckxx>hicpp-* ;
lib adhocutil : : : : <include>/usr/include/adhocutil ;
lib Ice++11 ;
lib pthread ;
diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp
index 9de15eb..e944065 100644
--- a/slicer/db/sqlInsertSerializer.cpp
+++ b/slicer/db/sqlInsertSerializer.cpp
@@ -59,7 +59,7 @@ namespace Slicer {
class IdSave : public Slicer::ValueSource {
public:
- IdSave(DB::Connection * const c) :
+ explicit IdSave(DB::Connection * const c) :
connection(c)
{
}
diff --git a/slicer/db/sqlSelectDeserializer.cpp b/slicer/db/sqlSelectDeserializer.cpp
index f150bde..250de03 100644
--- a/slicer/db/sqlSelectDeserializer.cpp
+++ b/slicer/db/sqlSelectDeserializer.cpp
@@ -6,6 +6,7 @@
namespace Slicer {
SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommand * c, Ice::optional<std::string> tc) :
cmd(c),
+ columnCount(0),
typeIdColName(tc)
{
}
@@ -73,7 +74,7 @@ namespace Slicer {
}
DeserializeRow(mp);
if (cmd->fetch()) {
- while (cmd->fetch()) ;
+ while (cmd->fetch()) {}
throw TooManyRowsReturned();
}
}
diff --git a/slicer/db/sqlTablePatchSerializer.cpp b/slicer/db/sqlTablePatchSerializer.cpp
index a83357f..ec5b59b 100644
--- a/slicer/db/sqlTablePatchSerializer.cpp
+++ b/slicer/db/sqlTablePatchSerializer.cpp
@@ -15,10 +15,6 @@ namespace Slicer {
tablePatch.src = ttname::get(this);
}
- SqlTablePatchSerializer::~SqlTablePatchSerializer()
- {
- }
-
void
SqlTablePatchSerializer::Serialize(Slicer::ModelPartForRootPtr mpr)
{
diff --git a/slicer/db/sqlTablePatchSerializer.h b/slicer/db/sqlTablePatchSerializer.h
index c3b3b2d..425ce95 100644
--- a/slicer/db/sqlTablePatchSerializer.h
+++ b/slicer/db/sqlTablePatchSerializer.h
@@ -8,7 +8,6 @@ namespace Slicer {
class DLL_PUBLIC SqlTablePatchSerializer : public Slicer::Serializer {
public:
SqlTablePatchSerializer(DB::Connection * const, DB::TablePatch &);
- ~SqlTablePatchSerializer();
virtual void Serialize(Slicer::ModelPartForRootPtr) override;
diff --git a/slicer/json/serializer.cpp b/slicer/json/serializer.cpp
index 681c8fb..4a7dcc9 100644
--- a/slicer/json/serializer.cpp
+++ b/slicer/json/serializer.cpp
@@ -25,7 +25,7 @@ namespace Slicer {
class JsonValueSource : public ValueSource {
public:
- JsonValueSource(const json::Value & s) :
+ explicit JsonValueSource(const json::Value & s) :
value(s)
{
}
@@ -76,48 +76,48 @@ namespace Slicer {
class JsonValueTarget : public ValueTarget {
public:
- JsonValueTarget(json::Value & t) :
+ explicit JsonValueTarget(json::Value & t) :
target(t)
{
target = json::Null();
}
- virtual void get(const bool & value) const
+ void get(const bool & value) const override
{
target = value;
}
- virtual void get(const Ice::Byte & value) const
+ void get(const Ice::Byte & value) const override
{
target = boost::numeric_cast<json::Number>(value);
}
- virtual void get(const Ice::Short & value) const
+ void get(const Ice::Short & value) const override
{
target = boost::numeric_cast<json::Number>(value);
}
- virtual void get(const Ice::Int & value) const
+ void get(const Ice::Int & value) const override
{
target = boost::numeric_cast<json::Number>(value);
}
- virtual void get(const Ice::Long & value) const
+ void get(const Ice::Long & value) const override
{
target = boost::numeric_cast<json::Number>(value);
}
- virtual void get(const Ice::Float & value) const
+ void get(const Ice::Float & value) const override
{
target = boost::numeric_cast<json::Number>(value);
}
- virtual void get(const Ice::Double & value) const
+ void get(const Ice::Double & value) const override
{
target = boost::numeric_cast<json::Number>(value);
}
- virtual void get(const std::string & value) const
+ void get(const std::string & value) const override
{
target = value;
}
@@ -128,7 +128,7 @@ namespace Slicer {
class DocumentTreeIterate {
public:
- DocumentTreeIterate(ModelPartPtr & mp) : modelPart(mp)
+ explicit DocumentTreeIterate(ModelPartPtr & mp) : modelPart(mp)
{
}
template<typename SimpleT>
@@ -196,7 +196,9 @@ namespace Slicer {
void
JsonSerializer::ModelTreeIterateSeq(json::Value * n, ModelPartPtr mp)
{
- if (!mp->HasValue()) return;
+ if (!mp->HasValue()) {
+ return;
+ }
auto arr = std::get_if<json::Array>(n);
arr->emplace_back();
ModelTreeIterateRoot(&arr->back(), mp);
@@ -205,7 +207,9 @@ namespace Slicer {
void
JsonSerializer::ModelTreeIterateDictObj(json::Value * n, ModelPartPtr mp)
{
- if (!mp->HasValue()) return;
+ if (!mp->HasValue()) {
+ return;
+ }
auto obj = std::get_if<json::Object>(n);
json::Object::key_type k;
json::Value v;
diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp
index 58e8caf..8a7dc39 100644
--- a/slicer/slicer/modelPartsTypes.cpp
+++ b/slicer/slicer/modelPartsTypes.cpp
@@ -260,13 +260,17 @@ namespace Slicer {
const ModelPartType ModelPartForDictionaryBase::type = mpt_Dictionary;
// Streams
+ // NOLINTNEXTLINE(hicpp-no-array-decay)
ChildRef ModelPartForStreamBase::GetAnonChildRef(const Slicer::HookFilter &) { throw InvalidStreamOperation(__FUNCTION__); }
+ // NOLINTNEXTLINE(hicpp-no-array-decay)
ChildRef ModelPartForStreamBase::GetChildRef(const std::string &, const Slicer::HookFilter &, bool) { throw InvalidStreamOperation(__FUNCTION__); }
ModelPartType ModelPartForStreamBase::GetType() const { return mpt_Sequence; }
bool ModelPartForStreamBase::HasValue() const { return true; }
// Stream Roots
ModelPartForStreamRootBase::ModelPartForStreamRootBase(ModelPartPtr mp) : ModelPartForRootBase(mp) { }
+ // NOLINTNEXTLINE(hicpp-no-array-decay)
void ModelPartForStreamRootBase::Write(Ice::OutputStream&) const { throw InvalidStreamOperation(__FUNCTION__); }
+ // NOLINTNEXTLINE(hicpp-no-array-decay)
void ModelPartForStreamRootBase::Read(Ice::InputStream&) { throw InvalidStreamOperation(__FUNCTION__); }
bool ModelPartForStreamRootBase::HasValue() const { return mp->HasValue(); }
void ModelPartForStreamRootBase::OnEachChild(const ChildHandler & ch) { ch(GetRootName(), mp, NULL); }
diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp
index 7cf4b22..ccb6a0d 100644
--- a/slicer/test/conversions.cpp
+++ b/slicer/test/conversions.cpp
@@ -26,23 +26,22 @@ namespace Slicer {
std::string
isoDateToString(const ::TestModule::IsoDate & in)
{
- struct tm tm;
- memset(&tm, 0, sizeof(struct tm));
+ struct tm tm {};
tm.tm_mday = in.day;
tm.tm_mon = in.month - 1;
tm.tm_year = in.year - 1900;
mktime(&tm);
- char buf[BUFSIZ];
- auto len = strftime(buf, BUFSIZ, "%Y-%m-%d", &tm);
- return std::string(buf, len);
+ std::string buf(BUFSIZ, '\0');
+ auto len = strftime(buf.data(), BUFSIZ, "%Y-%m-%d", &tm);
+ buf.resize(len);
+ return buf;
}
DLL_PUBLIC
::TestModule::IsoDate
stringToIsoDate(const std::string & in)
{
- struct tm tm;
- memset(&tm, 0, sizeof(struct tm));
+ struct tm tm {};
auto end = strptime(in.c_str(), "%Y-%m-%d", &tm);
if (!end || *end) {
// LCOV_EXCL_START
@@ -57,8 +56,7 @@ namespace Slicer {
std::string
dateTimeToString(const ::TestModule::DateTime & in)
{
- struct tm tm;
- memset(&tm, 0, sizeof(struct tm));
+ struct tm tm {};
tm.tm_sec = in.second;
tm.tm_min = in.minute;
tm.tm_hour = in.hour;
@@ -67,17 +65,17 @@ namespace Slicer {
tm.tm_year = in.year - 1900;
tm.tm_isdst = -1;
mktime(&tm);
- char buf[BUFSIZ];
- auto len = strftime(buf, BUFSIZ, "%Y-%b-%d %H:%M:%S", &tm);
- return std::string(buf, len);
+ std::string buf(BUFSIZ, '\0');
+ auto len = strftime(buf.data(), BUFSIZ, "%Y-%b-%d %H:%M:%S", &tm);
+ buf.resize(len);
+ return buf;
}
DLL_PUBLIC
::TestModule::DateTime
stringToDateTime(const std::string & in)
{
- struct tm tm;
- memset(&tm, 0, sizeof(struct tm));
+ struct tm tm {};
auto end = strptime(in.c_str(), "%Y-%b-%d %H:%M:%S", &tm);
if (!end || *end) {
// LCOV_EXCL_START
diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp
index 0aa0040..649ba59 100644
--- a/slicer/tool/parser.cpp
+++ b/slicer/tool/parser.cpp
@@ -25,7 +25,7 @@ namespace Slicer {
void
Slicer::defineConversions(Slice::DataMemberPtr dm) const
{
- if (!cpp) return;
+ if (!cpp) { return; }
auto type = dm->type();
auto c = Slice::ContainedPtr::dynamicCast(dm->container());
@@ -93,7 +93,7 @@ namespace Slicer {
Slicer::visitUnitStart(const Slice::UnitPtr & u)
{
fs::path topLevelFile(u->topLevelFile());
- if (!cpp) return true;
+ if (!cpp) { return true; }
fprintbf(cpp, "// Begin Slicer code\n\n");
fprintbf(cpp, "#include <%s>\n\n", fs::path(topLevelFile.filename()).replace_extension(".h").string());
@@ -112,7 +112,7 @@ namespace Slicer {
void
Slicer::visitUnitEnd(const Slice::UnitPtr&)
{
- if (!cpp) return;
+ if (!cpp) { return; }
fprintbf(cpp, "}\n\n");
fprintbf(cpp, "// End Slicer code\n\n");
@@ -121,7 +121,7 @@ namespace Slicer {
bool
Slicer::visitModuleStart(const Slice::ModulePtr & m)
{
- if (!cpp) return true;
+ if (!cpp) { return true; }
fprintbf(cpp, "// Begin module %s\n\n", m->name());
for (const auto & c : m->structs()) {
@@ -161,7 +161,7 @@ namespace Slicer {
components += 1;
- if (!cpp) return true;
+ if (!cpp) { return true; }
auto decl = c->declaration();
fprintbf(cpp, "// Class %s\n", c->name());
@@ -220,7 +220,7 @@ namespace Slicer {
components += 1;
- if (!cpp) return true;
+ if (!cpp) { return true; }
fprintbf(cpp, "// Struct %s\n", c->name());
visitComplexDataMembers(c, c->dataMembers());
@@ -241,7 +241,7 @@ namespace Slicer {
void
Slicer::visitComplexDataMembers(Slice::ConstructedPtr it, const Slice::DataMemberList & dataMembers) const
{
- if (!cpp) return;
+ if (!cpp) { return; }
fprintbf(cpp, "typedef ModelPartForComplex< %s > C%d;\n",
it->scoped(), components);
@@ -291,7 +291,7 @@ namespace Slicer {
components += 1;
- if (!cpp) return;
+ if (!cpp) { return; }
fprintbf(cpp, "// Enumeration %s\n", e->name());
fprintbf(cpp, "template<> DLL_PUBLIC\nconst Metadata ModelPartForEnum< %s >::metadata ",
@@ -323,7 +323,7 @@ namespace Slicer {
components += 1;
- if (!cpp) return;
+ if (!cpp) { return; }
fprintbf(cpp, "// Sequence %s\n", s->name());
fprintbf(cpp, "template<> DLL_PUBLIC\n");
@@ -364,7 +364,7 @@ namespace Slicer {
components += 1;
- if (!cpp) return;
+ if (!cpp) { return; }
fprintbf(cpp, "// Dictionary %s\n", d->name());
auto iname = metaDataValue("slicer:item:", d->getMetaData());
diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp
index b00c5e3..842a2a3 100644
--- a/slicer/xml/serializer.cpp
+++ b/slicer/xml/serializer.cpp
@@ -32,7 +32,7 @@ namespace Slicer {
class XmlValueSource : public ValueSource {
public:
- XmlValueSource(const Glib::ustring & s) :
+ explicit XmlValueSource(const Glib::ustring & s) :
value(s)
{
}
@@ -85,11 +85,11 @@ namespace Slicer {
class XmlContentValueSource : public XmlValueSource {
public:
- XmlContentValueSource() :
+ explicit XmlContentValueSource() :
XmlValueSource(Glib::ustring())
{
}
- XmlContentValueSource(const xmlpp::ContentNode * c) :
+ explicit XmlContentValueSource(const xmlpp::ContentNode * c) :
XmlValueSource(c->get_content())
{
}
@@ -97,7 +97,7 @@ namespace Slicer {
class XmlAttributeValueSource : public XmlValueSource {
public:
- XmlAttributeValueSource(const xmlpp::Attribute * a) :
+ explicit XmlAttributeValueSource(const xmlpp::Attribute * a) :
XmlValueSource(a->get_value())
{
}
@@ -105,12 +105,12 @@ namespace Slicer {
class XmlValueTarget : public ValueTarget {
public:
- XmlValueTarget(std::function<void(const Glib::ustring &)> a) :
+ explicit XmlValueTarget(std::function<void(const Glib::ustring &)> a) :
apply(a)
{
}
- virtual void get(const bool & value) const
+ void get(const bool & value) const override
{
if (value) {
apply(TrueText);
@@ -120,37 +120,37 @@ namespace Slicer {
}
}
- virtual void get(const Ice::Byte & value) const
+ void get(const Ice::Byte & value) const override
{
apply(boost::lexical_cast<Glib::ustring>((int)value));
}
- virtual void get(const Ice::Short & value) const
+ void get(const Ice::Short & value) const override
{
apply(boost::lexical_cast<Glib::ustring>(value));
}
- virtual void get(const Ice::Int & value) const
+ void get(const Ice::Int & value) const override
{
apply(boost::lexical_cast<Glib::ustring>(value));
}
- virtual void get(const Ice::Long & value) const
+ void get(const Ice::Long & value) const override
{
apply(boost::lexical_cast<Glib::ustring>(value));
}
- virtual void get(const Ice::Float & value) const
+ void get(const Ice::Float & value) const override
{
apply(boost::lexical_cast<Glib::ustring>(value));
}
- virtual void get(const Ice::Double & value) const
+ void get(const Ice::Double & value) const override
{
apply(boost::lexical_cast<Glib::ustring>(value));
}
- virtual void get(const std::string & value) const
+ void get(const std::string & value) const override
{
apply(value);
}
@@ -162,7 +162,7 @@ namespace Slicer {
class XmlAttributeValueTarget : public XmlValueTarget {
public:
- XmlAttributeValueTarget(xmlpp::Element * p, const std::string & n) :
+ explicit XmlAttributeValueTarget(xmlpp::Element * p, const std::string & n) :
XmlValueTarget(std::bind(&xmlpp::Element::set_attribute, p, Glib::ustring(n), _1, Glib::ustring()))
{
}
@@ -170,12 +170,12 @@ namespace Slicer {
class XmlContentValueTarget : public XmlValueTarget {
public:
- XmlContentValueTarget(xmlpp::Element * p) :
+ explicit XmlContentValueTarget(xmlpp::Element * p) :
XmlValueTarget(std::bind(&xmlpp::Element::set_first_child_text, p, _1))
{
}
- XmlContentValueTarget(const CurrentElementCreator & cec) :
+ explicit XmlContentValueTarget(const CurrentElementCreator & cec) :
XmlValueTarget(std::bind(&xmlpp::Element::set_first_child_text, std::bind(&CurrentElementCreator::deref, &cec), _1))
{
}