Skip to content

Contribute

Knight Hat edited this page Oct 16, 2023 · 1 revision

Table of Content

  1. General
  2. Code Format
  3. Git Commit Format

General

TL;DR: Be kind to each other

  1. Do

    • Be respectful: Treat all individuals with respect, regardless of their background, identity, or opinions.
    • Be inclusive: Welcome and include diverse perspectives, experiences, and ideas.
    • Be understanding: Seek to understand differing viewpoints and engage in constructive discussions.
    • Be mindful: Be mindful of the impact our words and actions have on others in the community.
  2. Don't

    • Harassment: Any form of harassment, discrimination, or offensive behavior is unacceptable and will not be tolerated.
    • Trolling: Deliberate and disruptive actions or comments with the intent to provoke or offend others.
    • Hateful speech: Use of derogatory or offensive language, slurs, or personal attacks.
    • Spam: Posting irrelevant or unsolicited content, including excessive self-promotion.

Code Format

Some of the code formats are included in the source code and can be loaded if you are using Android Studio

  1. Use Kotlin for non static classes. Why?
  2. Use spaces for indent (4 spaces). Tab indent will be rejected at PR.
  3. Follow as close as possible to the existing code style and conventions.
    • Check out files in .idea/ folder for details
  4. Be sure to write clear and concise code and documentation.
    • Do NOT build a pyramid (at most 3 nested statements are allowed).
    • Use easy to understand naming schemes
      • Capitalize first character of a word (except for the very first) if name contains multiple words.
      • Abbreviation: err stands for "error", do not name it e.
    • A function/method should only do ONE job.
    • A class is an idea of all functions/methods inside of it.
  5. If you're adding new features or make significant changes, consider adding relevant tests.
  6. If you're fixing a bug, please provide steps to reproduce the issue if applicable.

Avoid Declaring Static Functions In Kotlin Classes

Reason will be updated in the near future as more things discovered.

  1. Static methods in Kotlin is hard to generate documentation.
  2. Companion Object looks messy in Kotlin due to @JvmStatic and other annotation.
  3. Increase indentation.

Git Commit Format

  1. Keep the history as linear as possible.
  2. Avoid combining multiple classes to one commit.
  3. A commit is only about one change inside the class.
  4. If one change requires update in multiple classes, then multiple classes in one commit is allowed, but concise commit message is required.