Open SimonLab opened 2 years ago
Review guidelines for building library: https://hexdocs.pm/elixir/main/library-guidelines.html
Check for possible error inside the library: For example: https://github.com/dwyl/gogs/blob/2c55a5be2da1dd2db9844fbf6755566988471d42/lib/gogs.ex#L162-L165 Here we call the File.read function without checking for errors. We can add a case statement here to make sure we read the file without any errors or report the error from the library itself to make is easier to debug see: https://hexdocs.pm/elixir/main/library-guidelines.html#avoid-working-with-invalid-data
File.read
Application configuration At the moment we are using module constant to defined from environment variable. We had a few issues linked to this and it might be better to let the application using the library define these values in the config file. see https://hexdocs.pm/elixir/main/library-guidelines.html#avoid-application-configuration
Rename modules Create the Gogs namespace and use it for other modules: https://github.com/dwyl/gogs/blob/2c55a5be2da1dd2db9844fbf6755566988471d42/lib/helpers.ex#L1 become Gogs.Helpers see: https://hexdocs.pm/elixir/main/library-guidelines.html#avoid-defining-modules-that-are-not-in-your-namespace
Gogs
Gogs.Helpers
These are the main points that we can update for now.
@SimonLab excellent doc reading, thanks! 👌🏻 if you have time to refactor, please go for it. 🙌 If not, I’m happy to take a look. 👨🏻💻
Initial PR with the “easy” part: name spacing. 🤞
Review guidelines for building library: https://hexdocs.pm/elixir/main/library-guidelines.html
Check for possible error inside the library: For example: https://github.com/dwyl/gogs/blob/2c55a5be2da1dd2db9844fbf6755566988471d42/lib/gogs.ex#L162-L165 Here we call the
File.read
function without checking for errors. We can add a case statement here to make sure we read the file without any errors or report the error from the library itself to make is easier to debug see: https://hexdocs.pm/elixir/main/library-guidelines.html#avoid-working-with-invalid-dataApplication configuration At the moment we are using module constant to defined from environment variable. We had a few issues linked to this and it might be better to let the application using the library define these values in the config file. see https://hexdocs.pm/elixir/main/library-guidelines.html#avoid-application-configuration
Rename modules Create the
Gogs
namespace and use it for other modules: https://github.com/dwyl/gogs/blob/2c55a5be2da1dd2db9844fbf6755566988471d42/lib/helpers.ex#L1 becomeGogs.Helpers
see: https://hexdocs.pm/elixir/main/library-guidelines.html#avoid-defining-modules-that-are-not-in-your-namespaceThese are the main points that we can update for now.