Conditions | 2 |
Total Lines | 115 |
Code Lines | 102 |
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 | import React, { Fragment } from "react" |
||
142 | renderTeamSquadStats = () => { |
||
143 | if (this.state.loading === false && this.state.data) { |
||
144 | const { squadPlayerStatistics } = this.state.data |
||
145 | |||
146 | squadPlayerStatistics.sort((a, b) => b.minutes - a.minutes) |
||
147 | |||
148 | return ( |
||
149 | <Card className="team_stats__players" title="Spelers" hasTable={true}> |
||
150 | <table> |
||
151 | <thead> |
||
152 | <tr> |
||
153 | <th className={"table__column__string"}>Speler</th> |
||
154 | <th className={"table__column__number show-for-medium"}> |
||
155 | <span title="Wedstrijden gespeeld">P</span> |
||
156 | </th> |
||
157 | <th className={"table__column__number"}> |
||
158 | <span title="Wedstrijden gewonnen">W</span> |
||
159 | </th> |
||
160 | <th |
||
161 | className={"table__column__number"} |
||
162 | > |
||
163 | <span title="Wedstrijden gelijkgespeeld">D</span> |
||
164 | </th> |
||
165 | <th |
||
166 | className={"table__column__number"} |
||
167 | > |
||
168 | <span title="Wedstrijden verloren">L</span> |
||
169 | </th> |
||
170 | <th |
||
171 | className={"table__column__number"} |
||
172 | > |
||
173 | <img |
||
174 | src={iconCardYellow} |
||
175 | title="Gele kaart" |
||
176 | alt="Gele kaart" |
||
177 | className="table__header__icon" |
||
178 | /> |
||
179 | </th> |
||
180 | <th |
||
181 | className={"table__column__number"} |
||
182 | > |
||
183 | <img |
||
184 | src={iconCardRed} |
||
185 | title="Rode kaart" |
||
186 | alt="Rode kaart" |
||
187 | className="table__header__icon" |
||
188 | /> |
||
189 | </th> |
||
190 | <th |
||
191 | className={"table__column__number"} |
||
192 | > |
||
193 | <img |
||
194 | src={iconGoal} |
||
195 | title="Doelpunt(en) gescoord" |
||
196 | alt="Doelpunt(en) gescoord" |
||
197 | className="table__header__icon" |
||
198 | /> |
||
199 | </th> |
||
200 | <th |
||
201 | className={"table__column__number show-for-medium"} |
||
202 | > |
||
203 | <img |
||
204 | src={iconCleansheet} |
||
205 | title="Cleansheets" |
||
206 | alt="Cleansheets" |
||
207 | className="table__header__icon" |
||
208 | /> |
||
209 | </th> |
||
210 | <th |
||
211 | className={"table__column__number"} |
||
212 | > |
||
213 | <span title="Minuten gespeeld"> |
||
214 | <Icon icon="fa-clock-o" /> |
||
215 | </span> |
||
216 | </th> |
||
217 | </tr> |
||
218 | </thead> |
||
219 | <tbody> |
||
220 | {squadPlayerStatistics.map(function (player) { |
||
221 | return ( |
||
222 | <tr> |
||
223 | <td className={"table__column__string"}> |
||
224 | {player.firstName} {player.lastName} |
||
225 | </td> |
||
226 | <td className={"table__column__number show-for-medium"}> |
||
227 | {player.gamesPlayed} |
||
228 | </td> |
||
229 | <td className={"table__column__number"}> |
||
230 | {player.gamesWon} |
||
231 | </td> |
||
232 | <td className={"table__column__number"}> |
||
233 | {player.gamesEqual} |
||
234 | </td> |
||
235 | <td className={"table__column__number"}> |
||
236 | {player.gamesLost} |
||
237 | </td> |
||
238 | <td className={"table__column__number"}> |
||
239 | {player.yellowCards} |
||
240 | </td> |
||
241 | <td className={"table__column__number"}> |
||
242 | {player.redCards} |
||
243 | </td> |
||
244 | <td className={"table__column__number"}>{player.goals}</td> |
||
245 | <td className={"table__column__number show-for-medium"}> |
||
246 | {player.cleanSheets} |
||
247 | </td> |
||
248 | <td className={"table__column__number"}> |
||
249 | {player.minutes || "0"}' |
||
250 | </td> |
||
251 | </tr> |
||
252 | ) |
||
253 | })} |
||
254 | </tbody> |
||
255 | </table> |
||
256 | </Card> |
||
257 | ) |
||
285 |