Contributing - Pressio/pressio GitHub Wiki

Rules

Testing

Style

Classes

  • class name should be CamelCase: MyStruct, MyPodClass
  • Method names should be lower camel case
  • member names should use trailing _: e.g. int my_data_ (prefer snake case, or lower camel case)
  • public nested type aliases should have _type suffix: Example:
 struct Foo
 {
   using value_type = double;
   void setAlpha(){}
   private:
    int alpha_ = {};
 };

Templates

  • template parameters should be camel case
template<class ValueType>
class MyClass{}
  template<class ValueType>
  void my_function(ValueType a)
  • locally scoped templates can use _t suffix
void my_function(){
  using scalar_t = double;
}

Other

  • free functions: use snake case: e.g. pressio::create_stepper()
  • Metafunctions are functions, so should be named: is_something, or has_something, have_matching_execution_space.
  • macros should be all capital
  • enums:
    enum class FooList {
      Ok,
      Somethingbad
    };
  • Always prefix names with full namespace. For instance use ::pressio::ode::implicitStepper<...> instead of ode::implicitStepper<...>. This is a golden rule I would say to avoid issues later on and make also search/replace much easier. It is a bit more verbose, but it improves readability and safety all over. There are places where it is ok to take a shortcut, for example inside short implementation methods. But in general, don't take shortcuts 😃

References: #137, #301

Creating PRs

Reporting bugs

Pushing commits

One can format his last commit according to project rules specified in .clang-format before pushing it:

git diff -U0 --no-color HEAD^ | clang-format-diff.py -i -p1

Note: make sure you have clang-format installed and clang-format-diff.py in system path (e.g. /usr/share/clang/clang-format-10)

⚠️ **GitHub.com Fallback** ⚠️