| Conditions | 1 |
| Paths | 2 |
| Total Lines | 63 |
| 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 | /* |
||
| 46 | initialize: function() { |
||
| 47 | var $overlayContainer = $('<div/>'); |
||
| 48 | this.$el.append($overlayContainer); |
||
| 49 | |||
| 50 | this.data = this.options.data; |
||
| 51 | |||
| 52 | // start overlay |
||
| 53 | this.sandbox.start([{ |
||
| 54 | name: 'overlay@husky', |
||
| 55 | options: { |
||
| 56 | el: $overlayContainer, |
||
| 57 | instanceName: 'category-selection', |
||
| 58 | openOnStart: true, |
||
| 59 | removeOnClose: true, |
||
| 60 | skin: 'medium', |
||
| 61 | slides: [ |
||
| 62 | { |
||
| 63 | title: this.translations.title, |
||
| 64 | data: $(this.templates.skeleton({ |
||
| 65 | translations: this.translations |
||
| 66 | })), |
||
| 67 | okCallback: this.okCallbackOverlay.bind(this) |
||
| 68 | } |
||
| 69 | ] |
||
| 70 | } |
||
| 71 | }]); |
||
| 72 | |||
| 73 | this.sandbox.once('husky.overlay.category-selection.opened', function() { |
||
| 74 | this.sandbox.start([ |
||
| 75 | { |
||
| 76 | name: 'datagrid@husky', |
||
| 77 | options: { |
||
| 78 | el: $overlayContainer.find('.category-selection-list'), |
||
| 79 | instanceName: 'category-selection', |
||
| 80 | url: '/admin/api/categories?locale=' + this.options.locale + '&flat=true&sortBy=name&sortOrder=asc', |
||
| 81 | resultKey: 'categories', |
||
| 82 | sortable: false, |
||
| 83 | selectedCounter: false, |
||
| 84 | preselected: !!this.options.data.category ? [this.options.data.category.id] : [], |
||
| 85 | paginationOptions: { |
||
| 86 | dropdown: { |
||
| 87 | limit: 20 |
||
| 88 | } |
||
| 89 | }, |
||
| 90 | childrenPropertyName: 'hasChildren', |
||
| 91 | viewOptions: { |
||
| 92 | table: { |
||
| 93 | cropContents: false, |
||
| 94 | noItemsText: 'sulu.category.no-categories-available', |
||
| 95 | showHead: false, |
||
| 96 | cssClass: 'white-box', |
||
| 97 | selectItem: { |
||
| 98 | type: 'radio', |
||
| 99 | inFirstCell: true |
||
| 100 | } |
||
| 101 | } |
||
| 102 | }, |
||
| 103 | matchings: this.options.matchings |
||
| 104 | } |
||
| 105 | } |
||
| 106 | ]); |
||
| 107 | }.bind(this)); |
||
| 108 | }, |
||
| 109 | |||
| 126 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.