| Conditions | 3 |
| Total Lines | 100 |
| Code Lines | 76 |
| 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" |
||
| 113 | |||
| 114 | render() { |
||
| 115 | if (this.state.loading === false && this.state.data) { |
||
| 116 | this.state.data.sort((a, b) => { |
||
| 117 | return a.position - b.position !== 0 |
||
| 118 | ? a.position - b.position |
||
| 119 | : b.goalsPro - b.goalsAgainst - (a.goalsPro - a.goalsAgainst) |
||
| 120 | }) |
||
| 121 | |||
| 122 | return ( |
||
| 123 | <div className={"team-ranking"}> |
||
| 124 | <table className={"team-ranking__table"}> |
||
| 125 | <thead className={"team-ranking__header"}> |
||
| 126 | <tr className={"team-ranking__row"}> |
||
| 127 | <th |
||
| 128 | className={ |
||
| 129 | "team-ranking__column team-ranking__column--number team-ranking__column--ranking" |
||
| 130 | } |
||
| 131 | > |
||
| 132 | # |
||
| 133 | </th> |
||
| 134 | <th |
||
| 135 | className={ |
||
| 136 | "team-ranking__column team-ranking__column--string team-ranking__column--team" |
||
| 137 | } |
||
| 138 | > |
||
| 139 | Team |
||
| 140 | </th> |
||
| 141 | <th |
||
| 142 | className={ |
||
| 143 | "team-ranking__column team-ranking__column--number" |
||
| 144 | } |
||
| 145 | > |
||
| 146 | M |
||
| 147 | </th> |
||
| 148 | <th |
||
| 149 | className={ |
||
| 150 | "team-ranking__column team-ranking__column--number" |
||
| 151 | } |
||
| 152 | > |
||
| 153 | W |
||
| 154 | </th> |
||
| 155 | <th |
||
| 156 | className={ |
||
| 157 | "team-ranking__column team-ranking__column--number" |
||
| 158 | } |
||
| 159 | > |
||
| 160 | D |
||
| 161 | </th> |
||
| 162 | <th |
||
| 163 | className={ |
||
| 164 | "team-ranking__column team-ranking__column--number" |
||
| 165 | } |
||
| 166 | > |
||
| 167 | L |
||
| 168 | </th> |
||
| 169 | <th |
||
| 170 | className={ |
||
| 171 | "team-ranking__column team-ranking__column--number team-ranking__column--goals-pro" |
||
| 172 | } |
||
| 173 | > |
||
| 174 | G+ |
||
| 175 | </th> |
||
| 176 | <th |
||
| 177 | className={ |
||
| 178 | "team-ranking__column team-ranking__column--number team-ranking__column--goals-against" |
||
| 179 | } |
||
| 180 | > |
||
| 181 | G- |
||
| 182 | </th> |
||
| 183 | <th |
||
| 184 | className={ |
||
| 185 | "team-ranking__column team-ranking__column--number team-ranking__column--goals-difference" |
||
| 186 | } |
||
| 187 | > |
||
| 188 | +/- |
||
| 189 | </th> |
||
| 190 | <th |
||
| 191 | className={ |
||
| 192 | "team-ranking__column team-ranking__column--number team-ranking__column--points" |
||
| 193 | } |
||
| 194 | > |
||
| 195 | Pts |
||
| 196 | </th> |
||
| 197 | </tr> |
||
| 198 | </thead> |
||
| 199 | <tbody> |
||
| 200 | {this.state.data.map((result, i) => ( |
||
| 201 | <RankingRow |
||
| 202 | result={result} |
||
| 203 | key={i} |
||
| 204 | highlight={this.props.highlight} |
||
| 205 | /> |
||
| 206 | ))} |
||
| 207 | </tbody> |
||
| 208 | </table> |
||
| 209 | </div> |
||
| 210 | ) |
||
| 211 | } else { |
||
| 212 | return <div>Loading...</div> |
||
| 213 | } |
||
| 242 |