@@ -212,17 +212,16 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
212212 TODO: example
213213
214214При разделении вызова функции на несколько строк аргументы функции сдвигаются
215- на ДВА отступа, закрывающая скобка — на один относительно строки с
216- открывающей. Открывающую скобку желательно ставить на той же строке, что и имя
215+ на один отступ. Открывающую скобку желательно ставить на той же строке, что и имя
217216функции. Желательно в этом случае писать каждый аргумент функции на новой
218217строке. Отступы в объявлении функции оформляются аналогично.
219218
220219 long_function_name(
221- with,
222- many,
223- many,
224- parameters
225- )
220+ with,
221+ many,
222+ many,
223+ parameters
224+ )
226225
227226Если при вызове функции ей передаётся единственный аргумент, и этот аргумент —
228227анонимная функция, создаваемая конструкцией ` function ` -` end ` непосредственно в
@@ -244,24 +243,24 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
2442431 )
245244
246245 assert(
247- action_handlers[ action.tool] ,
248- "unknown tool"
249- )(
250- manifest,
251- cluster_info,
252- param,
253- machine,
254- role_args,
255- action
256- )
246+ action_handlers[ action.tool] ,
247+ "unknown tool"
248+ )(
249+ manifest,
250+ cluster_info,
251+ param,
252+ machine,
253+ role_args,
254+ action
255+ )
257256
2582572 )
259258
260259 machine.installed_rocks_set, machine.duplicate_rocks_set
261260 = luarocks_parse_installed_rocks(
262261 remote_luarocks_list_installed_rocks(
263- machine.external_url
264- )
262+ machine.external_url
263+ )
265264 )
266265
2672663 ) Допускается свешивание ` .. ` при переносах:
@@ -281,25 +280,25 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
281280
282281 if
283282 long_function_name(
284- with,
285- many,
286- many,
287- parameters
288- ) == other_long_function(
289- the,
290- same
291- )
283+ with,
284+ many,
285+ many,
286+ parameters
287+ ) == other_long_function(
288+ the,
289+ same
290+ )
292291 then
293292 body
294293 end
295294
2962956 )
297296
298297 local func_name = function(
299- param1,
300- param2,
301- longname3
302- )
298+ param1,
299+ param2,
300+ longname3
301+ )
303302 body
304303 end
305304
@@ -405,7 +404,7 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
405404 log(
406405 "bar"
407406 .. " baz"
408- )
407+ )
409408
410409## Избыточный синтаксис
411410
@@ -542,17 +541,17 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
542541#### Штатная проверка аргументов
543542
544543 local is_log_enabled_raw = function(
545- modules_config,
546- levels_config,
547- module_name,
548- level
549- )
544+ modules_config,
545+ levels_config,
546+ module_name,
547+ level
548+ )
550549 arguments(
551- "table", levels_config,
552- "table", modules_config,
553- "string", module_name,
554- "number", level
555- )
550+ "table", levels_config,
551+ "table", modules_config,
552+ "string", module_name,
553+ "number", level
554+ )
556555 ...
557556 end
558557
@@ -561,8 +560,8 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
561560 local foo = function(bar)
562561 bar = bar or BAZ
563562 arguments(
564- "quo", bar
565- )
563+ "quo", bar
564+ )
566565
567566## Конструкторы таблиц
568567
@@ -693,11 +692,11 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
693692
694693 make_myobject = function(args)
695694 return setmetatable(
696- {
697- private_variable_ = 42;
698- },
699- mt;
700- )
695+ {
696+ private_variable_ = 42;
697+ },
698+ mt
699+ )
701700 end
702701 end
703702
@@ -893,10 +892,10 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
893892Не рекомендуется:
894893
895894 test:case "test-case-with-a-really-really-really-...-really-long-name" (
896- function()
897- ...
898- end
899- )
895+ function()
896+ ...
897+ end
898+ )
900899
901900Рекомендуется:
902901
@@ -912,10 +911,10 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
912911
913912 test:case "some-test-case"
914913 :with(temporary_directory("tmpdir", "tmp", "/long/long/path/to/dir")) (
915- function(env)
916- ...
917- end
918- )
914+ function(env)
915+ ...
916+ end
917+ )
919918
920919Тоже нежелательно (неправильный отступ у анонимной функции):
921920
@@ -929,12 +928,12 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
929928
930929 test:case "some-test-case"
931930 :with(
932- temporary_directory(
933- "tmpdir",
934- "tmp",
935- "/long/long/path/to/dir"
936- )
937- ) (function(env)
931+ temporary_directory(
932+ "tmpdir",
933+ "tmp",
934+ "/long/long/path/to/dir"
935+ )
936+ ) (function(env)
938937 ...
939938 end)
940939
@@ -969,19 +968,19 @@ need_*, should_*, must_*, in_*, not_*`` и т.п.
969968Пример:
970969
971970 ensure_returns(
972- "some check",
973- 2,
974- { false, "expected error" },
975- xpcall(
976- function()
977- error("expected error")
978- end,
979- function(msg)
980- log_error("foo failed:", debug.traceback(foo))
981- return foo
982- end
983- )
971+ "some check",
972+ 2,
973+ { false, "expected error" },
974+ xpcall(
975+ function()
976+ error("expected error")
977+ end,
978+ function(msg)
979+ log_error("foo failed:", debug.traceback(foo))
980+ return foo
981+ end
984982 )
983+ )
985984
986985## Устаревшие и запрещенные выражения языка
987986
@@ -1121,9 +1120,9 @@ error message, необходимо в обязательном порядке
11211120Неверно:
11221121
11231122 assert(
1124- a == b,
1125- "value of a: " .. tstr(a) .. " is not equal to value of b: " .. tstr(b)
1126- )
1123+ a == b,
1124+ "value of a: " .. tstr(a) .. " is not equal to value of b: " .. tstr(b)
1125+ )
11271126
11281127Верно:
11291128
0 commit comments