Skip to content

Commit 32f80d9

Browse files
committed
[luacheck] support more options
1 parent f189989 commit 32f80d9

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.codeclimate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ engines:
3131
- new
3232
only:
3333
- new
34+
max_cyclomatic_complexity: 3
3435
checks:
3536
global:
3637
enabled: false

bin/engine-luacheck

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ checks.each do |name, value|
6161
end
6262
end
6363

64+
LENGTH_OPTIONS = %w(max_line_length max_code_line_length max_string_line_length max_comment_line_length max_cyclomatic_complexity)
65+
66+
length_options = LENGTH_OPTIONS.map do |name|
67+
value = options.fetch(name, nil)
68+
opt = name.tr('_', '-')
69+
70+
case value
71+
when nil then next
72+
when false then "--no-#{opt}"
73+
when Numeric then [ "--#{opt}", value.to_s ]
74+
else warn "Unknown value #{value} (#{value.class}) for option #{name}"
75+
end
76+
end
77+
6478
ARRAY_OPTIONS = %w(globals read_globals new_globals new_read_globals not_globals ignore enable only)
6579

6680
array_options = ARRAY_OPTIONS.map do |name|
@@ -107,7 +121,15 @@ Find.find(*existing_paths) do |path|
107121
end
108122
end
109123

110-
cmd = ['luacheck', *check_options.compact, *boolean_options.compact, *array_options.compact.flatten, '--formatter', 'codeclimate', *files ]
124+
cmd = [
125+
'luacheck',
126+
*check_options.compact,
127+
*boolean_options.compact,
128+
*length_options.compact.flatten,
129+
*array_options.compact.flatten,
130+
'--formatter', 'codeclimate',
131+
*files
132+
]
111133
warn Shellwords.join(cmd)
112134

113135
IO.popen(cmd) do |io|

0 commit comments

Comments
 (0)