This repository has been archived on 2024-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
neofetch/CONTRIBUTING.md

2.0 KiB
Raw Blame History

How to Contribute

Table of Contents

ShellCheck

For your contribution to be accepted, your changes need to pass ShellCheck.

Run ShellCheck with the following command:

# Why do we exclude numerous tests?
# See: https://github.com/dylanaraps/neofetch/wiki/Shellcheck-Exclusions
shellcheck neofetch -e SC1090,SC2009,SC2012,SC2016,SC2034,SC2128,SC2153,SC2154,SC2178,SC2010,SC1004,SC1091,SC1117

Note: If you have trouble installing ShellCheck. You can open a pull request on the repo and our Travis.ci hook will run ShellCheck for you.

Coding Conventions

  • Indent 4 spaces.
  • Use snake_case for function and variable names.
  • Keep lines below 100 characters long.
  • Use [[ ]] for tests.

No no's

  • Dont use echo.
    • Use printf "%s\n"
  • Dont use bc.
  • Dont use sed.
  • Dont use cat.
    • Use bash's built-in syntax (file="$(< /path/to/file.txt)")).
  • Dont use grep "pattern" | awk '{ printf }'.
    • Use awk '/pattern/ { printf }'

If Statements

If the test only has one command inside of it; use the compact test syntax. Otherwise the normal if/fi is just fine.

# Bad
if [[ "$var" ]]; then
    printf "%s\n" "$var"
fi

# Good
[[ "$var" ]] && printf "%s\n" "$var"

# Also good (Use this for longer lines).
[[ "$var" ]] && \
    printf "%s\n" "$var"

Case Statements

Case statements need to be formatted in a specific way.

# Good example (Notice the indentation).
case "$var" in
    1)  printf "%s\n" 1 ;;
    2)
        printf "%s\n" "1"
        printf "%s\n" "2"
    ;;

    *)
        printf "%s\n" "1"
        printf "%s\n" "2"
        printf "%s\n" "3"
    ;;
esac