Skip to content

Commit

Permalink
Add :trigger to Credo.Check.Consistency.LineEndings
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Jul 31, 2022
1 parent 3046864 commit 1fdd569
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/credo/check/consistency/line_endings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,24 @@ defmodule Credo.Check.Consistency.LineEndings do
defp issues_for(expected, source_file, params) do
first_line_with_issue = @collector.first_line_with_issue(expected, source_file)

message =
case expected do
:unix ->
"File is using windows line endings while most of the files use unix line endings."

:windows ->
"File is using unix line endings while most of the files use windows line endings."
end

trigger =
case expected do
:unix -> "\r\n"
:windows -> "\n"
end

source_file
|> IssueMeta.for(params)
|> format_issue(message: message_for(expected), line_no: first_line_with_issue)
|> format_issue(message: message, line_no: first_line_with_issue, trigger: trigger)
|> List.wrap()
end

defp message_for(:unix = _expected) do
"File is using windows line endings while most of the files use unix line endings."
end

defp message_for(:windows = _expected) do
"File is using unix line endings while most of the files use windows line endings."
end
end

0 comments on commit 1fdd569

Please sign in to comment.