Skip to content

Commit 476f04a

Browse files
albertoreddragonwasrobot
authored andcommitted
[Patch] do not allow negative padding (#49)
With long file names padding in `String.duplicate("-", padding)` can become negative
1 parent f675064 commit 476f04a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/js2e.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ defmodule JS2E do
153153
|> String.downcase
154154

155155
padding = String.duplicate("-",
156-
74 - String.length(pretty_warning_type) - String.length(file_path))
156+
max(0, 74 - String.length(pretty_warning_type) - String.length(file_path)))
157157

158158
warnings
159159
|> Enum.each(fn warning ->
@@ -183,7 +183,7 @@ defmodule JS2E do
183183
|> String.upcase
184184

185185
padding = String.duplicate("-",
186-
74 - String.length(pretty_error_type) - String.length(file_path))
186+
max(0, 74 - String.length(pretty_error_type) - String.length(file_path)))
187187

188188
errors
189189
|> Enum.each(fn error ->
@@ -215,7 +215,7 @@ defmodule JS2E do
215215
|> String.upcase
216216

217217
padding = String.duplicate("-",
218-
74 - String.length(pretty_error_type) - String.length(file_path))
218+
max(0, 74 - String.length(pretty_error_type) - String.length(file_path)))
219219

220220
errors
221221
|> Enum.each(fn error ->

0 commit comments

Comments
 (0)