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 266266 */
267267 'validate_paths ' => env ('GITHOOKS_VALIDATE_PATHS ' , true ),
268268
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+
269281 /*
270282 |--------------------------------------------------------------------------
271283 | Output errors
Original file line number Diff line number Diff line change @@ -191,12 +191,26 @@ public function getDockerContainer(): string
191191 */
192192 protected function analizeCommittedFiles (Collection $ commitFiles ): self
193193 {
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 )) {
196210 continue ;
197211 }
198212
199- $ filePath = $ file -> getFilePath ( );
213+ $ filePath = implode ( ' ' , $ filePaths );
200214 $ command = $ this ->dockerCommand ($ this ->analyzerCommand ().' ' .$ filePath );
201215
202216 $ params = [
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ public function defineEnvironment($app): void
5252 'code_analyzers ' => [],
5353 'artisan_path ' => base_path ('artisan ' ),
5454 'output_errors ' => false ,
55+ 'analyzer_chunk_size ' => 100 ,
5556 'validate_paths ' => true ,
5657 'automatically_fix_errors ' => false ,
5758 'rerun_analyzer_after_autofix ' => false ,
You can’t perform that action at this time.
0 commit comments