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

Use explicit negative ranges #1135

Merged
merged 1 commit into from
Jun 2, 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: 1 addition & 1 deletion lib/credo/check/config_comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ defmodule Credo.Check.ConfigComment do
defp value_for(param_string) do
if regex_value?(param_string) do
param_string
|> Credo.Backports.String.slice(1..-2)
|> Credo.Backports.String.slice(1..-2//-1)
|> Regex.compile!("i")
else
String.to_atom("Elixir.#{param_string}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defmodule Credo.Check.Consistency.MultiAliasImportRequireUse.Collector do
aliases =
case arguments do
[{:__aliases__, _, nested_modules}] when length(nested_modules) > 1 ->
base_name = Credo.Backports.Enum.slice(nested_modules, 0..-2)
base_name = Credo.Backports.Enum.slice(nested_modules, 0..-2//-1)
{:single, base_name}

[{{:., _, [{:__aliases__, _, _namespaces}, :{}]}, _, _nested_aliases}] ->
Expand Down
2 changes: 1 addition & 1 deletion lib/credo/check/warning/unused_function_return_helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ defmodule Credo.Check.Warning.UnusedFunctionReturnHelper do
when is_list(arguments) do
# IO.inspect(ast, label: "#{unquote(op)} (#{Macro.to_string(candidate)} #{acc})")

head_expression = Credo.Backports.Enum.slice(arguments, 0..-2)
head_expression = Credo.Backports.Enum.slice(arguments, 0..-2//-1)

if Credo.Code.contains_child?(head_expression, candidate) do
{nil, :VERIFIED}
Expand Down
12 changes: 6 additions & 6 deletions lib/credo/cli/command/diff/task/get_git_diff.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ defmodule Credo.CLI.Command.Diff.Task.GetGitDiff do
defp run_credo_on_dir(exec, dirname, previous_git_ref, given_ref) do
{previous_argv, _last_arg} =
exec.argv
|> Credo.Backports.Enum.slice(1..-1)
|> Credo.Backports.Enum.slice(1..-1//-1)
|> Enum.reduce({[], nil}, fn
_, {argv, "--working-dir"} -> {Credo.Backports.Enum.slice(argv, 1..-2), nil}
_, {argv, "--from-git-merge-base"} -> {Credo.Backports.Enum.slice(argv, 1..-2), nil}
_, {argv, "--from-git-ref"} -> {Credo.Backports.Enum.slice(argv, 1..-2), nil}
_, {argv, "--from-dir"} -> {Credo.Backports.Enum.slice(argv, 1..-2), nil}
_, {argv, "--since"} -> {Credo.Backports.Enum.slice(argv, 1..-2), nil}
_, {argv, "--working-dir"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
_, {argv, "--from-git-merge-base"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
_, {argv, "--from-git-ref"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
_, {argv, "--from-dir"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
_, {argv, "--since"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
"--show-fixed", {argv, _last_arg} -> {argv, nil}
"--show-kept", {argv, _last_arg} -> {argv, nil}
^previous_git_ref, {argv, _last_arg} -> {argv, nil}
Expand Down
2 changes: 1 addition & 1 deletion lib/credo/cli/command/explain/output/default.ex
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ defmodule Credo.CLI.Command.Explain.Output.Default do
|> String.trim()
|> String.split("\n")
|> Enum.flat_map(&format_explanation(&1, outer_color))
|> Credo.Backports.Enum.slice(0..-2)
|> Credo.Backports.Enum.slice(0..-2//-1)
|> UI.puts()

UI.puts_edge([outer_color, :faint])
Expand Down
Loading