Contributing to a ThrowTheSwitch.org Project

πŸ‘πŸŽ‰ First off, thanks for taking the time to contribute! πŸŽ‰πŸ‘

The following is a set of guidelines for contributing to any of ThrowTheSwitch.org's projects or the website itself, hosted at throwtheswitch.org or ThrowTheSwitch's organization on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

Table Of Contents

πŸ“– Code of Conduct

Please review our Code of Conduct. It is in effect at all times. We expect it to be honored by everyone who contributes to this project. Be a Good Human!

πŸ’‘ Asking Questions

Note: Please don't file an issue to ask a question. We have an official forum where the community chimes in with helpful advice if you have questions.

What should I know before I get started?

ThrowTheSwitch hosts a number of open source projects β€” Ceedling is the entrypoint for many users. Ceedling is actually built upon the foundation of Unity Test (a flexible C testing framework) and CMock (a mocking tool for C) and it coordinates many other open source and proprietary tools. Please do your best to focus your ideas and questions at the correct tool. We'll do our best to help you find your way, but there will be times where we'll have to direct your attention to another subtool.

Here are some of the main projects hosted by ThrowTheSwitch.org:

  • Ceedling -- Build coordinator for testing C applications, especially embedded C (and optionally your release build too!)
  • CMock -- Mocking tool for automatically creating stubs, mocks, and skeletons in C
  • Unity -- Unit Testing framework for C, specially embedded C.
  • MadScienceLabDocker -- Docker image giving you a shortcut to getting running with Ceedling
  • CException -- An exception framework for using simple exceptions in C.

There are many more, but this list should be a good starting point.

πŸ“₯ Opening an Issue

Before creating an issue, check if you are using the latest version of the project. If you are not up-to-date, see if updating fixes your issue first.

πŸͺ² Bug Reports and Other Issues

A great way to contribute to the project is to send a detailed issue when you encounter a problem. We always appreciate a well-written, thorough bug report.

In short, since you are most likely a developer, provide a ticket that you would like to receive.

  • Review the documentation before opening a new issue.

  • Do not open a duplicate issue! Search through existing issues to see if your issue has previously been reported. If your issue exists, comment with any additional information you have. You may simply note "I have this problem too", which helps prioritize the most common problems and requests.

  • Prefer using reactions, not comments, if you simply want to "+1" an existing issue.

  • Fully complete the provided issue template. The bug report template requests all the information we need to quickly and efficiently address your issue. Be clear, concise, and descriptive. Provide as much information as you can, including steps to reproduce, stack traces, compiler errors, library versions, OS versions, and screenshots (if applicable).

  • Use GitHub-flavored Markdown. Especially put code blocks and console outputs in backticks (```). This improves readability.

🌱 Feature Requests

Feature requests are welcome! We don't have all the answers and we truly love the collaborative experience of building software together! That being said, we cannot guarantee your request will be accepted. We want to avoid feature creep. Your idea may be great, but also out-of-scope for the project. If accepted, we'll do our best to tackle it in a timely manner, but cannot make any commitments regarding the timeline for implementation and release. However, you are welcome to submit a pull request to help!

  • Please don't open a duplicate feature request. Search for existing feature requests first. If you find your feature (or one very similar) previously requested, comment on that issue.

  • Fully complete the provided issue template. The feature request template asks for all necessary information for us to begin a productive conversation.

  • Be precise about the proposed outcome of the feature and how it relates to existing features. Include implementation details if possible.

πŸ” Triaging Issues

You can triage issues which may include reproducing bug reports or asking for additional information, such as version numbers or reproduction instructions. Any help you can provide to quickly resolve an issue is very much appreciated!

πŸ” Submitting Pull Requests

We love pull requests! Before forking the repo and creating a pull request for non-trivial changes, it is usually best to first open an issue to discuss the changes, or discuss your intended approach for solving the problem in the comments for an existing issue.

For most contributions, after your first pull request is accepted and merged, you will be invited to the project and given push access. πŸŽ‰

Note: All contributions will be licensed under the project's license.

  • Smaller is better. Submit one pull request per bug fix or feature. A pull request should contain isolated changes pertaining to a single bug fix or feature implementation. Do not refactor or reformat code that is unrelated to your change. It is better to submit many small pull requests rather than a single large one. Enormous pull requests will take enormous amounts of time to review, or may be rejected altogether.

  • Coordinate bigger changes. For large and non-trivial changes, open an issue to discuss a strategy with the maintainers. Otherwise, you risk doing a lot of work for nothing!

  • Prioritize understanding over cleverness. Write code clearly and concisely. Remember that source code usually gets written once and read often. Ensure the code is clear to the reader. The purpose and logic should be obvious to a reasonably skilled developer, otherwise you should add a comment that explains it.

  • Follow existing coding style and conventions. Keep your code consistent with the style, formatting, and conventions in the rest of the code base. When possible, these will be enforced with a linter. Consistency makes it easier to review and modify in the future.

  • Include test coverage. Add unit tests when possible. Follow existing patterns for implementing tests.

  • Update the example project if one exists to exercise any new functionality you have added.

  • Add documentation. Document your changes with code doc comments or in existing guides.

  • Update the CHANGELOG for all enhancements and bug fixes. Include the corresponding issue number if one exists, and your GitHub username. (example: "- Fixed crash in profile view. #123 @jessesquires")

  • Use the repo's default branch. Branch from and submit your pull request to the repo's default branch. Usually this is main, but it could be dev, develop, or master.

  • Resolve any merge conflicts that occur.

  • Promptly address any CI failures. If your pull request fails to build or pass tests, please push another commit to fix it.

  • When writing comments, use properly constructed sentences, including punctuation.

  • Use spaces, not tabs.

πŸ“ Writing Commit Messages

Please write a great commit message.

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Wrap the body at about 72 characters
  6. Use the body to explain why, not what and how (the code shows that!)
  7. If applicable, prefix the title with the relevant component name or emoji (see below. examples: "[Docs] Fix typo", "[Profile] Fix missing avatar")
:palm_tree: Summary of Amazing Feature Here

Add a more detailed explanation here, if necessary. Possibly give 
some background about the issue being fixed, etc. The body of the 
commit message can be several paragraphs. Further paragraphs come 
after blank lines and please do proper word-wrap.

Wrap it to about 72 characters or so. In some contexts, 
the first line is treated as the subject of the commit and the 
rest of the text as the body. The blank line separating the summary 
from the body is critical (unless you omit the body entirely); 
various tools like `log`, `shortlog` and `rebase` can get confused 
if you run the two together.

Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how or what. The code explains 
how or what. Reviewers and your future self can read the patch, 
but might not understand why a particular solution was implemented.
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.

 - Bullet points are awesome, too

 - A hyphen should be used for the bullet, preceded
   by a single space, with blank lines in between

Note the fixed or relevant GitHub issues at the end:

Resolves: #123
See also: #456, #789

βœ… Pull Request Checklist

Not all Pull Requests require these things, but here's a great list of things to check to see if it makes sense for your situation:

  • Are the changes complete?
  • Are there tests for the new functionality?
  • Are the changes passing the style checks?
  • Is there documentation for the new functionality?
  • Has the change been added to Changelog.md?
  • Has the change been added to ReleaseNotes.md?
  • Have new config options been added as defaults to the project.yml files?

❀️ Who Loves Emoji?

Commit comments, Issues, Feature Requests... they can all use a little sprucing up, right? Consider using the following emoji for a mix of function and :sparkles: dazzle! We encourage loosely following the conventions of gitmoji for contributing to Ceedling.

  • actions

    • 🌱 :seedling: (or other plants) when growing new features. Choose your fav! 🌡 🌿 🌲 🌴 🌳 🌼
    • 🎨 :art: when improving the format/structure of the code
    • 🐎 :racehorse: when improving performance
    • 🚱 :non-potable_water: when plugging memory leaks
    • πŸ“ :memo: when writing docs
    • πŸ› :bug: (or other insects) when fixing a bug. Maybe πŸͺ² 🐜 or 🐝 ?
    • πŸ”₯ :fire: when removing code or files
    • πŸ’š :green_heart: when fixing the CI build
    • βœ… :white_check_mark: when adding tests
    • πŸ”’ :lock: when dealing with security
    • ⬆️ :arrow_up: when upgrading dependencies
    • ⬇️ :arrow_down: when downgrading dependencies
    • πŸ‘• :shirt: when removing linter warnings
  • platforms

    • 🐧 :penguin: when fixing something on Linux
    • 🍎 :apple: when fixing something on macOS
    • 🏁 :checkered_flag: when fixing something on Windows

βœ… Code Review

  • Review the code, not the author. Look for and suggest improvements without disparaging or insulting the author. Provide actionable feedback and explain your reasoning.

  • You are not your code. When your code is critiqued, questioned, or constructively criticized, remember that you are not your code. Do not take code review personally.

  • Always do your best. No one writes bugs on purpose. Do your best, and learn from your mistakes.

  • Kindly note any violations to the guidelines specified in this document.

🎻 Coding Style

Consistency is the most important. Following the existing style, formatting, and naming conventions of the file you are modifying and of the overall project. Failure to do so will result in a prolonged review process that has to focus on updating the superficial aspects of your code, rather than improving its functionality and performance.

For example, if all private properties are prefixed with an underscore _, then new ones you add should be prefixed in the same way. Or, if methods are named using camelcase, like thisIsMyNewMethod, then do not diverge from that by writing this_is_my_new_method. You get the idea. If in doubt, please ask or search the codebase for something similar.

When possible, style and format will be enforced with a linter.

C Styleguide

C code is linted with AStyle.

Ruby Styleguide

Ruby code is linted with Rubocop

πŸ… Certificate of Origin

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

  1. The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
  2. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
  3. The contribution was provided directly to me by some other person who certified (1), (2) or (3) and I have not modified it.
  4. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.

No Brown M&M's

If you are reading this, bravo dear user and (hopefully) contributor for making it this far! You are awesome. :100:

To confirm that you have read this guide and are following it as best as possible, include this emoji at the top of your issue or pull request: 🍍 :pineapple:

πŸ™ Credits

Written by @jessesquires. Lovingly adapted to ThrowTheSwitch.org by @mvandervoord.

Please feel free to adopt this guide in your own projects. Fork it wholesale or remix it for your needs.

Many of the ideas and prose for the statements in this document were based on or inspired by work from the following communities:

We commend them for their efforts to facilitate collaboration in their projects.

 
panel4.png
 

ThrowTheSwitch.org Code of Conduct

Thank you for participating in a ThrowTheSwitch.org community project! We want this to continue to be a warm and inviting place for everyone to share ideas and get help. To accomplish this goal, we've developed this Code of Conduct.

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

Our Standards

Examples of behavior that contributes to a positive environment for our community include:

  • Demonstrating empathy and kindness toward other people
  • Being respectful of differing opinions, viewpoints, and experiences
  • Giving and gracefully accepting constructive feedback
  • Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
  • Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

  • The use of sexualized language or imagery, and sexual attention or advances of any kind
  • Trolling, insulting or derogatory comments, and personal or political attacks
  • Public or private harassment
  • Publishing others' private information, such as a physical or email address, without their explicit permission
  • Other conduct which could reasonably be considered inappropriate in a professional setting

Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hello@thingamabyte.com.

All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

1. Correction

Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

2. Warning

Community Impact: A violation through a single incident or series of actions.

Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

3. Temporary Ban

Community Impact: A serious violation of community standards, including sustained inappropriate behavior.

Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

4. Permanent Ban

Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

Consequence: A permanent ban from any sort of public interaction within the community.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.

Community Impact Guidelines were inspired by Mozilla's code of conduct enforcement ladder.

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

 
 

ThrowTheSwitch.org Coding Standard

Hi. Welcome to the coding standard for ThrowTheSwitch.org. For the most part, we try to follow these standards to unify our contributors' code into a cohesive unit (puns intended). You might find places where these standards aren't followed. We're not perfect. Please be polite where you notice these discrepancies and we'll try to be polite when we notice yours.

;)

Why Have A Coding Standard?

Being consistent makes code easier to understand. We've made an attempt to keep our standard simple because we also believe that we can only expect someone to follow something that is understandable. Please do your best.

Our Philosophy

Before we get into details on syntax, let's take a moment to talk about our vision for these tools. We're C developers and embedded software developers. These tools are great to test any C code, but catering to embedded software has made us more tolerant of compiler quirks. There are a LOT of quirky compilers out there. By quirky I mean "doesn't follow standards because they feel like they have a license to do as they wish."

Our philosophy is "support every compiler we can". Most often, this means that we aim for writing C code that is standards compliant (often C89... that seems to be a sweet spot that is almost always compatible). But it also means these tools are tolerant of things that aren't common. Some that aren't even compliant. There are configuration options to override the size of standard types. There are configuration options to force Unity to not use certain standard library functions. A lot of Unity is configurable and we have worked hard to make it not TOO ugly in the process.

Similarly, our tools that parse C do their best. They aren't full C parsers (yet) and, even if they were, they would still have to accept non-standard additions like gcc extensions or specifying @0x1000 to force a variable to compile to a particular location. It's just what we do, because we like everything to Just Workβ„’.

Speaking of having things Just Workβ„’, that's our second philosophy. By that, we mean that we do our best to have EVERY configuration option have a logical default. We believe that if you're working with a simple compiler and target, you shouldn't need to configure very much... we try to make the tools guess as much as they can, but give the user the power to override it when it's wrong.

Naming Things

Let's talk about naming things. Programming is all about naming things. We name files, functions, variables, and so much more. While we're not always going to find the best name for something, we actually put quite a bit of effort into finding What Something WANTS to be Calledβ„’.

When naming things, we more or less follow this hierarchy, the first being the most important to us (but we do all four whenever possible):

  1. Readable
  2. Descriptive
  3. Consistent
  4. Memorable

Readable

We want to read our code. This means we like names and flow that are more naturally read. We try to avoid double negatives. We try to avoid cryptic abbreviations (sticking to ones we feel are common).

Descriptive

We like descriptive names for things, especially functions and variables. Finding the right name for something is an important endeavor. You might notice from poking around our code that this often results in names that are a little longer than the average. Guilty. We're okay with a tiny bit more typing if it means our code is easier to understand.

There are two exceptions to this rule that we also stick to as religiously as possible:

First, while we realize hungarian notation (and similar systems for encoding type information into variable names) is providing a more descriptive name, we feel that (for the average developer) it takes away from readability and therefore is to be avoided.

Second, loop counters and other local throw-away variables often have a purpose which is obvious. There's no need, therefore, to get carried away with complex naming. We find i, j, and k are better loop counters than loopCounterVar or whatnot. We only break this rule when we see that more description could improve understanding of an algorithm.

Consistent

We like consistency, but we're not really obsessed with it. We try to name our configuration macros in a consistent fashion... you'll notice a repeated use of UNITY_EXCLUDE_BLAH or UNITY_USES_BLAH macros. This helps users avoid having to remember each macro's details.

Memorable

Where ever it doesn't violate the above principles, we try to apply memorable names. Sometimes this means using something that is simply descriptive, but often we strive for descriptive AND unique... we like quirky names that stand out in our memory and are easier to search for. Take a look through the file names in Ceedling and you'll get a good idea of what we are talking about here. Why use preprocess when you can use preprocessinator? Or what better describes a module in charge of invoking tasks during releases than release_invoker? Don't get carried away. The names are still descriptive and fulfill the above requirements, but they don't feel stale.

C and C++ Details

We don't really want to add to the style battles out there. Tabs or spaces? How many spaces? Where do the braces go? These are age-old questions that will never be answered... or at least not answered in a way that will make everyone happy.

We've decided on our own style preferences. If you'd like to contribute to these projects (and we hope that you do), then we ask if you do your best to follow the same. It will only hurt a little. We promise.

Whitespace

Our C-style is to use spaces and to use 4 of them per indent level. It's a nice power-of-2 number that looks decent on a wide screen. We have no more reason than that. We break that rule when we have lines that wrap (macros or function arguments or whatnot). When that happens, we like to indent further to line things up in nice tidy columns.

if (stuff_happened)
    {
        do_something();
    }

Case

  • Files - all lower case with underscores.
  • Variables - all lower case with underscores
  • Macros - all caps with underscores.
  • Typedefs - all caps with underscores. (also ends with _T).
  • Functions - camel cased. Usually named ModuleName_FuncName
  • Constants and Globals - camel cased.

Braces

The left brace is on the next line after the declaration. The right brace is directly below that. Everything in between in indented one level. If you're catching an error and you have a one-line, go ahead and to it on the same line.

while (blah)
    {
        //Like so. Even if only one line, we use braces.
    }

Comments

Do you know what we hate? Old-school C block comments. BUT, we're using them anyway. As we mentioned, our goal is to support every compiler we can, especially embedded compilers. There are STILL C compilers out there that only support old-school block comments. So that is what we're using. We apologize. We think they are ugly too.

Ruby Details

Is there really such thing as a Ruby coding standard? Ruby is such a free form language, it seems almost sacrilegious to suggest that people should comply to one method! We'll keep it really brief!

Whitespace

Our Ruby style is to use spaces and to use 2 of them per indent level. It's a nice power-of-2 number that really grooves with Ruby's compact style. We have no more reason than that. We break that rule when we have lines that wrap. When that happens, we like to indent further to line things up in nice tidy columns.

Case

  • Files - all lower case with underscores.
  • Variables - all lower case with underscores
  • Classes, Modules, etc - Camel cased.
  • Functions - all lower case with underscores
  • Constants - all upper case with underscores

Documentation

Egad. Really? We use markdown and we like pdf files because they can be made to look nice while still being portable. Good enough?

Find The Latest of This And More at ThrowTheSwitch.org