Skip to content

Commit dc50788

Browse files
websisds
authored andcommitted
Increase performance of PhpCs pre commit hook
1 parent 97e8610 commit dc50788

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/overcommit/hook/pre_commit/php_cs.rb

+6-13
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,14 @@ class PhpCs < Base
1212
def run
1313
messages = []
1414

15-
applicable_files.each do |file|
16-
result = execute(command, args: [file])
17-
if result.status
18-
rows = result.stdout.split("\n")
19-
20-
# Discard the csv header
21-
rows.shift
22-
23-
# Push each of the errors in the particular file into the array
24-
rows.map do |row|
25-
messages << row
26-
end
27-
end
15+
result = execute(command, args: applicable_files)
16+
if result.status
17+
messages = result.stdout.split("\n")
18+
# Discard the csv header
19+
messages.shift
2820
end
2921

22+
return :fail if messages.empty? && !result.success?
3023
return :pass if messages.empty?
3124

3225
parse_messages(messages)

0 commit comments

Comments
 (0)