Showing 6 of 8 total issues
Method points_allowed
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def points_allowed(stats, league)
points = stats["PointsAllowed"].to_i
return league.pts_all_0 if points == 0
return league.pts_all_6 if points <= 6
return league.pts_all_13 if points <= 13
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
Open
return league.pts_all_27 if points <= 27
Avoid too many return
statements within this method. Open
Open
return league.pts_all_46 if points >= 46
Avoid too many return
statements within this method. Open
Open
return league.pts_all_34 if points <= 34
Avoid too many return
statements within this method. Open
Open
return league.pts_all_45 if points <= 45
Method player_stats
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def player_stats(year, week, player_id)
if year.empty? || week.empty?
stats = {"error" => "A year or week is needed to calculate."}
else
url = "http://api.nfldata.apiphany.com/developer/JSON/PlayerGameStatsByPlayerID/#{year}/#{week}/#{player_id}"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"