-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Development: code style and guidelines
It's pretty simple:
- indent with two spaces
- lines can be very long, so your $EDITOR had better handle it
- align indented continuations of function arguments on the column after the opening parenthesis
- no whitespace after casts
- ...
TODO: Finish this. Mind you, it's somewhat free-form style, but as always, when in Rome...
- functions should consume a reference for each and every jv input argument
- use jv in preference to C types whenever possible
Most jq programs and functions are very short and require little in the way of style.
But jq programs and functions can be large enough to require splitting across multiple lines, in which case the preferred style is: .
jq is a lot like SQL when it comes to styling multi-line programs. Where should ... | ...
be split? Should the |
be left on the end of the first line or the beginning of the next? This is a matter of taste, but if one leaves the |
on the end of the first line then one should line up all the |
s at the same level of parenthesis nesting.
When should one indent? |
should not require indenting the right side. But perhaps the first continuation should be indented.
...
- Home
- FAQ
- jq Language Description
- Cookbook
- Modules
- Parsing Expression Grammars
- Docs for Oniguruma Regular Expressions (RE.txt)
- Advanced Topics
- Guide for Contributors
- How To
- C API
- jq Internals
- Tips
- Development