robinmonjo / coincoin

Blockchain based cryptocurrency proof-of-concept built with Elixir. Feedback welcome
404 stars 54 forks source link

Format and type specs #19

Closed robinmonjo closed 6 years ago

robinmonjo commented 7 years ago

The goal of this PR is to use the Elixir 1.6 code formatter and write type specs on the entire codebase

So far I set up the code formatter. I had to:

TODOs:

Once Elixir 1.6 is released I will have to "simplify" the travis.yml

Fix: https://github.com/robinmonjo/coincoin/issues/14 Fix: https://github.com/robinmonjo/coincoin/issues/18

robinmonjo commented 6 years ago

Ok I think I'm done with this PR. @yordis if you want to have a look, be my guest 😊

yordis commented 6 years ago

Did you ran elixir format?

robinmonjo commented 6 years ago

Yes I did ran mix format, formatting is also checked by CI but I didn't include .formatter.exs in the list of file to format 😊. Fixed in last commit

yordis commented 6 years ago

Add .editorconfig, it will help with situations of trimming the spaces and adding the jump of line at the end of the file

# .editorconfig
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
yordis commented 6 years ago

Well you need to install the plugin for your editor for sure 😄

robinmonjo commented 6 years ago

Don't you think this would be redundant with mix format ? I think mix format already ensure everything you list in the config file

yordis commented 6 years ago

@robinmonjo does mix format add the jump at the end of the file or trim trailing whitespace?

I think it doesn't because some of your files are missing the jump at the end of the line

Also is for all the files on the system

robinmonjo commented 6 years ago

Yes it does add the jumpline (only on files that matches the patterns defined in .formatter.exs. As for trailing whitespaces I'm not sure my editor does it for me. Will take a look at editor config (you are the first one who talk to me about this)

yordis commented 6 years ago

I like editorconfig because you help the people that contributes to the project and you mitigate the issue with IDE/Editors configuration, at least they could install the plugin (which some of the editors and IDE already have it by default) and it will help us out.

robinmonjo commented 6 years ago

Ok @yordis I added the .editorconfig file :+1:

robinmonjo commented 6 years ago

@yordis is it all good for you ? Should we merge this ?

yordis commented 6 years ago

@robinmonjo all good man! Amazing work 😎

robinmonjo commented 6 years ago

👍 thanks again for the review and advices ! I started to read the "Metaprogramming Elixir" book to see what can be done with the AST and how to use it to build a "blockchain language" for smart contracts. Lot's of work, big subject but might be interesting :)