T* About

trivelop

{:ok, "Let's ship it ..."}

Credo: How Config Comments work

As of v1.4 of Elixir the compiler will warn you when you declare an unused module attribute. Unfortunately, this is also the case for @lint attributes.

# BEFORE: using @lint attribute to disable Credo
#         for an entire function

@lint false
defp do_stuff() do
  # ...
end

With the release of Credo v0.8, there is a new comment-based syntax. This will get rid of the compiler warnings. Also, you will be able to disable specific lines or entire files for all or only specific checks with this syntax.

# AFTER: use config comment to disable Credo
#        for the exact issue you want to ignore

defp do_stuff() do
  # credo:disable-for-next-line
  IO.inspect {:we_want_this_inspect_in_production!}
end

There are four config comments available:

  • credo:disable-for-this-file - disables Credo for the entire file, no matter where the comment is put (so you can put it somewhere it doesn’t bother you too much)
  • credo:disable-for-next-line - disables Credo for the next line
  • credo:disable-for-previous-line - disables Credo for the previous line
  • credo:disable-for-lines:<count> - disables Credo for the given number of lines (can be negative to disable previous lines)

Disabling specific checks

Each of these can also take the name of the check you want to disable:

defp do_stuff() do
  # credo:disable-for-next-line Credo.Check.Warning.IoInspect
  IO.inspect {:we_want_this_inspect_in_production!}
end

Lastly, you can put a regular expression (/.+/) instead of a check name to disable multiple checks (or if you do not want to type out the checks):

defp do_stuff() do
  # credo:disable-for-next-line /\.Warning\./
  IO.inspect {:we_want_this_inspect_in_production!}
end

Some Batteries NOT included …

There are two features which are not supported with this new syntax:

  • Let you put config comment at the end of a code line
  • Let you disable Credo at a specific line and re-enable it later

The reason for the first is that comments should be on their own line (except for things like defstruct, see Credo’s Style Guide).

The reason for the second is that people should not get used to regularly disabling Credo for large parts of their code (with the obvious exception of excluding entire files like third-party code).

Credo has always been good at rethinking seemingly tried-and-true mechanics. But: It can only get better at this through feedback. We have to reflect both the raised issues and the status quo.

While disabling Credo for a specific range of your code might seem useful, we have to ask ourselves if that is really what we want. Instead of giving people the means to silence these issues, we have to encourage them to “complain” and file a bug report with the Credo project on GitHub.

One more thing …

I would really like to thank all the contributors who make these releases possibly. Credo is very much a community effort and I applaud each and every one of you for being an active part of the Elixir community.

ElixirConf EU 2017 - Growing Up

Last week my brother-in-arms Christoph and I had the opportunity to attend ElixirConf EU for the second time. It’s been a great experience, rekindling old Elixir friendships and forming new ones. It is always great to meet people you only know from the interwebs - like @devoncestes and @bgmarx - in person.

But we also met some colleagues from home:

ElixirConf EU was a two track conference this time around, and while I was not giving a talk myself, Credo made a cameo appereance in a talk or two.

It makes me tremendously happy to see how we as a community embrace the same principles and form a strong community around similar ideas - open, looking for steady progress and a solid stack, embracing fault-tolerance (in people and machines 😉).

It became obvious during the three keynotes that Elixir and Phoenix have paid their dues. Seriously, it was amazing to see people from companies like Bleacher Report, CCP Games (Eve Online), Square Enix and Twitch tell us about their experience of using Elixir in production. We - the Elixir community - can now slowly shift our focus from convincing other developers of joining our club to conquering the hearts and minds of people outside our little clubhouse.

P.S. First flight with noise cancelling headphones. Easily the second most amazing technology on planet Earth (after Beam/OTP) 🌋😡🎧🏖😳

Joining 5Minds

After last week’s departure from Neopoly it’s time to look to the future!

Starting next month, I will transition into my new role at 5Minds.

There is so much that excites me about this new endeavour: They’re loving Elixir, which is always a good thing, but the main pull for me was probably just how much energy and development this young company exhibits.

I have a hard time finding words to describe the connection I felt. The people I met are enthusiastic folks by heart and crafting software is their life’s passion, as is mine.

If I had to sum up my initial impression in four words, I’d call them “super professional mad scientists”. Can’t wait to become one of them.