Conditions | 3 |
Total Lines | 77 |
Code Lines | 59 |
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, { Component } from "react" |
||
13 | render() { |
||
14 | moment.locale("nl-BE") |
||
15 | |||
16 | const { result } = this.props |
||
17 | const { |
||
18 | matchDay, |
||
19 | dateTime, |
||
20 | resultHome, |
||
21 | resultAway, |
||
22 | regNumberHome, |
||
23 | regNumberAway, |
||
24 | home, |
||
25 | away, |
||
26 | status, |
||
27 | } = result |
||
28 | |||
29 | const d = new moment(dateTime) |
||
30 | const date = d.format("dddd D MMMM YYYY") |
||
31 | const time = d.format("HH:mm") |
||
32 | const matchPlayed = |
||
33 | typeof resultHome !== "undefined" && typeof resultAway !== "undefined" |
||
34 | |||
35 | return ( |
||
36 | <article className={"team-calendar-match"}> |
||
37 | <header className={"team-calendar-match__title"}> |
||
38 | <h2> |
||
39 | {date}{" "} |
||
40 | <span className={"team-calendar-match__title__separator"}>|</span> |
||
41 | <span className={"team-calendar-match__title__tagline"}> |
||
42 | speeldag {matchDay} |
||
43 | </span> |
||
44 | </h2> |
||
45 | </header> |
||
46 | <div className={"team-calendar-match__main"}> |
||
47 | <div |
||
48 | className={`team-calendar-match__team team-calendar-match__team--home ${ |
||
49 | matchPlayed && resultHome > resultAway && "match-winner" |
||
50 | }`} |
||
51 | > |
||
52 | {home} |
||
53 | |||
54 | <ClubLogo |
||
55 | regNumber={regNumberHome} |
||
56 | title={home} |
||
57 | className={ |
||
58 | "team-calendar-match__logo team-calendar-match__logo--home" |
||
59 | } |
||
60 | lazyload={true} |
||
61 | /> |
||
62 | </div> |
||
63 | <div className={"team-calendar-match__score"}> |
||
64 | {typeof status !== "undefined" && status !== "" ? ( |
||
65 | <span title={mapMatchStatus(status)}>{status}</span> |
||
66 | ) : typeof resultHome !== "undefined" && |
||
67 | typeof resultAway !== "undefined" ? ( |
||
68 | `${resultHome} - ${resultAway}` |
||
69 | ) : ( |
||
70 | time |
||
71 | )} |
||
72 | </div> |
||
73 | <div |
||
74 | className={`team-calendar-match__team team-calendar-match__team--away ${ |
||
75 | matchPlayed && resultAway > resultHome && "match-winner" |
||
76 | }`} |
||
77 | > |
||
78 | <ClubLogo |
||
79 | regNumber={regNumberAway} |
||
80 | title={away} |
||
81 | className={ |
||
82 | "team-calendar-match__logo team-calendar-match__logo--away" |
||
83 | } |
||
84 | lazyload={true} |
||
85 | /> |
||
86 | {away} |
||
87 | </div> |
||
88 | </div> |
||
89 | </article> |
||
90 | ) |
||
178 |