| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Code Lines | 8 |
| 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 |
||
| 136 | protected function getCheckIgnoreConfig() |
||
| 137 | { |
||
| 138 | $allowedHosts = json_encode($this->notifierOptions['allowed_js_hosts']); |
||
| 139 | $customCheckIgnoreFunction = $this->checkIgnoreFunctionProvider->getCheckIgnoreFunctionCode(); |
||
| 140 | |||
| 141 | return <<<END_HTML |
||
| 142 | (function(Rollbar) { |
||
| 143 | var allowedHosts = {$allowedHosts}; |
||
| 144 | var customCheckIgnoreFunction = {$customCheckIgnoreFunction}; |
||
| 145 | if (allowedHosts.length === 0) { |
||
| 146 | allowedHosts.push(window.location.origin); |
||
| 147 | } |
||
| 148 | |||
| 149 | function isFromAllowedHosts(filename) { |
||
| 150 | for (var i = 0; i < allowedHosts.length; i++) { |
||
| 151 | if (filename.match(allowedHosts[i])) { |
||
| 152 | return true; |
||
| 153 | } |
||
| 154 | } |
||
| 155 | |||
| 156 | return false; |
||
| 157 | } |
||
| 158 | |||
| 159 | function isLogMessage(payload) { |
||
| 160 | try { |
||
| 161 | if (payload.data.body.message !== undefined) { |
||
| 162 | return true; |
||
| 163 | } |
||
| 164 | } catch (e) { |
||
| 165 | } |
||
| 166 | |||
| 167 | return false; |
||
| 168 | } |
||
| 169 | |||
| 170 | function ignoreRemoteUncaught(isUncaught, args, payload) { |
||
| 171 | try { |
||
| 172 | if (typeof customCheckIgnoreFunction === 'function' && customCheckIgnoreFunction(isUncaught, args, payload)) { |
||
| 173 | return true; |
||
| 174 | } |
||
| 175 | |||
| 176 | //this prevents breaking simple string reporting |
||
| 177 | if (isLogMessage(payload)) { |
||
| 178 | return false; |
||
| 179 | } |
||
| 180 | |||
| 181 | var filename = payload.data.body.trace.frames[0].filename; |
||
| 182 | if (isUncaught && !isFromAllowedHosts(filename)) { |
||
| 183 | return true; |
||
| 184 | } |
||
| 185 | } catch (e) { |
||
| 186 | // Most likely there was no filename or the frame doesn't exist. |
||
| 187 | return true; |
||
| 188 | } |
||
| 189 | |||
| 190 | return false; |
||
| 191 | } |
||
| 192 | |||
| 193 | Rollbar.configure({checkIgnore: ignoreRemoteUncaught}); |
||
| 194 | })(Rollbar); |
||
| 195 | END_HTML; |
||
| 196 | } |
||
| 197 | |||
| 208 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.