aboutsummaryrefslogtreecommitdiff
path: root/contributing.md
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-15 17:39:04 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-15 17:39:04 +0100
commit424611c6016e4a189e3a887fabe8e45b637e80f4 (patch)
tree950fc7aaccc090510d20010376b724c820e38a0e /contributing.md
parent8ff89409c7ee5399d98fe4a8e2a67961fab8add1 (diff)
merge #36
Diffstat (limited to 'contributing.md')
-rw-r--r--contributing.md52
1 files changed, 42 insertions, 10 deletions
diff --git a/contributing.md b/contributing.md
index 64afb44..5b0c79d 100644
--- a/contributing.md
+++ b/contributing.md
@@ -679,30 +679,57 @@ that you can click on to open them.
```
</td></tr></table></details>
- <details><summary>
- Throw exceptions using standard C++ exceptions (such as <code>std::runtime_error</code>)
+ Utilize standard exceptions where appropriate (those found in <code>&lt;stdexcept&gt;</code>)
</summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
- if (error) {
- throw std::runtime_error("An error occurred");
+ #include <stdexcept>
+
+ // ...
+
+ if (foo == nullptr) {
+ throw std::runtime_error("What is wrong");
}
```
</td><td>
```cpp
- if (error) {
- throw "An error occurred";
+ if (foo == nullptr) {
+ std::cout << "What is wrong" << std::endl;
+ exit(1);
}
```
</td></tr></table></details>
- <details><summary>
- Constructors of classes derived from <code>Component</code> should be protected and <code>ComponentManager</code> should be declared as a friend class.
+ Mention the name of the class when throwing an exception
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ Foo::bar() {
+ if (...)
+ throw std::runtime_error("Foo: big error!");
+ }
+ ```
+ </td><td>
+
+ ```cpp
+ Foo::bar() {
+ if (...)
+ throw std::runtime_error("big error!");
+ }
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Constructors of classes derived from <code>Component</code> should be
+ protected and <code>ComponentManager</code> should be declared as a friend
+ class.
</summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
class MyComponent : public Component {
protected:
- MyComponent() = default;
+ MyComponent(...);
+ //! Only ComponentManager is allowed to create components
friend class ComponentManager;
};
```
@@ -711,16 +738,20 @@ that you can click on to open them.
```cpp
class MyComponent : public Component {
public:
- MyComponent() = default;
+ MyComponent(...);
};
```
</td></tr></table></details>
- <details><summary>
- Use of format specifiers (like <code>%s</code> and <code>%n</code>) are not allowed (use <code>{}</code> with <code>std::format</code> instead)
+ C++ <code>std::format</code> should be used instead of C-style format specifiers
</summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
std::string message = std::format("Hello, {}", name);
+
+ dbg_logf("Here too: {}", 3);
+
+ throw std::runtime_error(std::format("Or here: {}", 5));
```
</td><td>
@@ -730,7 +761,8 @@ that you can click on to open them.
```
</td></tr></table></details>
- <details><summary>
- Argument names should be added in <code>.h</code> files (not only in <code>.cpp</code> and <code>.hpp</code> files)
+ Argument names should be added in <code>.h</code> files (not only in
+ <code>.cpp</code> and <code>.hpp</code> files)
</summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
Foo.h: