Conditions | 2 |
Paths | 2 |
Total Lines | 179 |
Code Lines | 138 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
71 | public function populate(){ |
||
72 | $descriptions = array( |
||
73 | array( |
||
74 | 'groupId' => 0, |
||
75 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
76 | 'result' => 0, |
||
77 | 'match' => '', |
||
78 | 'description' => "", |
||
79 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_CLEAN |
||
80 | ), |
||
81 | |||
82 | array( |
||
83 | 'groupId' => 0, |
||
84 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
85 | 'result' => 1, |
||
86 | 'match' => '', |
||
87 | 'description' => "", |
||
88 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_INFECTED |
||
89 | ), |
||
90 | |||
91 | array( |
||
92 | 'groupId' => 0, |
||
93 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
94 | 'result' => 40, |
||
95 | 'match' => '', |
||
96 | 'description' => "Unknown option passed.", |
||
97 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
98 | ), |
||
99 | |||
100 | array( |
||
101 | 'groupId' => 0, |
||
102 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
103 | 'result' => 50, |
||
104 | 'match' => '', |
||
105 | 'description' => "Database initialization error.", |
||
106 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
107 | ), |
||
108 | |||
109 | array( |
||
110 | 'groupId' => 0, |
||
111 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
112 | 'result' => 52, |
||
113 | 'match' => '', |
||
114 | 'description' => "Not supported file type.", |
||
115 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
116 | ), |
||
117 | |||
118 | array( |
||
119 | 'groupId' => 0, |
||
120 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
121 | 'result' => 53, |
||
122 | 'match' => '', |
||
123 | 'description' => "Can't open directory.", |
||
124 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
125 | ), |
||
126 | |||
127 | array( |
||
128 | 'groupId' => 0, |
||
129 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
130 | 'result' => 54, |
||
131 | 'match' => '', |
||
132 | 'description' => "Can't open file. (ofm)", |
||
133 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
134 | ), |
||
135 | |||
136 | array( |
||
137 | 'groupId' => 0, |
||
138 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
139 | 'result' => 55, |
||
140 | 'match' => '', |
||
141 | 'description' => "Error reading file. (ofm)", |
||
142 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
143 | ), |
||
144 | |||
145 | array( |
||
146 | 'groupId' => 0, |
||
147 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
148 | 'result' => 56, |
||
149 | 'match' => '', |
||
150 | 'description' => "Can't stat input file / directory.", |
||
151 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
152 | ), |
||
153 | |||
154 | array( |
||
155 | 'groupId' => 0, |
||
156 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
157 | 'result' => 57, |
||
158 | 'match' => '', |
||
159 | 'description' => "Can't get absolute path name of current working directory.", |
||
160 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
161 | ), |
||
162 | |||
163 | array( |
||
164 | 'groupId' => 0, |
||
165 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
166 | 'result' => 58, |
||
167 | 'match' => '', |
||
168 | 'description' => "I/O error, please check your file system.", |
||
169 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
170 | ), |
||
171 | |||
172 | array( |
||
173 | 'groupId' => 0, |
||
174 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
175 | 'result' => 62, |
||
176 | 'match' => '', |
||
177 | 'description' => "Can't initialize logger.", |
||
178 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
179 | ), |
||
180 | |||
181 | array( |
||
182 | 'groupId' => 0, |
||
183 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
184 | 'result' => 63, |
||
185 | 'match' => '', |
||
186 | 'description' => "Can't create temporary files/directories (check permissions).", |
||
187 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
188 | ), |
||
189 | |||
190 | array( |
||
191 | 'groupId' => 0, |
||
192 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
193 | 'result' => 64, |
||
194 | 'match' => '', |
||
195 | 'description' => "Can't write to temporary directory (please specify another one).", |
||
196 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
197 | ), |
||
198 | |||
199 | array( |
||
200 | 'groupId' => 0, |
||
201 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
202 | 'result' => 70, |
||
203 | 'match' => '', |
||
204 | 'description' => "Can't allocate memory (calloc).", |
||
205 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
206 | ), |
||
207 | |||
208 | array( |
||
209 | 'groupId' => 0, |
||
210 | 'statusType' => Rule::RULE_TYPE_CODE, |
||
211 | 'result' => 71, |
||
212 | 'match' => '', |
||
213 | 'description' => "Can't allocate memory (malloc).", |
||
214 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
215 | ), |
||
216 | |||
217 | array( |
||
218 | 'groupId' => 0, |
||
219 | 'statusType' => Rule::RULE_TYPE_MATCH, |
||
220 | 'result' => 0, |
||
221 | 'match' => '/.*: OK$/', |
||
222 | 'description' => '', |
||
223 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_CLEAN |
||
224 | ), |
||
225 | |||
226 | array( |
||
227 | 'groupId' => 0, |
||
228 | 'statusType' => Rule::RULE_TYPE_MATCH, |
||
229 | 'result' => 0, |
||
230 | 'match' => '/.*: (.*) FOUND$/', |
||
231 | 'description' => '', |
||
232 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_INFECTED |
||
233 | ), |
||
234 | |||
235 | array( |
||
236 | 'groupId' => 0, |
||
237 | 'statusType' => Rule::RULE_TYPE_MATCH, |
||
238 | 'result' => 0, |
||
239 | 'match' => '/.*: (.*) ERROR$/', |
||
240 | 'description' => '', |
||
241 | 'status' => \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED |
||
242 | ), |
||
243 | ); |
||
244 | |||
245 | foreach ($descriptions as $description){ |
||
246 | $rule = Rule::fromParams($description); |
||
247 | $this->insert($rule); |
||
248 | } |
||
249 | } |
||
250 | } |
||
251 |