Conditions | 11 |
Paths | 3 |
Total Lines | 49 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
69 | protected function prepareIndexes() |
||
70 | { |
||
71 | $originalState = SearchVariant::current_state(); |
||
72 | $dirtyIndexes = array(); |
||
73 | $dirty = $this->getSource(); |
||
74 | $indexes = FullTextSearch::get_indexes(); |
||
75 | $indexableService = IndexableService::singleton(); |
||
76 | foreach ($dirty as $base => $statefulids) { |
||
77 | if (!$statefulids) { |
||
78 | continue; |
||
79 | } |
||
80 | |||
81 | foreach ($statefulids as $statefulid) { |
||
82 | $state = $statefulid['state']; |
||
83 | $ids = $statefulid['ids']; |
||
84 | |||
85 | SearchVariant::activate_state($state); |
||
86 | |||
87 | // Ensure that indexes for all new / updated objects are included |
||
88 | $objs = DataObject::get($base)->byIDs(array_keys($ids)); |
||
89 | foreach ($objs as $obj) { |
||
90 | foreach ($ids[$obj->ID] as $index) { |
||
91 | if (!$indexes[$index]->variantStateExcluded($state)) { |
||
92 | // Remove any existing records from index if ShowInSearch is changed to false |
||
93 | if (!$indexableService->isIndexable($obj)) { |
||
94 | $indexes[$index]->delete($base, $obj->ID, $state); |
||
95 | } else { |
||
96 | $indexes[$index]->add($obj); |
||
97 | } |
||
98 | $dirtyIndexes[$index] = $indexes[$index]; |
||
99 | } |
||
100 | } |
||
101 | unset($ids[$obj->ID]); |
||
102 | } |
||
103 | |||
104 | // Generate list of records that do not exist and should be removed |
||
105 | foreach ($ids as $id => $fromindexes) { |
||
106 | foreach ($fromindexes as $index) { |
||
107 | if (!$indexes[$index]->variantStateExcluded($state)) { |
||
108 | $indexes[$index]->delete($base, $id, $state); |
||
109 | $dirtyIndexes[$index] = $indexes[$index]; |
||
110 | } |
||
111 | } |
||
112 | } |
||
113 | } |
||
114 | } |
||
115 | |||
116 | SearchVariant::activate_state($originalState); |
||
117 | return $dirtyIndexes; |
||
118 | } |
||
160 |
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