Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do we use this style guide in an automated way? #143

Open
sergiotapia opened this issue May 9, 2017 · 12 comments
Open

How do we use this style guide in an automated way? #143

sergiotapia opened this issue May 9, 2017 · 12 comments

Comments

@sergiotapia
Copy link

Right now I have Atom, Credo, and the atom-credo linter package installed.

Is there a way for us Elixir devs to use this style guide in an automated way?

@optikfluffel
Copy link

Having something like https://atom.io/packages/elm-format would be pretty cool 😆

@christopheradams
Copy link
Owner

Is there a way for us Elixir devs to use this style guide in an automated way?

It should be possible to write custom Credo checks for many of the style recommendations in this guide, and package them up for use in any Elixir project. Would this be of interest? Do you think it would make sense to include them here, or to create a separate repo/project for that purpose?

Having something like https://atom.io/packages/elm-format would be pretty cool 😆

Not quite the same, but have you tried https://github.com/lpil/dogma ?

@sergiotapia
Copy link
Author

sergiotapia commented May 10, 2017

I found this repo using the trending feature for Github, so I imagine that a lot of Elixir devs agree this this is a nice way to write Elixir. I would love to be able to install a package in Atom and run all these style checks against my open file.

In Javascript I use prettier.
In Ruby I use rubocop.
In Go I use go fmt.
In Elixir...eh... wat do?!

@christopheradams
Copy link
Owner

@sergiotapia You already mentioned atom-credo. That runs mix credo and reports the output, right? In theory it should work with a customized Credo config.

It would be a fair amount of work to write credo checks for this style guide, and either upstream them to credo or create a separate package. But it should be doable!

@ericmj
Copy link

ericmj commented May 10, 2017

We have a google summer of code student working on an elixir formatter. It won't follow this style guide, but it will be fairly similar.

@corroded corroded added this to Needs Discussion / Clarification in Style guide Kanban board May 10, 2017
@bamorim
Copy link

bamorim commented Jun 3, 2018

First of all, sorry for posting in this old issue, but since it was open I though that would not be that bad.

I've been playing around with Credo and the Formatter to see what things are not automated.
I detected a few things you can check on this repository

Source Code Layout

Neither credo nor formatter caught it

Formatter didn't caught, but Credo did

Syntax

Neither credo nor formatter caught it

Formatter didn't caught, but Credo did

Comments

Only problems with comment grammar (which is totally understandeable), as seen here

Modules

Almost nothing was caught. I think only space after defmodule was solved automatically.

I think that the order is something really nice to add to Credo. Will think about it

Typespecs

Neither credo nor formatter caught it

Structs

Neither credo nor formatter caught it

Improving

There is probably a lot of places we can improve that I haven't tested. I also dind't got into naming because it is a nasty space.

One thing we could do to automate it better is:

Add Checks to Credo

This is the list of checks I think is not that hard to implement on Credo

Maybe we should create some issues on Credo repo and see if they think these checks are reasonable and then we can try to implement the checks (we could ship the checks in a different repo as well)

What do you guys think?

@bamorim
Copy link

bamorim commented Jun 3, 2018

There is a discussion on rrene/credo#540 about the module ordering

@Stratus3D
Copy link

Looks like there is a PR out for module attribute ordering: rrrene/credo#588 🎉

@xtian
Copy link

xtian commented Sep 5, 2019

I have a package called credo_contrib which implements a lot of the rules from this style guide (including module attribute ordering). I'll take a look at the list above and see if there are any more I can add. Contributions welcome also!

@Stratus3D
Copy link

@Stratus3D
Copy link

@christopheradams
Copy link
Owner

I have created rrrene/credo#933 to enforce https://github.com/christopheradams/elixir_style_guide#pipe-operator tada

This is great work @Stratus3D, please keep us up to date on your credo PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Style guide Kanban board
Needs Discussion / Clarification
Development

No branches or pull requests

7 participants