| Conditions | 1 |
| Paths | 6 |
| Total Lines | 100 |
| 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 | /* |
||
| 86 | initialize: function() { |
||
| 87 | this.$el.parent().removeClass('content-spacing'); |
||
| 88 | this.$el.parent().addClass('article-teaser-selection'); |
||
| 89 | |||
| 90 | var $container = $(this.templates.skeleton()); |
||
| 91 | this.$el.append($container); |
||
| 92 | |||
| 93 | var toolbar = this.retrieveListToolbarTemplate(); |
||
| 94 | this.sandbox.sulu.initListToolbarAndList.call(this, |
||
| 95 | 'article', |
||
| 96 | '/admin/api/articles/fields', |
||
| 97 | { |
||
| 98 | el: '.teaser-selection-search', |
||
| 99 | instanceName: this.options.instanceName, |
||
| 100 | template: toolbar |
||
| 101 | }, |
||
| 102 | { |
||
| 103 | el: '.teaser-selection-list', |
||
| 104 | instanceName: this.options.instanceName, |
||
| 105 | url: this.getUrl(), |
||
| 106 | preselected: _.map(this.options.data, function(item) { |
||
| 107 | return item.id; |
||
| 108 | }), |
||
| 109 | resultKey: this.options.resultKey, |
||
| 110 | clickCallback: function(item) { |
||
| 111 | this.sandbox.emit('husky.datagrid.teaser-selection.toggle.item', item); |
||
| 112 | }.bind(this), |
||
| 113 | searchInstanceName: this.options.instanceName, |
||
| 114 | searchFields: this.options.searchFields, |
||
| 115 | paginationOptions: { |
||
| 116 | dropdown: { |
||
| 117 | limit: 20 |
||
| 118 | } |
||
| 119 | }, |
||
| 120 | viewOptions: { |
||
| 121 | table: { |
||
| 122 | actionIconColumn: 'title', |
||
| 123 | badges: [ |
||
| 124 | { |
||
| 125 | column: 'title', |
||
| 126 | callback: function(item, badge) { |
||
| 127 | if (!!item.localizationState && |
||
| 128 | item.localizationState.state === 'ghost' && |
||
| 129 | item.localizationState.locale !== this.options.locale |
||
| 130 | ) { |
||
| 131 | badge.title = item.localizationState.locale; |
||
| 132 | |||
| 133 | return badge; |
||
| 134 | } |
||
| 135 | |||
| 136 | return false; |
||
| 137 | }.bind(this) |
||
| 138 | }, |
||
| 139 | { |
||
| 140 | column: 'title', |
||
| 141 | callback: function(item, badge) { |
||
| 142 | var icons = '', |
||
| 143 | tooltip = this.translations.unpublished; |
||
| 144 | |||
| 145 | if (!!item.published && !item.publishedState) { |
||
| 146 | tooltip = this.translations.publishedWithDraft; |
||
| 147 | icons += this.templates.publishedIcon({title: tooltip}); |
||
| 148 | } |
||
| 149 | if (!item.publishedState) { |
||
| 150 | icons += this.templates.draftIcon({title: tooltip}); |
||
| 151 | } |
||
| 152 | |||
| 153 | badge.title = icons; |
||
| 154 | badge.cssClass = 'badge-none'; |
||
| 155 | |||
| 156 | return badge; |
||
| 157 | }.bind(this) |
||
| 158 | } |
||
| 159 | ] |
||
| 160 | } |
||
| 161 | }, |
||
| 162 | } |
||
| 163 | ); |
||
| 164 | |||
| 165 | this.sandbox.start([ |
||
| 166 | { |
||
| 167 | name: 'tabs@husky', |
||
| 168 | options: { |
||
| 169 | el: '.teaser-selection-tabs', |
||
| 170 | data: getTabsData(), |
||
| 171 | callback: this.changeType.bind(this) |
||
| 172 | } |
||
| 173 | }, |
||
| 174 | { |
||
| 175 | name: 'articles/list/authored-selection/form@suluarticle', |
||
| 176 | options: { |
||
| 177 | el: '.slide.authored-slide .overlay-content', |
||
| 178 | data: this.options.data, |
||
| 179 | selectCallback: this.closeAuthoredSelection.bind(this) |
||
| 180 | } |
||
| 181 | } |
||
| 182 | ]); |
||
| 183 | |||
| 184 | this.bindCustomEvents(); |
||
| 185 | }, |
||
| 186 | |||
| 267 |
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.