reid-rigo

reid-rigo

Code review request: codeowners package

Hello, I’m new to Elixir and created this package, which is the adaptation of some Ruby code I wrote, as a learning exercise: codeowners | Hex

I’m looking for feedback on:

  • How to make this code more idiomatic
  • More appropriate functions/modules to use
  • Best practices for libraries

Feedback is welcome here or in Github

Most Liked

sodapopcan

sodapopcan

For me it’s not about refactoring—a global rename is a global rename—it’s about ease of reading. When I see __MODULE__ I immediately think “local.” Seeing a fully-qualified self-referencing module name always causes a bit of a jarring pause where I have to go and confirm that it is indeed referencing itself. This is indeed on the minor end of readability issues and is not a hill I’d die on. I do, however, vehemently disagree with the advice in that guide to use an alias if you want “a prettier name” :face_with_raised_eyebrow: If it weren’t for the few legitimate uses cases it has, I wouldn’t be upset if the :as option for alias were removed from the language.

RudManusachi

RudManusachi

Hi, @reid-rigo :wave: and welcome!

I’d point you to this style guide: GitHub - christopheradams/elixir_style_guide: A community driven style guide for Elixir · GitHub

Use the __MODULE__ pseudo variable when a module refers to itself.

It might look weird at first (becuase of double underscores and all caps) but it’s very common to refer to the module itself.

RudManusachi

RudManusachi

One of the point you were asking:

  • How to make this code more idiomatic

So I just pointed to what seemed more idiomatic to me :slightly_smiling_face:

Based on a suggestion in another thread I tried #{__MODULE__} , but that outputs Elixir.Codeowners when I run mix docs.

So it does with any module name, such as: #{Logger} would print "Elixir.Logger". If you want to nicely disregard the prefix Elixir. you could inspect/1 it:

"#{inspect(__MODULE__)}"

See example: elixir/lib/elixir/lib/kernel/utils.ex at c5816a227f5ad295ccbfcc5571308f76190d6bfe · elixir-lang/elixir · GitHub

Last Post!

reid-rigo

reid-rigo

the use of File.cwd! in build is odd; consider allowing callers to either supply a root directly or as an override. To reduce the need for most callers to pass a root, load could do some guessing based on if the supplied file is in a doc or .github directory.

I made a change to accept root as an option in this commit

Where Next?

Popular in Questions Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42576 114
New

We're in Beta

About us Mission Statement