Skip to content

Commit

Permalink
Rename module attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
NJichev committed May 2, 2024
1 parent d8011ee commit 450f9e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/credo/check/warning/leaky_environment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Credo.Check.Warning.LeakyEnvironment do
Credo.Code.prewalk(source_file, &traverse(&1, &2, issue_meta))
end

@offset 2
@colon_and_dot_length 2
defp traverse({{:., _, call}, meta, args} = ast, issues, issue_meta) do
case get_forbidden_call(call, args) do
nil ->
Expand All @@ -39,7 +39,7 @@ defmodule Credo.Check.Warning.LeakyEnvironment do
trigger ->
[module, _function] = call
len = module |> Atom.to_string() |> String.length()
column = meta[:column] - len - @offset
column = meta[:column] - len - @colon_and_dot_length
meta = Keyword.put(meta, :column, column)

{ast, [issue_for(issue_meta, meta, trigger) | issues]}
Expand Down
5 changes: 2 additions & 3 deletions lib/credo/check/warning/unsafe_exec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ defmodule Credo.Check.Warning.UnsafeExec do
nil
end

# offset 2 characters for the dot call and the atom syntax
@offset 2
@colon_and_dot_length 2
defp issue_for(call, suggestion, trigger, meta, module, issue_meta) do
len = module |> Atom.to_string() |> String.length()
column = meta[:column] - len - @offset
column = meta[:column] - len - @colon_and_dot_length

format_issue(issue_meta,
message: "Prefer #{suggestion} over #{call} to prevent command injection.",
Expand Down

0 comments on commit 450f9e9

Please sign in to comment.