Skip to content

Commit 5891264

Browse files
committed
Add explicit steps and remove Backports module
1 parent 3651e33 commit 5891264

File tree

10 files changed

+19
-44
lines changed

10 files changed

+19
-44
lines changed

lib/credo/backports.ex

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/credo/check/config_comment.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ defmodule Credo.Check.ConfigComment do
135135
defp value_for(param_string) do
136136
if regex_value?(param_string) do
137137
param_string
138-
|> Credo.Backports.String.slice(1..-2//-1)
138+
|> String.slice(1..-2//1)
139139
|> Regex.compile!("i")
140140
else
141141
String.to_atom("Elixir.#{param_string}")

lib/credo/check/consistency/multi_alias_import_require_use/collector.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ defmodule Credo.Check.Consistency.MultiAliasImportRequireUse.Collector do
4242
aliases =
4343
case arguments do
4444
[{:__aliases__, _, nested_modules}] when length(nested_modules) > 1 ->
45-
base_name = Credo.Backports.Enum.slice(nested_modules, 0..-2//-1)
45+
base_name = Enum.slice(nested_modules, 0..-2//1)
4646
{:single, base_name}
4747

4848
[{{:., _, [{:__aliases__, _, _namespaces}, :{}]}, _, _nested_aliases}] ->

lib/credo/check/consistency/space_around_operators.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ defmodule Credo.Check.Consistency.SpaceAroundOperators do
139139

140140
defp number_in_range?(line, column) do
141141
line
142-
|> Credo.Backports.String.slice(column..-1)
142+
|> String.slice(column..-1//1)
143143
|> String.match?(~r/^\d+\.\./)
144144
end
145145

@@ -166,13 +166,13 @@ defmodule Credo.Check.Consistency.SpaceAroundOperators do
166166
# -1 because we need to subtract the operator
167167
binary_pattern_end_after? =
168168
line
169-
|> Credo.Backports.String.slice(column..-1)
169+
|> String.slice(column..-1//1)
170170
|> String.match?(~r/\>\>/)
171171

172172
# -1 because we need to subtract the operator
173173
typed_after? =
174174
line
175-
|> Credo.Backports.String.slice(column..-1)
175+
|> String.slice(column..-1//1)
176176
|> String.match?(~r/^\s*(integer|native|signed|unsigned|binary|size|little|float)/)
177177

178178
# -2 because we need to subtract the operator

lib/credo/check/readability/large_numbers.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ defmodule Credo.Check.Readability.LargeNumbers do
181181
Enum.map(allowed_trailing_digits, fn trailing_digits ->
182182
if String.length(string) > trailing_digits do
183183
base =
184-
Credo.Backports.String.slice(string, 0..(-1 * trailing_digits - 1))
184+
String.slice(string, 0..(-1 * trailing_digits - 1)//1)
185185
|> String.reverse()
186186
|> String.replace(~r/(\d{3})(?=\d)/, "\\1_")
187187
|> String.reverse()
188188

189-
trailing = Credo.Backports.String.slice(string, (-1 * trailing_digits)..-1)
189+
trailing = String.slice(string, (-1 * trailing_digits)..-1//1)
190190

191191
"#{base}_#{trailing}"
192192
end
@@ -236,7 +236,7 @@ defmodule Credo.Check.Readability.LargeNumbers do
236236

237237
ending_of_number =
238238
~r/^([0-9_\.]+)/
239-
|> Regex.run(Credo.Backports.String.slice(line, (column1 + 1)..-1))
239+
|> Regex.run(String.slice(line, (column1 + 1)..-1//1))
240240
|> List.wrap()
241241
|> List.last()
242242
|> to_string()

lib/credo/check/readability/parentheses_on_zero_arity_defs.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ defmodule Credo.Check.Readability.ParenthesesOnZeroArityDefs do
8989
name_size = text |> to_string |> String.length()
9090
skip = (SourceFile.column(source_file, line_no, text) || -1) + name_size - 1
9191

92-
Credo.Backports.String.slice(line, skip..-1)
92+
String.slice(line, skip..-1//1)
9393
end
9494

9595
defp issue_for(issue_meta, name, line_no, kind) do

lib/credo/check/warning/unused_function_return_helper.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ defmodule Credo.Check.Warning.UnusedFunctionReturnHelper do
132132
when is_list(arguments) do
133133
# IO.inspect(ast, label: "#{unquote(op)} (#{Macro.to_string(candidate)} #{acc})")
134134

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

137137
if Credo.Code.contains_child?(head_expression, candidate) do
138138
{nil, :VERIFIED}

lib/credo/cli/command/diff/task/get_git_diff.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ defmodule Credo.CLI.Command.Diff.Task.GetGitDiff do
104104
defp run_credo_on_dir(exec, dirname, previous_git_ref, given_ref) do
105105
{previous_argv, _last_arg} =
106106
exec.argv
107-
|> Credo.Backports.Enum.slice(1..-1//-1)
107+
|> Enum.slice(1..-1//1)
108108
|> Enum.reduce({[], nil}, fn
109-
_, {argv, "--working-dir"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
110-
_, {argv, "--from-git-merge-base"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
111-
_, {argv, "--from-git-ref"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
112-
_, {argv, "--from-dir"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
113-
_, {argv, "--since"} -> {Credo.Backports.Enum.slice(argv, 1..-2//-1), nil}
109+
_, {argv, "--working-dir"} -> {Enum.slice(argv, 1..-2//1), nil}
110+
_, {argv, "--from-git-merge-base"} -> {Enum.slice(argv, 1..-2//1), nil}
111+
_, {argv, "--from-git-ref"} -> {Enum.slice(argv, 1..-2//1), nil}
112+
_, {argv, "--from-dir"} -> {Enum.slice(argv, 1..-2//1), nil}
113+
_, {argv, "--since"} -> {Enum.slice(argv, 1..-2//1), nil}
114114
"--show-fixed", {argv, _last_arg} -> {argv, nil}
115115
"--show-kept", {argv, _last_arg} -> {argv, nil}
116116
^previous_git_ref, {argv, _last_arg} -> {argv, nil}

lib/credo/cli/command/explain/output/default.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ defmodule Credo.CLI.Command.Explain.Output.Default do
269269
|> String.trim()
270270
|> String.split("\n")
271271
|> Enum.flat_map(&format_explanation(&1, outer_color))
272-
|> Credo.Backports.Enum.slice(0..-2//-1)
272+
|> Enum.slice(0..-2//1)
273273
|> UI.puts()
274274

275275
UI.puts_edge([outer_color, :faint])

lib/credo/code/interpolation_helper.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ defmodule Credo.Code.InterpolationHelper do
5858
line = String.to_charlist(line)
5959
part1 = Enum.slice(line, 0, col_start - 1)
6060
part2 = String.to_charlist(String.duplicate(char, length))
61-
part3 = Credo.Backports.Enum.slice(line, (col_end - 1)..-1)
61+
part3 = Enum.slice(line, (col_end - 1)..-1//1)
6262
List.to_string(part1 ++ part2 ++ part3)
6363
end
6464

@@ -271,6 +271,6 @@ defmodule Credo.Code.InterpolationHelper do
271271
# col-1 to account for col being 1-based
272272
start = max(col_end - 1, 0)
273273

274-
Credo.Backports.String.slice(line, start..-1)
274+
String.slice(line, start..-1)
275275
end
276276
end

0 commit comments

Comments
 (0)