File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed
src/Console/Commands/Hooks Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 266
266
*/
267
267
'validate_paths ' => env ('GITHOOKS_VALIDATE_PATHS ' , true ),
268
268
269
+ /*
270
+ |--------------------------------------------------------------------------
271
+ | Analyzer chunk size
272
+ |--------------------------------------------------------------------------
273
+ |
274
+ | This configuration option allows you to set the number of files to be
275
+ | sent in chunks to the analyzers. Can also be set to 1 to send them
276
+ | one by one.
277
+ |
278
+ */
279
+ 'analyzer_chunk_size ' => env ('GITHOOKS_ANALYZER_CHUNK_SIZE ' , 100 ),
280
+
269
281
/*
270
282
|--------------------------------------------------------------------------
271
283
| Output errors
Original file line number Diff line number Diff line change @@ -191,12 +191,26 @@ public function getDockerContainer(): string
191
191
*/
192
192
protected function analizeCommittedFiles (Collection $ commitFiles ): self
193
193
{
194
- foreach ($ commitFiles as $ file ) {
195
- if (! $ this ->canFileBeAnalyzed ($ file )) {
194
+ $ chunkSize = config ('git-hooks.analyzer_chunk_size ' );
195
+
196
+ /** @var Collection<int, ChangedFile> $chunk */
197
+ foreach ($ commitFiles ->chunk ($ chunkSize ) as $ chunk ) {
198
+ $ filePaths = [];
199
+
200
+ /** @var ChangedFile $file */
201
+ foreach ($ chunk as $ file ) {
202
+ if (! $ this ->canFileBeAnalyzed ($ file )) {
203
+ continue ;
204
+ }
205
+
206
+ $ filePaths [] = $ file ->getFilePath ();
207
+ }
208
+
209
+ if (empty ($ filePaths )) {
196
210
continue ;
197
211
}
198
212
199
- $ filePath = $ file -> getFilePath ( );
213
+ $ filePath = implode ( ' ' , $ filePaths );
200
214
$ command = $ this ->dockerCommand ($ this ->analyzerCommand ().' ' .$ filePath );
201
215
202
216
$ params = [
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ public function defineEnvironment($app): void
52
52
'code_analyzers ' => [],
53
53
'artisan_path ' => base_path ('artisan ' ),
54
54
'output_errors ' => false ,
55
+ 'analyzer_chunk_size ' => 100 ,
55
56
'validate_paths ' => true ,
56
57
'automatically_fix_errors ' => false ,
57
58
'rerun_analyzer_after_autofix ' => false ,
You can’t perform that action at this time.
0 commit comments