From 87fec23f4baae5533623a94caace0f13997ab979 Mon Sep 17 00:00:00 2001 From: MrSimbax Date: Tue, 7 Apr 2020 18:59:46 +0200 Subject: [PATCH 1/4] Fix 'class naming' linter issues --- src/CBot/CBotFileUtils.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/CBot/CBotFileUtils.cpp b/src/CBot/CBotFileUtils.cpp index b2a19cb1..e4245e0d 100644 --- a/src/CBot/CBotFileUtils.cpp +++ b/src/CBot/CBotFileUtils.cpp @@ -183,7 +183,12 @@ bool ReadLong(std::istream &istr, long &l) bool WriteFloat(std::ostream &ostr, float f) { - union {float fValue; unsigned int iValue;} u; + union TypeConverter { + float fValue; + unsigned int iValue; + }; + + TypeConverter u; u.fValue = 0.0f; u.iValue = 0; @@ -193,7 +198,12 @@ bool WriteFloat(std::ostream &ostr, float f) bool ReadFloat(std::istream &istr, float &f) { - union {float fValue; unsigned int iValue;} u; + union TypeConverter { + float fValue; + unsigned int iValue; + }; + + TypeConverter u; u.fValue = 0.0f; u.iValue = 0; @@ -204,7 +214,12 @@ bool ReadFloat(std::istream &istr, float &f) bool WriteDouble(std::ostream &ostr, double d) { - union {double dValue; unsigned long iValue;} u; + union TypeConverter { + double dValue; + unsigned long iValue; + }; + + TypeConverter u; u.dValue = 0.0; u.iValue = 0; @@ -214,7 +229,12 @@ bool WriteDouble(std::ostream &ostr, double d) bool ReadDouble(std::istream &istr, double &d) { - union {double dValue; unsigned long iValue;} u; + union TypeConverter { + double dValue; + unsigned long iValue; + }; + + TypeConverter u; u.dValue = 0.0; u.iValue = 0; From f09768fb2d5c64c61a422add6808f5994a856185 Mon Sep 17 00:00:00 2001 From: MrSimbax Date: Tue, 7 Apr 2020 19:13:30 +0200 Subject: [PATCH 2/4] Fix 'undefined function' linter issue --- src/CBot/CBotInstr/CBotExprLitNum.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CBot/CBotInstr/CBotExprLitNum.h b/src/CBot/CBotInstr/CBotExprLitNum.h index 8d7edcc1..f3fcaf89 100644 --- a/src/CBot/CBotInstr/CBotExprLitNum.h +++ b/src/CBot/CBotInstr/CBotExprLitNum.h @@ -38,7 +38,7 @@ class CBotExprLitNum : public CBotInstr { public: - CBotExprLitNum(T val); + CBotExprLitNum(T val) = delete; ~CBotExprLitNum(); /*! From ad33e0e6245247297ebf99adee14af1e9ee1f45c Mon Sep 17 00:00:00 2001 From: MrSimbax Date: Tue, 7 Apr 2020 20:05:32 +0200 Subject: [PATCH 3/4] Fix 'code block placement' linter issues --- src/CBot/CBotFileUtils.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/CBot/CBotFileUtils.cpp b/src/CBot/CBotFileUtils.cpp index e4245e0d..1abb23e5 100644 --- a/src/CBot/CBotFileUtils.cpp +++ b/src/CBot/CBotFileUtils.cpp @@ -183,7 +183,8 @@ bool ReadLong(std::istream &istr, long &l) bool WriteFloat(std::ostream &ostr, float f) { - union TypeConverter { + union TypeConverter + { float fValue; unsigned int iValue; }; @@ -198,7 +199,8 @@ bool WriteFloat(std::ostream &ostr, float f) bool ReadFloat(std::istream &istr, float &f) { - union TypeConverter { + union TypeConverter + { float fValue; unsigned int iValue; }; @@ -214,7 +216,8 @@ bool ReadFloat(std::istream &istr, float &f) bool WriteDouble(std::ostream &ostr, double d) { - union TypeConverter { + union TypeConverter + { double dValue; unsigned long iValue; }; @@ -229,7 +232,8 @@ bool WriteDouble(std::ostream &ostr, double d) bool ReadDouble(std::istream &istr, double &d) { - union TypeConverter { + union TypeConverter + { double dValue; unsigned long iValue; }; From 17ba464d336cc3ebc068102130f930b013be87ac Mon Sep 17 00:00:00 2001 From: MrSimbax Date: Tue, 7 Apr 2020 20:16:23 +0200 Subject: [PATCH 4/4] Fix so called ''compilation errors'' in linter --- src/CBot/CBotInstr/CBotExprLitNum.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CBot/CBotInstr/CBotExprLitNum.h b/src/CBot/CBotInstr/CBotExprLitNum.h index f3fcaf89..954fdc84 100644 --- a/src/CBot/CBotInstr/CBotExprLitNum.h +++ b/src/CBot/CBotInstr/CBotExprLitNum.h @@ -38,7 +38,9 @@ class CBotExprLitNum : public CBotInstr { public: - CBotExprLitNum(T val) = delete; + // To keep linter happy, instead of = delete (see https://stackoverflow.com/a/37593094) + CBotExprLitNum(T val) { static_assert(sizeof(T) == 0, "Only specializations of CBotExprLitNum can be used"); }; + ~CBotExprLitNum(); /*!