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

Fix Elixir 1.17 warnings #561

Merged
merged 4 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.

### Fixed

- Fix runtime warning on Elixir 1.17 [[@ypconstante](https://github.com/ypconstante)]

### Security

## 0.18.0
Expand Down
4 changes: 2 additions & 2 deletions lib/faker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Faker do
acc
end

@alphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
@alphabet ~c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
defp letter do
Enum.at(@alphabet, random_between(0, Enum.count(@alphabet) - 1))
end
Expand Down Expand Up @@ -106,7 +106,7 @@ defmodule Faker do
"""
@spec random_uniform() :: float
def random_uniform do
Application.get_env(:faker, :random_module).random_uniform
Application.get_env(:faker, :random_module).random_uniform()
end

@doc """
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/address.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Faker.Address do

alias Faker.Person

@geobase32 '0123456789bcdefghjkmnpqrstuvwxyz'
@geobase32 ~c"0123456789bcdefghjkmnpqrstuvwxyz"

@moduledoc """
Functions for generating addresses.
Expand Down
16 changes: 8 additions & 8 deletions lib/faker/avatar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ defmodule Faker.Avatar do

## Examples

iex> Faker.Avatar.image_url('faker')
iex> Faker.Avatar.image_url("faker")
"https://robohash.org/faker"
iex> Faker.Avatar.image_url('elixir')
iex> Faker.Avatar.image_url("elixir")
"https://robohash.org/elixir"
iex> Faker.Avatar.image_url('plug')
iex> Faker.Avatar.image_url("plug")
"https://robohash.org/plug"
iex> Faker.Avatar.image_url('ecto')
iex> Faker.Avatar.image_url("ecto")
"https://robohash.org/ecto"
"""
@spec image_url(binary) :: String.t()
Expand Down Expand Up @@ -70,13 +70,13 @@ defmodule Faker.Avatar do

## Examples

iex> Faker.Avatar.image_url('phoenix', 100, 100)
iex> Faker.Avatar.image_url("phoenix", 100, 100)
"https://robohash.org/phoenix?size=100x100"
iex> Faker.Avatar.image_url('haskell', 200, 200)
iex> Faker.Avatar.image_url("haskell", 200, 200)
"https://robohash.org/haskell?size=200x200"
iex> Faker.Avatar.image_url('ocaml', 300, 300)
iex> Faker.Avatar.image_url("ocaml", 300, 300)
"https://robohash.org/ocaml?size=300x300"
iex> Faker.Avatar.image_url('idris', 400, 400)
iex> Faker.Avatar.image_url("idris", 400, 400)
"https://robohash.org/idris?size=400x400"
"""
@spec image_url(binary, integer, integer) :: String.t()
Expand Down
10 changes: 5 additions & 5 deletions lib/faker/lorem.ex
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,13 @@ defmodule Faker.Lorem do
## Examples

iex> Faker.Lorem.characters()
'ppkQqaIfGqxsjFoNITNnu6eXyJicLJNth88PrhGDhwp4LNQMt5pCFh7XGEZUiBOjqwcnSUTH94vu8a9XKUwNAs48lHzPITbFXSfTS0pHfBSmHkbj9kOsd7qRuGeXKTgCgI1idI3uwENwTqc'
~c'ppkQqaIfGqxsjFoNITNnu6eXyJicLJNth88PrhGDhwp4LNQMt5pCFh7XGEZUiBOjqwcnSUTH94vu8a9XKUwNAs48lHzPITbFXSfTS0pHfBSmHkbj9kOsd7qRuGeXKTgCgI1idI3uwENwTqc'
iex> Faker.Lorem.characters(3..5)
'EFbv'
~c'EFbv'
iex> Faker.Lorem.characters(2)
'vx'
~c'vx'
iex> Faker.Lorem.characters(7)
'jycADSd'
~c'jycADSd'
"""
@spec characters(integer | Range.t()) :: [char]
def characters(range_or_length \\ 15..255)
Expand Down Expand Up @@ -498,7 +498,7 @@ defmodule Faker.Lorem do
end

defp character do
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
alphabet = ~c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Enum.at(alphabet, Faker.random_between(0, Enum.count(alphabet) - 1))
end
end