diff --git a/lib/qr_code/data_encoding/common.ex b/lib/qr_code/data_encoding/common.ex index 95c704e..fcfcbd1 100644 --- a/lib/qr_code/data_encoding/common.ex +++ b/lib/qr_code/data_encoding/common.ex @@ -57,7 +57,7 @@ defmodule QRCode.DataEncoding.Common do end defp add_specification(fill_to_max) do - 1..fill_to_max + 1..fill_to_max//1 |> Enum.map(fn x -> rem(x, 2) end) |> Enum.reduce(<<>>, fn x, acc when x == 0 -> acc <> <<17>> diff --git a/lib/qr_code/data_masking.ex b/lib/qr_code/data_masking.ex index 6e31113..af810d6 100644 --- a/lib/qr_code/data_masking.ex +++ b/lib/qr_code/data_masking.ex @@ -25,7 +25,7 @@ defmodule QRCode.DataMasking do @spec masking_matrices(Matrix.t()) :: Enumerable.t() def masking_matrices(matrix) do - Stream.map(0..7, fn num -> {num, make_mask_pattern(matrix, num)} end) + Stream.map(0..7//1, fn num -> {num, make_mask_pattern(matrix, num)} end) end @spec total_penalties(Enumerable.t()) :: Enumerable.t() @@ -44,7 +44,7 @@ defmodule QRCode.DataMasking do @spec total_penalty(Matrix.t()) :: pos_integer() def total_penalty(matrix) do - Enum.reduce(1..4, 0, fn pen, sum -> penalty(matrix, pen) + sum end) + Enum.reduce(1..4//1, 0, fn pen, sum -> penalty(matrix, pen) + sum end) end @spec penalty(Matrix.t(), 1 | 2 | 3 | 4) :: non_neg_integer() diff --git a/lib/qr_code/galois_field.ex b/lib/qr_code/galois_field.ex index 0ec76df..977dce2 100644 --- a/lib/qr_code/galois_field.ex +++ b/lib/qr_code/galois_field.ex @@ -272,7 +272,7 @@ defmodule QRCode.GaloisField do 2 """ @spec to_i(alpha()) :: value() - def to_i(alpha) when alpha in 0..254 do + def to_i(alpha) when alpha in 0..254//1 do @gf_table |> Enum.find(fn {_i, a} -> alpha == a end) |> first() @@ -285,7 +285,7 @@ defmodule QRCode.GaloisField do 1 """ @spec to_a(value()) :: alpha() - def to_a(integer) when integer in 1..255 do + def to_a(integer) when integer in 1..255//1 do @gf_table |> Enum.find(fn {i, _a} -> integer == i end) |> second() diff --git a/lib/qr_code/generator_polynomial.ex b/lib/qr_code/generator_polynomial.ex index 708baff..8ae215c 100644 --- a/lib/qr_code/generator_polynomial.ex +++ b/lib/qr_code/generator_polynomial.ex @@ -30,7 +30,7 @@ defmodule QRCode.GeneratorPolynomial do [0, 251, 67, 46, 61, 118, 70, 64, 94, 32, 45] """ @spec create(degree()) :: polynomial() - def create(degree) when is_integer(degree) and degree in 1..254 do + def create(degree) when is_integer(degree) and degree in 1..254//1 do degree |> roots() |> Enum.reduce(&multiply/2) diff --git a/lib/qr_code/placement.ex b/lib/qr_code/placement.ex index d12bde2..e585309 100644 --- a/lib/qr_code/placement.ex +++ b/lib/qr_code/placement.ex @@ -180,7 +180,7 @@ defmodule QRCode.Placement do end defp fill_matrix_by_message(matrix, size, message) do - (size - 1)..7 + (size - 1)..7//-1 |> Enum.take_every(2) |> Enum.concat([5, 3, 1]) |> Enum.map_reduce({matrix, message}, fn col, acc -> diff --git a/lib/qr_code/qr.ex b/lib/qr_code/qr.ex index c119fdd..c5d510d 100644 --- a/lib/qr_code/qr.ex +++ b/lib/qr_code/qr.ex @@ -44,8 +44,8 @@ defmodule QRCode.QR do defguard level(lvl) when lvl in @levels defguard mode(m) when m in @modes - defguard version(v) when v in 1..40 - defguard masking(m) when m in 0..7 + defguard version(v) when v in 1..40//1 + defguard masking(m) when m in 0..7//1 @doc """ Creates QR code. You can change the error correction level according to your needs. diff --git a/test/generator_polynomial_test.exs b/test/generator_polynomial_test.exs index 26f93b8..550a33f 100644 --- a/test/generator_polynomial_test.exs +++ b/test/generator_polynomial_test.exs @@ -11,7 +11,7 @@ defmodule GeneratorPolynomialTest do forall degree <- integer(1, 254) do poly = GP.create(degree) - assert Enum.all?(poly, fn x -> x in 0..254 end) + assert Enum.all?(poly, fn x -> x in 0..254//1 end) end end diff --git a/test/placement_test.exs b/test/placement_test.exs index 01d554a..30b44ae 100644 --- a/test/placement_test.exs +++ b/test/placement_test.exs @@ -15,7 +15,7 @@ defmodule PlacementTest do describe "Placement" do test "should check if finder patterns have correct position at qr matrix" do tasks = - for version <- 1..40 do + for version <- 1..40//1 do Task.async(fn -> size = 4 * version + 17 @@ -34,7 +34,7 @@ defmodule PlacementTest do test "should check if separator patterns have correct position at qr matrix" do tasks = - for version <- 1..40 do + for version <- 1..40//1 do Task.async(fn -> size = 4 * version + 17 @@ -53,7 +53,7 @@ defmodule PlacementTest do test "should check if reserved areas have correct position at qr matrix" do tasks = - for version <- 1..40 do + for version <- 1..40//1 do Task.async(fn -> size = 4 * version + 17 @@ -72,7 +72,7 @@ defmodule PlacementTest do test "should check if timing patterns have correct position at qr matrix" do tasks = - for version <- 1..40 do + for version <- 1..40//1 do Task.async(fn -> size = 4 * version + 17 @@ -91,7 +91,7 @@ defmodule PlacementTest do test "should check if alignment patterns have correct positions at qr matrix" do tasks = - for version <- 1..40 do + for version <- 1..40//1 do Task.async(fn -> size = 4 * version + 17 @@ -110,7 +110,7 @@ defmodule PlacementTest do test "should check if dark modules have correct position at qr matrix" do tasks = - for version <- 1..40 do + for version <- 1..40//1 do Task.async(fn -> size = 4 * version + 17 @@ -143,7 +143,7 @@ defmodule PlacementTest do size = 4 * version + 16 {:ok, [hd | rest]} = - size..7 + size..7//-1 |> Enum.take_every(2) |> Enum.concat([5, 3, 1]) |> Enum.reverse()