Skip to content
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: 1 addition & 1 deletion lib/elixir/lib/agent.ex
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ defmodule Agent do
@doc false
defmacro __using__(opts) do
quote location: :keep, bind_quoted: [opts: opts] do
unless Module.has_attribute?(__MODULE__, :doc) do
if not Module.has_attribute?(__MODULE__, :doc) do
@doc """
Returns a specification to start this module under a supervisor.

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/calendar/time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ defmodule Time do
do: unit > 0,
else: unit in ~w(second millisecond microsecond nanosecond)a

unless valid? do
if not valid? do
raise ArgumentError,
"unsupported time unit. Expected :hour, :minute, :second, :millisecond, :microsecond, :nanosecond, or a positive integer, got #{inspect(unit)}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ defmodule Config do
"""
@doc since: "1.9.0"
def config(root_key, opts) when is_atom(root_key) and is_list(opts) do
unless Keyword.keyword?(opts) do
if not Keyword.keyword?(opts) do
raise ArgumentError, "config/2 expected a keyword list, got: #{inspect(opts)}"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/dynamic_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ defmodule DynamicSupervisor do
defmacro __using__(opts) do
quote location: :keep, bind_quoted: [opts: opts] do
@behaviour DynamicSupervisor
unless Module.has_attribute?(__MODULE__, :doc) do
if not Module.has_attribute?(__MODULE__, :doc) do
@doc """
Returns a specification to start this module under a supervisor.

Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/lib/gen_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ defmodule GenServer do
quote location: :keep, bind_quoted: [opts: opts] do
@behaviour GenServer

unless Module.has_attribute?(__MODULE__, :doc) do
if not Module.has_attribute?(__MODULE__, :doc) do
@doc """
Returns a specification to start this module under a supervisor.

Expand Down Expand Up @@ -945,7 +945,7 @@ defmodule GenServer do
end

defmacro __before_compile__(env) do
unless Module.defines?(env.module, {:init, 1}) do
if not Module.defines?(env.module, {:init, 1}) do
message = """
function init/1 required by behaviour GenServer is not implemented \
(in module #{inspect(env.module)}).
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/io/ansi/docs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ defmodule IO.ANSI.Docs do
|> String.split(@spaces)
|> write_with_wrap(options[:width] - byte_size(indent), indent, no_wrap, prefix)

unless no_wrap, do: newline_after_block(options)
if !no_wrap, do: newline_after_block(options)
end

defp format_text(text, options) do
Expand Down
14 changes: 7 additions & 7 deletions lib/elixir/lib/kernel/typespec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ defmodule Kernel.Typespec do
case spec_to_signature(expr) do
{name, arity} ->
# store doc only once in case callback has multiple clauses
unless :ets.member(set, {kind, name, arity}) do
if not :ets.member(set, {kind, name, arity}) do
{line, doc} = get_doc_info(set, :doc, line)
store_doc(set, kind, name, arity, line, :doc, doc, %{})
end
Expand Down Expand Up @@ -320,7 +320,7 @@ defmodule Kernel.Typespec do

invalid_args = :lists.filter(&(not valid_variable_ast?(&1)), args)

unless invalid_args == [] do
if invalid_args != [] do
invalid_args = :lists.join(", ", :lists.map(&Macro.to_string/1, invalid_args))

message =
Expand Down Expand Up @@ -380,7 +380,7 @@ defmodule Kernel.Typespec do
ensure_no_defaults!(args)
state = clean_local_state(state)

unless Keyword.keyword?(guard) do
if not Keyword.keyword?(guard) do
error = "expected keywords as guard in type specification, got: #{Macro.to_string(guard)}"
compile_error(caller, error)
end
Expand Down Expand Up @@ -573,7 +573,7 @@ defmodule Kernel.Typespec do
|> Map.delete(:__struct__)
|> Map.to_list()

unless Keyword.keyword?(fields) do
if not Keyword.keyword?(fields) do
compile_error(caller, "expected key-value pairs in struct #{Macro.to_string(name)}")
end

Expand All @@ -587,7 +587,7 @@ defmodule Kernel.Typespec do
)

fun = fn {field, _} ->
unless Keyword.has_key?(struct, field) do
if not Keyword.has_key?(struct, field) do
compile_error(
caller,
"undefined field #{inspect(field)} on struct #{inspect(module)}"
Expand Down Expand Up @@ -630,7 +630,7 @@ defmodule Kernel.Typespec do
)

fun = fn {field, _} ->
unless Keyword.has_key?(fields, field) do
if not Keyword.has_key?(fields, field) do
compile_error(caller, "undefined field #{field} on record #{inspect(tag)}")
end
end
Expand Down Expand Up @@ -754,7 +754,7 @@ defmodule Kernel.Typespec do
) do
remote = Module.get_attribute(caller.module, attr)

unless is_atom(remote) and remote != nil do
if not (is_atom(remote) and remote != nil) do
message =
"invalid remote in typespec: #{Macro.to_string(orig)} (@#{attr} is #{inspect(remote)})"

Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/lib/macro.ex
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,8 @@ defmodule Macro do
defp find_invalid(bin) when is_binary(bin), do: nil

defp find_invalid(fun) when is_function(fun) do
unless Function.info(fun, :env) == {:env, []} and
Function.info(fun, :type) == {:type, :external} do
if Function.info(fun, :env) != {:env, []} or
Function.info(fun, :type) != {:type, :external} do
{:error, fun}
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/lib/module.ex
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ defmodule Module do
end

def create(module, quoted, opts) when is_atom(module) and is_list(opts) do
unless Keyword.has_key?(opts, :file) do
if not Keyword.has_key?(opts, :file) do
raise ArgumentError, "expected :file to be given as option"
end

Expand Down Expand Up @@ -2260,7 +2260,7 @@ defmodule Module do
end

defp preprocess_attribute(:nifs, value) do
unless function_arity_list?(value) do
if not function_arity_list?(value) do
raise ArgumentError,
"@nifs is a built-in module attribute for specifying a list " <>
"of functions and their arities that are NIFs, got: #{inspect(value)}"
Expand Down
14 changes: 7 additions & 7 deletions lib/elixir/lib/partition_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -228,26 +228,26 @@ defmodule PartitionSupervisor do
def start_link(opts) when is_list(opts) do
name = opts[:name]

unless name do
if !name do
raise ArgumentError, "the :name option must be given to PartitionSupervisor"
end

{child_spec, opts} = Keyword.pop(opts, :child_spec)

unless child_spec do
if !child_spec do
raise ArgumentError, "the :child_spec option must be given to PartitionSupervisor"
end

{partitions, opts} = Keyword.pop(opts, :partitions, System.schedulers_online())

unless is_integer(partitions) and partitions >= 1 do
if not (is_integer(partitions) and partitions >= 1) do
raise ArgumentError,
"the :partitions option must be a positive integer, got: #{inspect(partitions)}"
end

{with_arguments, opts} = Keyword.pop(opts, :with_arguments, fn args, _partition -> args end)

unless is_function(with_arguments, 2) do
if not is_function(with_arguments, 2) do
raise ArgumentError,
"the :with_arguments option must be a function that receives two arguments, " <>
"the current call arguments and the partition, got: #{inspect(with_arguments)}"
Expand All @@ -260,7 +260,7 @@ defmodule PartitionSupervisor do
for partition <- 0..(partitions - 1) do
args = with_arguments.(args, partition)

unless is_list(args) do
if not is_list(args) do
raise "the call to the function in :with_arguments must return a list, got: #{inspect(args)}"
end

Expand All @@ -270,7 +270,7 @@ defmodule PartitionSupervisor do

auto_shutdown = Keyword.get(opts, :auto_shutdown, :never)

unless auto_shutdown == :never do
if auto_shutdown != :never do
raise ArgumentError,
"the :auto_shutdown option must be :never, got: #{inspect(auto_shutdown)}"
end
Expand Down Expand Up @@ -319,7 +319,7 @@ defmodule PartitionSupervisor do
defp init_partitions({:via, _, _}, partitions) do
child_spec = {Registry, keys: :unique, name: @registry}

unless Process.whereis(@registry) do
if !Process.whereis(@registry) do
Supervisor.start_child(:elixir_sup, child_spec)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ defmodule Protocol do
# Inline struct implementation for performance
@compile {:inline, struct_impl_for: 1}

unless Module.defines_type?(__MODULE__, {:t, 0}) do
if not Module.defines_type?(__MODULE__, {:t, 0}) do
@typedoc """
All the types that implement this protocol.
"""
Expand Down
12 changes: 6 additions & 6 deletions lib/elixir/lib/registry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ defmodule Registry do
def start_link(options) do
keys = Keyword.get(options, :keys)

unless keys in @keys do
if keys not in @keys do
raise ArgumentError,
"expected :keys to be given and be one of :unique or :duplicate, got: #{inspect(keys)}"
end
Expand All @@ -350,27 +350,27 @@ defmodule Registry do

meta = Keyword.get(options, :meta, [])

unless Keyword.keyword?(meta) do
if not Keyword.keyword?(meta) do
raise ArgumentError, "expected :meta to be a keyword list, got: #{inspect(meta)}"
end

partitions = Keyword.get(options, :partitions, 1)

unless is_integer(partitions) and partitions >= 1 do
if not (is_integer(partitions) and partitions >= 1) do
raise ArgumentError,
"expected :partitions to be a positive integer, got: #{inspect(partitions)}"
end

listeners = Keyword.get(options, :listeners, [])

unless is_list(listeners) and Enum.all?(listeners, &is_atom/1) do
if not (is_list(listeners) and Enum.all?(listeners, &is_atom/1)) do
raise ArgumentError,
"expected :listeners to be a list of named processes, got: #{inspect(listeners)}"
end

compressed = Keyword.get(options, :compressed, false)

unless is_boolean(compressed) do
if not is_boolean(compressed) do
raise ArgumentError,
"expected :compressed to be a boolean, got: #{inspect(compressed)}"
end
Expand Down Expand Up @@ -1433,7 +1433,7 @@ defmodule Registry do
end

defp unlink_if_unregistered(pid_server, pid_ets, self) do
unless :ets.member(pid_ets, self) do
if not :ets.member(pid_ets, self) do
Process.unlink(pid_server)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/elixir/lib/stream/reducers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ defmodule Stream.Reducers do
defmacro reject(callback, fun \\ nil) do
quote do
fn entry, acc ->
unless unquote(callback).(entry) do
next(unquote(fun), entry, acc)
else
if unquote(callback).(entry) do
skip(acc)
else
next(unquote(fun), entry, acc)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ defmodule Supervisor do
import Supervisor.Spec
@behaviour Supervisor

unless Module.has_attribute?(__MODULE__, :doc) do
if not Module.has_attribute?(__MODULE__, :doc) do
@doc """
Returns a specification to start this module under a supervisor.

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/supervisor/spec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ defmodule Supervisor.Spec do
) :: {:ok, tuple}
@deprecated "Use the new child specifications outlined in the Supervisor module instead"
def supervise(children, options) do
unless strategy = options[:strategy] do
if !(strategy = options[:strategy]) do
raise ArgumentError, "expected :strategy option to be given"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ defmodule System do
def cmd(command, args, opts \\ []) when is_binary(command) and is_list(args) do
assert_no_null_byte!(command, "System.cmd/3")

unless Enum.all?(args, &is_binary/1) do
if not Enum.all?(args, &is_binary/1) do
raise ArgumentError, "all arguments for System.cmd/3 must be binaries"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/task.ex
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ defmodule Task do
@doc false
defmacro __using__(opts) do
quote location: :keep, bind_quoted: [opts: opts] do
unless Module.has_attribute?(__MODULE__, :doc) do
if not Module.has_attribute?(__MODULE__, :doc) do
@doc """
Returns a specification to start this module under a supervisor.

Expand Down
6 changes: 3 additions & 3 deletions lib/elixir/lib/task/supervised.ex
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ defmodule Task.Supervised do
ordered = Keyword.get(options, :ordered, true)
zip_input_on_exit = Keyword.get(options, :zip_input_on_exit, false)

unless is_integer(max_concurrency) and max_concurrency > 0 do
if not (is_integer(max_concurrency) and max_concurrency > 0) do
raise ArgumentError, ":max_concurrency must be an integer greater than zero"
end

unless on_timeout in [:exit, :kill_task] do
if on_timeout not in [:exit, :kill_task] do
raise ArgumentError, ":on_timeout must be either :exit or :kill_task"
end

unless (is_integer(timeout) and timeout >= 0) or timeout == :infinity do
if not ((is_integer(timeout) and timeout >= 0) or timeout == :infinity) do
raise ArgumentError, ":timeout must be either a positive integer or :infinity"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/task/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ defmodule Task.Supervisor do
defp build_stream(supervisor, link_type, enumerable, fun, options) do
shutdown = Keyword.get(options, :shutdown, 5000)

unless (is_integer(shutdown) and shutdown >= 0) or shutdown == :brutal_kill do
if not ((is_integer(shutdown) and shutdown >= 0) or shutdown == :brutal_kill) do
raise ArgumentError, ":shutdown must be either a positive integer or :brutal_kill"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/scripts/diff.exs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ defmodule Diff do
end

defp assert_dir!(dir) do
unless File.dir?(dir) do
if not File.dir?(dir) do
raise ArgumentError, "#{inspect(dir)} is not a directory"
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/test/elixir/file_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ defmodule FileTest do
stat = File.stat!(fixture)
assert stat.mode == 0o100666

unless windows?() do
if not windows?() do
assert File.chmod(fixture, 0o100777) == :ok
stat = File.stat!(fixture)
assert stat.mode == 0o100777
Expand All @@ -1814,7 +1814,7 @@ defmodule FileTest do
stat = File.stat!(fixture)
assert stat.mode == 0o100666

unless windows?() do
if not windows?() do
assert File.chmod!(fixture, 0o100777) == :ok
stat = File.stat!(fixture)
assert stat.mode == 0o100777
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/cli_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ defmodule Kernel.CLI.ExecutableTest do
System.cmd(elixir_executable(context.cli_extension), ["-e", "Time.new!(0, 0, 0)"])

# TODO: remove this once we bump CI to 26.3
unless windows?() and System.otp_release() == "26" do
if not (windows?() and System.otp_release() == "26") do
{output, 0} =
System.cmd(iex_executable(context.cli_extension), [
"--eval",
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/dialyzer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule Kernel.DialyzerTest do
|> String.to_charlist()

# Some OSs (like Windows) do not provide the HOME environment variable.
unless System.get_env("HOME") do
if !System.get_env("HOME") do
System.put_env("HOME", System.user_home())
end

Expand Down
Loading