cql
cql copied to clipboard
Code formatting and styling
To avoid code written in too different styles, I would encourage the use of hlint and hindent and also compiling with stack --pedantic.
If you have any other styling rule you'd like to be followed, that would be nice to share
**Update 2018-05-31 by @epost and @marcosh **: https://www.tweag.io/posts/2019-05-27-ormolu.html and https://github.com/ennocramer/floskell
Yesh! Glad you asked. This is work in progress but it does tackle some important points: https://hackmd.io/U8vrBv94TqK413F0GIEAfg.
We probably also want to use an .editorconfig file, see https://editorconfig.org.
What would be a good place to hook in your suggested linting?
I'll take a look at editorconfig.
I'm using hlint and hindent at every save in my editor. I think that would be the best option (or anyway, anybody makes sures that he pushes code after linting it). Violations should be catched in code review.
Otherwise we could setup something which formats the code as soon as it is pushed, so we are sure that in code review everything is written nicely
Yeah that seems like a good idea for now. I was thinking we could validate it during the automated build, but not sure how easy that is, since our .travis.yml basically only says 'use Nix'.
The .editorconfig would look something like this I guess:
# see https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
There are also some tab warnings, see https://travis-ci.com/statebox/aql/builds/85998010
oh the tab issue seems to be fixed already in master: https://travis-ci.com/statebox/aql/builds/86003480
yeah I just merged Marco's commit.
stack build --pedantic adds the -Wall -Werror flags, shall we put these in package.yaml so that it affects nix-build and thus Travis builds as well?
Based on our rocketchat discussions of last night and before, we're investigating code formatters, and the extent to which they can help us produce readable code in the spirit of the stuff discussed above.
Is anyone besides me using a Mac? Getting ‘stack build’ to recognize ‘—pedantic’ would remove the cycle where I have to commit and push to read error messages from Travis CI.
On Oct 23, 2018, at 8:12 AM, Erik Post [email protected] wrote:
Based on our rocketchat discussions of last night and before, we're investigating code formatters, and the extent to which they can help us produce readable code in the spirit of the stuff discussed above.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or mute the thread.
@wisnesky Yep, moi. Let's try and figure that out. (I've heard some harsh criticism of Stack so this may be an example of how it's not so nice; I'm not sure.) Anyway, I created https://github.com/statebox/aql/issues/108 for this.