From 17c03d0ce9558699bd6b3c86edc90a1ffc6aa61b Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:25:29 -0800 Subject: [PATCH 01/12] Move config/.credo.exs to .credo.exs --- config/.credo.exs => .credo.exs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/.credo.exs => .credo.exs (100%) diff --git a/config/.credo.exs b/.credo.exs similarity index 100% rename from config/.credo.exs rename to .credo.exs From 9da38c198942ead8727700b69b90dd66c6138fcd Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:25:44 -0800 Subject: [PATCH 02/12] Delete config/* This resolves a deprecation warning to do with calling `use Mix.Config` Since libraries aren't intended to set application config anyway, we should just delete the directory. --- config/config.exs | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 config/config.exs diff --git a/config/config.exs b/config/config.exs deleted file mode 100644 index 285785c..0000000 --- a/config/config.exs +++ /dev/null @@ -1,30 +0,0 @@ -# This file is responsible for configuring your application -# and its dependencies with the aid of the Mix.Config module. -use Mix.Config - -# This configuration is loaded before any dependency and is restricted -# to this project. If another project depends on this project, this -# file won't be loaded nor affect the parent project. For this reason, -# if you want to provide default values for your application for -# 3rd-party users, it should be done in your "mix.exs" file. - -# You can configure for your application as: -# -# config :algae, key: :value -# -# And access this configuration in your application as: -# -# Application.get_env(:algae, :key) -# -# Or configure a 3rd-party app: -# -# config :logger, level: :info -# - -# It is also possible to import configuration files, relative to this -# directory. For example, you can emulate configuration per environment -# by uncommenting the line below and defining dev.exs, test.exs and such. -# Configuration from the imported file will override the ones defined -# here (which is why it is important to import them last). -# -# import_config "#{Mix.env}.exs" From 04848faf69885db1e4556fd7841a7678cb32d073 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:32:41 -0800 Subject: [PATCH 03/12] Remove mix.lock from .gitignore --- .gitignore | 1 - mix.lock | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 mix.lock diff --git a/.gitignore b/.gitignore index f6278de..38b9586 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ erl_crash.dump *.ez *.beam .DS_Store -mix.lock .mix diff --git a/mix.lock b/mix.lock new file mode 100644 index 0000000..5877c48 --- /dev/null +++ b/mix.lock @@ -0,0 +1,21 @@ +%{ + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, + "credo": {:hex, :credo, "1.6.2", "2f82b29a47c0bb7b72f023bf3a34d151624f1cbe1e6c4e52303b05a11166a701", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "ae9dc112bc368e7b145c547bec2ed257ef88955851c15057c7835251a17211c6"}, + "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, + "earmark": {:hex, :earmark, "1.4.20", "d5097b1c7417a03c73a2985fcf01c3f72192c427b8a498719737dca5273938cb", [:mix], [{:earmark_parser, "== 1.4.18", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "7be744242dbde74c858279f4a65d9d31f37d163190d739340015c30038c1edb3"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.18", "e1b2be73eb08a49fb032a0208bf647380682374a725dfb5b9e510def8397f6f2", [:mix], [], "hexpm", "114a0e85ec3cf9e04b811009e73c206394ffecfcc313e0b346de0d557774ee97"}, + "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, + "ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"}, + "exceptional": {:hex, :exceptional, "2.1.3", "cb17cb9b7c4882e763b82db08ba317678157ca95970fae96b31b3c90f5960c3d", [:mix], [], "hexpm", "59d67ae2df6784e7a957087742ae9011f220c3d1523706c5cd7ee0741bca5897"}, + "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, + "inch_ex": {:hex, :inch_ex, "2.0.0", "24268a9284a1751f2ceda569cd978e1fa394c977c45c331bb52a405de544f4de", [:mix], [{:bunt, "~> 0.2", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "96d0ec5ecac8cf63142d02f16b7ab7152cf0f0f1a185a80161b758383c9399a8"}, + "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, + "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.2.1", "264fc6864936b59fedb3ceb89998c64e9bb91945faf1eb115d349b96913cc2ef", [:mix], [], "hexpm", "23c31d0ec38c97bf9adde35bc91bc8e1181ea5202881f48a192f4aa2d2cf4d59"}, + "operator": {:hex, :operator, "0.2.1", "4572312bbd3e63a5c237bf15c3a7670d568e3651ea744289130780006e70e5f5", [:mix], [], "hexpm", "1990cc6dc651d7fff04636eef06fc64e6bc1da83a1da890c08ca3432e17e267a"}, + "quark": {:hex, :quark, "2.3.2", "066e0d431440d077684469967f54d732443ea2a48932e0916e974633e8b39c95", [:mix], [], "hexpm", "2f6423779b02afe7e3e4af3cfecfcd94572f2051664d4d8329ffa872d24b10a8"}, + "type_class": {:hex, :type_class, "1.2.7", "287a7982810c8f7fb0b8914f716b09cc675522846dc5d13b8b053662456dff4a", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}], "hexpm", "f9184803b6dcf3da4b9b3a15510498fc21566e8e2fe78f566238b7a02c973eee"}, + "witchcraft": {:hex, :witchcraft, "1.0.4", "8733ac0ee769d4d2f73610de5a2b601a4ccbe385d1fca6419280f2511d21d0c9", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}, {:operator, "~> 0.2", [hex: :operator, repo: "hexpm", optional: false]}, {:quark, "~> 2.2", [hex: :quark, repo: "hexpm", optional: false]}, {:type_class, "~> 1.2", [hex: :type_class, repo: "hexpm", optional: false]}], "hexpm", "a380f439f1962d2e56cdad874ed7eb4612ddd6ec5ee3c6ad0c5d63e60539e6b0"}, +} From f9153b149d793c77f8f88bb4a247dfb900633766 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:35:06 -0800 Subject: [PATCH 04/12] Update type_class: 1.2.7 => 1.2.8 --- mix.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.lock b/mix.lock index 5877c48..2e8e459 100644 --- a/mix.lock +++ b/mix.lock @@ -16,6 +16,6 @@ "nimble_parsec": {:hex, :nimble_parsec, "1.2.1", "264fc6864936b59fedb3ceb89998c64e9bb91945faf1eb115d349b96913cc2ef", [:mix], [], "hexpm", "23c31d0ec38c97bf9adde35bc91bc8e1181ea5202881f48a192f4aa2d2cf4d59"}, "operator": {:hex, :operator, "0.2.1", "4572312bbd3e63a5c237bf15c3a7670d568e3651ea744289130780006e70e5f5", [:mix], [], "hexpm", "1990cc6dc651d7fff04636eef06fc64e6bc1da83a1da890c08ca3432e17e267a"}, "quark": {:hex, :quark, "2.3.2", "066e0d431440d077684469967f54d732443ea2a48932e0916e974633e8b39c95", [:mix], [], "hexpm", "2f6423779b02afe7e3e4af3cfecfcd94572f2051664d4d8329ffa872d24b10a8"}, - "type_class": {:hex, :type_class, "1.2.7", "287a7982810c8f7fb0b8914f716b09cc675522846dc5d13b8b053662456dff4a", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}], "hexpm", "f9184803b6dcf3da4b9b3a15510498fc21566e8e2fe78f566238b7a02c973eee"}, + "type_class": {:hex, :type_class, "1.2.8", "349db84be8c664e119efaae1a09a44b113bc8e81af1d032f4e3e38feef4fac32", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}], "hexpm", "bb93de2cacfd6f0ee43f4616f7a139816a73deba4ae8ee3364bcfa4abe3eef3e"}, "witchcraft": {:hex, :witchcraft, "1.0.4", "8733ac0ee769d4d2f73610de5a2b601a4ccbe385d1fca6419280f2511d21d0c9", [:mix], [{:exceptional, "~> 2.1", [hex: :exceptional, repo: "hexpm", optional: false]}, {:operator, "~> 0.2", [hex: :operator, repo: "hexpm", optional: false]}, {:quark, "~> 2.2", [hex: :quark, repo: "hexpm", optional: false]}, {:type_class, "~> 1.2", [hex: :type_class, repo: "hexpm", optional: false]}], "hexpm", "a380f439f1962d2e56cdad874ed7eb4612ddd6ec5ee3c6ad0c5d63e60539e6b0"}, } From 8e21a267f91e45ace8863b865672fd517f84af1d Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:40:18 -0800 Subject: [PATCH 05/12] Set preferred_cli_env for :quality to :test By default, if MIX_ENV is unset, mix tasks run using the :dev environment. This is required to ensure that tests are run when calling `mix quality` with no explicit environment. --- mix.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/mix.exs b/mix.exs index 5664d58..10845cc 100644 --- a/mix.exs +++ b/mix.exs @@ -6,6 +6,7 @@ defmodule Algae.Mixfile do app: :algae, aliases: aliases(), deps: deps(), + preferred_cli_env: [quality: :test], # Versions version: "1.3.0", From f13bb40c329a623abd0e3fca5fd59fe4ca90d905 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:53:34 -0800 Subject: [PATCH 06/12] Add test/support/* to elixirc_paths This causes the test fixtures to be built at compile-time, and eliminates a deprecation warning in the call to Code.load_file/1 --- mix.exs | 4 ++++ test/{support.exs => support/example.ex} | 0 test/test_helper.exs | 1 - 3 files changed, 4 insertions(+), 1 deletion(-) rename test/{support.exs => support/example.ex} (100%) diff --git a/mix.exs b/mix.exs index 10845cc..7fb57fb 100644 --- a/mix.exs +++ b/mix.exs @@ -11,6 +11,7 @@ defmodule Algae.Mixfile do # Versions version: "1.3.0", elixir: "~> 1.9", + elixirc_paths: elixirc_paths(Mix.env()), # Docs name: "Algae", @@ -31,6 +32,9 @@ defmodule Algae.Mixfile do ] end + defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(_), do: ["lib"] + defp deps do [ {:credo, "~> 1.5", only: [:dev, :test], runtime: false}, diff --git a/test/support.exs b/test/support/example.ex similarity index 100% rename from test/support.exs rename to test/support/example.ex diff --git a/test/test_helper.exs b/test/test_helper.exs index 5d2d1e4..869559e 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,2 +1 @@ ExUnit.start() -Code.load_file("test/support.exs") From b58b52600dee112a07b8e33fd09e6ab1788de325 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:57:40 -0800 Subject: [PATCH 07/12] Fix unused literal warning in Algae.Reader doctest --- lib/algae/reader.ex | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/algae/reader.ex b/lib/algae/reader.ex index b91a173..03fcbf9 100644 --- a/lib/algae/reader.ex +++ b/lib/algae/reader.ex @@ -12,21 +12,21 @@ defmodule Algae.Reader do iex> use Witchcraft ...> - ...> correct = + iex> correct = ...> monad %Algae.Reader{} do ...> count <- ask &Map.get(&1, :count) ...> bindings <- ask() ...> return (count == Map.size(bindings)) ...> end ...> - ...> sample_bindings = %{count: 3, a: 1, b: 2} - ...> correct_count = run(correct, sample_bindings) - ...> "Correct count for #{inspect sample_bindings}? #{correct_count}" + iex> sample_bindings = %{count: 3, a: 1, b: 2} + iex> correct_count = run(correct, sample_bindings) + iex> "Correct count for #{inspect sample_bindings}? #{correct_count}" "Correct count for %{a: 1, b: 2, count: 3}? true" ...> - ...> bad_bindings = %{count: 100, a: 1, b: 2} - ...> bad_count = run(correct, bad_bindings) - ...> "Correct count for #{inspect bad_bindings}? #{bad_count}" + iex> bad_bindings = %{count: 100, a: 1, b: 2} + iex> bad_count = run(correct, bad_bindings) + iex> "Correct count for #{inspect bad_bindings}? #{bad_count}" "Correct count for %{a: 1, b: 2, count: 100}? false" Example adapted from From d5518fca0cdc4a4da3751fc18f977e48f7e0b032 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:58:40 -0800 Subject: [PATCH 08/12] Fix Map.size/1 deprecation warning --- lib/algae/reader.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/algae/reader.ex b/lib/algae/reader.ex index 03fcbf9..5e36724 100644 --- a/lib/algae/reader.ex +++ b/lib/algae/reader.ex @@ -16,7 +16,7 @@ defmodule Algae.Reader do ...> monad %Algae.Reader{} do ...> count <- ask &Map.get(&1, :count) ...> bindings <- ask() - ...> return (count == Map.size(bindings)) + ...> return (count == map_size(bindings)) ...> end ...> iex> sample_bindings = %{count: 3, a: 1, b: 2} From f686b93d2e832861b73302cba79bf42f59d19a70 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 21:59:55 -0800 Subject: [PATCH 09/12] Fix reference to undefined Algae.State.default/1 The default struct field referenced a private function. This raised compiler warnings anywhere the struct was initialized, however because the default is never called this was never triggered by tests. --- lib/algae/state.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/algae/state.ex b/lib/algae/state.ex index a9b5366..eee13df 100644 --- a/lib/algae/state.ex +++ b/lib/algae/state.ex @@ -76,7 +76,7 @@ defmodule Algae.State do defstruct [runner: &State.default/1] @spec default(any()) :: {integer(), any()} - defp default(s), do: {s, s} + def default(s), do: {s, s} @doc """ Construct a new `Algae.State` struct from a state runner in the form From 5bee338a3e66ae62a7d8e85a2b02f03926ebf535 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 22:03:43 -0800 Subject: [PATCH 10/12] Add `@moduledoc false` to test fixtures to resolve Credo warnings --- test/support/example.ex | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/support/example.ex b/test/support/example.ex index d6b70fe..70c5164 100644 --- a/test/support/example.ex +++ b/test/support/example.ex @@ -1,6 +1,8 @@ import Algae defmodule Example do + @moduledoc false + defdata Complex :: ([{:ok, integer()}] | number()) \\ 22 defdata Any :: any() @@ -8,10 +10,14 @@ defmodule Example do defdata None :: none() defmodule Embedded.One do + @moduledoc false + defdata do: quux :: any() \\ 22 end defmodule Embedded.Many do + @moduledoc false + defdata do first :: any() second :: integer() \\ 42 @@ -25,10 +31,14 @@ defmodule Example do end defmodule Simple do + @moduledoc false + defdata any() end defmodule Sum.Lights do + @moduledoc false + defsum do defdata Red :: any() \\ 22 defdata Yellow :: any() @@ -37,6 +47,8 @@ defmodule Example do end defmodule Sum.Maybe do + @moduledoc false + defsum do defdata Just do value :: any() @@ -47,6 +59,8 @@ defmodule Example do end defmodule Player do + @moduledoc false + # =============== # # Data Definition # # =============== # @@ -72,12 +86,16 @@ defmodule Example do end defmodule Id do + @moduledoc false + defdata any() end defdata Wrapper :: any() defmodule Person do + @moduledoc false + defdata do name :: String.t() age :: non_neg_integer() @@ -85,6 +103,8 @@ defmodule Example do end defmodule Animal do + @moduledoc false + defdata do name :: String.t() leg_count :: non_neg_integer() \\ 4 @@ -96,16 +116,22 @@ defmodule Example do end defmodule Constant do + @moduledoc false + defdata fun() def new(value), do: %Constant{constant: fn _ -> value end} end defmodule Nothing do + @moduledoc false + defdata none() end defmodule Light do + @moduledoc false + # ============== # # Sum Definition # # ============== # @@ -127,6 +153,8 @@ defmodule Example do end defmodule Pet do + @moduledoc false + defsum do defdata Cat do name :: String.t() @@ -141,6 +169,8 @@ defmodule Example do end defmodule Option do + @moduledoc false + defsum do defdata None :: none() defdata Some :: any() @@ -151,6 +181,8 @@ defmodule Example do defdata Video :: String.t() \\ "2001: A Space Odyssey" defmodule Media do + @moduledoc false + defsum do defdata Paper :: Example.Book.t() \\ Example.Book.new() defdata Film :: Example.Video.t() \\ Example.Video.new("A Clockwork Orange") From 0717d2f4258abaf28d6df51386bb018668cdfb82 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 22:05:39 -0800 Subject: [PATCH 11/12] Update .tool-versions --- .tool-versions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index d5fb44a..05efa3e 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -erlang 22.0.5 -elixir 1.9.4 +erlang 24.2 +elixir 1.13.2 \ No newline at end of file From 4b901dc02eaa965eb647700b5b39d6931d591c5c Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Fri, 28 Jan 2022 22:07:55 -0800 Subject: [PATCH 12/12] Bump patch version: 1.3.0 => 1.3.1 --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 7fb57fb..b16a55c 100644 --- a/mix.exs +++ b/mix.exs @@ -9,7 +9,7 @@ defmodule Algae.Mixfile do preferred_cli_env: [quality: :test], # Versions - version: "1.3.0", + version: "1.3.1", elixir: "~> 1.9", elixirc_paths: elixirc_paths(Mix.env()),