| Conditions | 5 |
| Paths | 7 |
| Total Lines | 80 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 32 | public function handle(): int |
||
| 33 | { |
||
| 34 | $this->info('Creating Manticore Search indexes...'); |
||
| 35 | |||
| 36 | $dropExisting = $this->option('drop'); |
||
| 37 | |||
| 38 | // Get connection details from config |
||
| 39 | $host = config('sphinxsearch.host', '127.0.0.1'); |
||
| 40 | $port = config('sphinxsearch.port', 9308); |
||
| 41 | |||
| 42 | // Create client |
||
| 43 | $this->client = new Client([ |
||
| 44 | 'host' => $host, |
||
| 45 | 'port' => $port, |
||
| 46 | ]); |
||
| 47 | |||
| 48 | // We'll skip checking for data_dir this way since it may not be accessible via API |
||
| 49 | // but instead provide better error handling during index creation |
||
| 50 | |||
| 51 | // If you encounter data_dir errors, ensure it's properly set in manticore.conf: |
||
| 52 | // data_dir = /path/to/data |
||
| 53 | // And make sure the path exists and has proper permissions |
||
| 54 | |||
| 55 | try { |
||
| 56 | $this->client->nodes()->status(); |
||
| 57 | } catch (\Exception $e) { |
||
| 58 | $this->error('Failed to connect to Manticore Search: '.$e->getMessage()); |
||
| 59 | $this->info('Please check if Manticore Search is running and properly configured.'); |
||
| 60 | |||
| 61 | return 1; |
||
| 62 | } |
||
| 63 | |||
| 64 | // Define indexes and their schema |
||
| 65 | $indexes = [ |
||
| 66 | 'releases_rt' => [ |
||
| 67 | 'settings' => [ |
||
| 68 | 'min_prefix_len' => 0, |
||
| 69 | 'min_infix_len' => 2, |
||
| 70 | ], |
||
| 71 | 'columns' => [ |
||
| 72 | 'name' => ['type' => 'text'], |
||
| 73 | 'searchname' => ['type' => 'text'], |
||
| 74 | 'fromname' => ['type' => 'text'], |
||
| 75 | 'filename' => ['type' => 'text'], |
||
| 76 | 'categories_id' => ['type' => 'text'], |
||
| 77 | 'dummy' => ['type' => 'integer', 'attribute' => true], |
||
| 78 | ], |
||
| 79 | ], |
||
| 80 | 'predb_rt' => [ |
||
| 81 | 'settings' => [ |
||
| 82 | 'min_prefix_len' => 0, |
||
| 83 | 'min_infix_len' => 2, |
||
| 84 | ], |
||
| 85 | 'columns' => [ |
||
| 86 | 'title' => ['type' => 'text', 'attribute' => true], |
||
| 87 | 'filename' => ['type' => 'text', 'attribute' => true], |
||
| 88 | 'dummy' => ['type' => 'integer', 'attribute' => true], |
||
| 89 | 'source' => ['type' => 'string', 'attribute' => true], |
||
| 90 | ], |
||
| 91 | ], |
||
| 92 | ]; |
||
| 93 | |||
| 94 | $hasErrors = false; |
||
| 95 | |||
| 96 | // Create each index |
||
| 97 | foreach ($indexes as $indexName => $schema) { |
||
| 98 | if (! $this->createIndex($indexName, $schema, $dropExisting)) { |
||
| 99 | $hasErrors = true; |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | if ($hasErrors) { |
||
| 104 | $this->error('Some errors occurred during index creation.'); |
||
| 105 | |||
| 106 | return 1; |
||
| 107 | } |
||
| 108 | |||
| 109 | $this->info('All Manticore Search indexes created successfully!'); |
||
| 110 | |||
| 111 | return 0; |
||
| 112 | } |
||
| 166 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths