From 4a95f0824ac27b36ba1ce59af1506f0286a16b35 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Sun, 20 Nov 2022 01:37:13 +0000 Subject: [PATCH] doc: Update coding-style.rst with clang-tidy readability-static-accessed-through-instance check --- doc/contributing/source/coding-style.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/contributing/source/coding-style.rst b/doc/contributing/source/coding-style.rst index 5e89bbf05..9663b6bdc 100644 --- a/doc/contributing/source/coding-style.rst +++ b/doc/contributing/source/coding-style.rst @@ -1318,5 +1318,17 @@ of rules that should be observed while developing code. - Avoid declaring trivial destructors, to optimize performance. +- Avoid accessing class static functions and members through objects. + Instead, prefer to access them through the class. + + .. sourcecode:: cpp + + // OK + MyClass::StaticFunction(); + + // Avoid + MyClass myClass; + MyClass.StaticFunction(); + - Prefer to use ``static_assert()`` over ``NS_ASSERT()`` when conditions can be evaluated at compile-time.