From b37f79b43a50ed1eff34771e15fa6cdc1dae0936 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 15 Aug 2022 22:28:22 +0100 Subject: [PATCH 1/2] Adds .clang-tidy --- .clang-tidy | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..9e7ce8e04 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,108 @@ +--- +Checks: |- + *, + -altera-id-dependent-backward-branch, + -altera-struct-pack-align, + -altera-unroll-loops, + -bugprone-branch-clone, + -bugprone-copy-constructor-init, + -bugprone-easily-swappable-parameters, + -bugprone-integer-division, + -bugprone-macro-parentheses, + -bugprone-narrowing-conversions, + -bugprone-redundant-branch-condition, + -bugprone-reserved-identifier, + -bugprone-string-constructor, + -bugprone-unhandled-self-assignment, + -cert-dcl37-c, + -cert-dcl51-cpp, + -cert-msc30-c, + -cert-msc50-cpp, + -cert-oop54-cpp, + -cert-oop54-cpp, + -clang-diagnostic-error, + -concurrency-mt-unsafe, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-c-copy-assignment-signature, + -cppcoreguidelines-init-variables, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-narrowing-conversions, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-prefer-member-initializer, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-pro-type-member-init, + -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-pro-type-vararg, + -cppcoreguidelines-special-member-functions, + -fuchsia-default-arguments-calls, + -fuchsia-default-arguments-declarations, + -fuchsia-overloaded-operator, + -fuchsia-trailing-return, + -google-explicit-constructor, + -google-global-names-in-headers, + -google-readability-braces-around-statements, + -google-readability-casting, + -google-runtime-int, + -hicpp-avoid-c-arrays, + -hicpp-braces-around-statements, + -hicpp-braces-around-statements, + -hicpp-exception-baseclass, + -hicpp-explicit-conversions, + -hicpp-member-init, + -hicpp-multiway-paths-covered, + -hicpp-named-parameter, + -hicpp-no-array-decay, + -hicpp-signed-bitwise,, + -hicpp-special-member-functions, + -hicpp-uppercase-literal-suffix, + -hicpp-use-auto, + -hicpp-use-equals-default, + -hicpp-use-nullptr, + -hicpp-vararg, + -llvm-else-after-return, + -llvm-header-guard,, + -llvmlibc-callee-namespace, + -llvmlibc-implementation-in-namespace,, + -llvmlibc-restrict-system-libc-headers, + -misc-definitions-in-headers, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + -misc-non-private-member-variables-in-classes, + -misc-unconventional-assign-operator, + -misc-unused-parameters,, + -modernize-avoid-c-arrays, + -modernize-raw-string-literal, + -modernize-redundant-void-arg, + -modernize-use-auto, + -modernize-use-default-member-init, + -modernize-use-equals-default, + -modernize-use-nullptr, + -modernize-use-nullptr, + -modernize-use-trailing-return-type, + -modernize-use-using, + -performance-unnecessary-value-param, + -readability-avoid-const-params-in-decls, + -readability-braces-around-statements, + -readability-braces-around-statements, + -readability-const-return-type, + -readability-container-size-empty, + -readability-convert-member-functions-to-static, + -readability-delete-null-pointer, + -readability-else-after-return, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-isolate-declaration, + -readability-magic-numbers, + -readability-make-member-function-const, + -readability-named-parameter, + -readability-redundant-access-specifiers, + -readability-redundant-declaration, + -readability-redundant-string-init, + -readability-simplify-boolean-expr, + -readability-uppercase-literal-suffix, +FormatStyle: file +HeaderFilterRegex: '.*' +WarningsAsErrors: '' From a8ddd3b39b3fda76b5e5dbccfa4aae7d647d6b18 Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 15 Aug 2022 22:40:48 +0100 Subject: [PATCH 2/2] Adds clang-format pre-commit hook Reformats code --- .pre-commit-config.yaml | 5 +++++ Instances.h | 13 +++++-------- Task/tests/TaskGetter.test.cpp | 2 +- Task/tests/TaskSetter.test.cpp | 3 ++- Trade/tests/TradeSignal.test.cpp | 3 ++- Trade/tests/TradeSignalManager.test.cpp | 3 ++- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b73b0ad64..9fdd623ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,11 @@ --- repos: + # - repo: https://github.com/pre-commit/mirrors-clang-format + # rev: v14.0.6 + # hooks: + # - id: clang-format + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 hooks: diff --git a/Instances.h b/Instances.h index 9f1812fa5..e6937f1fa 100644 --- a/Instances.h +++ b/Instances.h @@ -37,21 +37,18 @@ #include "Dict.mqh" #include "Util.h" -template +template class Instances { -public: - + public: static T* instances[]; - Instances(T* _self) { - Util::ArrayPush(instances, _self); - } + Instances(T* _self) { Util::ArrayPush(instances, _self); } ~Instances() { - //Util::ArrayRemove(instances, &this); + // Util::ArrayRemove(instances, &this); } }; -template +template T* Instances::instances[]; #endif // INSTANCES_MQH diff --git a/Task/tests/TaskGetter.test.cpp b/Task/tests/TaskGetter.test.cpp index e34c6dc56..481bdf3c1 100644 --- a/Task/tests/TaskGetter.test.cpp +++ b/Task/tests/TaskGetter.test.cpp @@ -32,4 +32,4 @@ #include "../../Std.h" #include "../../String.extern.h" -int main(int argc, char **argv) {} +int main(int argc, char **argv) { return 0; } diff --git a/Task/tests/TaskSetter.test.cpp b/Task/tests/TaskSetter.test.cpp index c422842f2..7e9d1cda0 100644 --- a/Task/tests/TaskSetter.test.cpp +++ b/Task/tests/TaskSetter.test.cpp @@ -25,10 +25,11 @@ */ // Includes. +#include "../TaskSetter.h" + #include "../../Common.define.h" #include "../../Common.extern.h" #include "../../Std.h" #include "../../String.extern.h" -#include "../TaskSetter.h" int main(int argc, char **argv) {} diff --git a/Trade/tests/TradeSignal.test.cpp b/Trade/tests/TradeSignal.test.cpp index 696ec4422..fc7f0364f 100644 --- a/Trade/tests/TradeSignal.test.cpp +++ b/Trade/tests/TradeSignal.test.cpp @@ -25,10 +25,11 @@ */ // Includes. +#include "../TradeSignal.h" + #include "../../Common.define.h" #include "../../Common.extern.h" #include "../../Std.h" #include "../../String.extern.h" -#include "../TradeSignal.h" int main(int argc, char **argv) {} diff --git a/Trade/tests/TradeSignalManager.test.cpp b/Trade/tests/TradeSignalManager.test.cpp index 7ca976d9f..92f0cb16e 100644 --- a/Trade/tests/TradeSignalManager.test.cpp +++ b/Trade/tests/TradeSignalManager.test.cpp @@ -25,10 +25,11 @@ */ // Includes. +#include "../TradeSignalManager.h" + #include "../../Common.define.h" #include "../../Common.extern.h" #include "../../Std.h" #include "../../String.extern.h" -#include "../TradeSignalManager.h" int main(int argc, char **argv) {}