Brandon-Lyons/Fantasy-Sports-Calculator-Rails

View on GitHub

Showing 6 of 8 total issues

Method points_allowed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
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
Severity: Minor
Found in app/models/football_team.rb - About 45 mins to fix

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

    return league.pts_all_27 if points <= 27
Severity: Major
Found in app/models/football_team.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return league.pts_all_46 if points >= 46
    Severity: Major
    Found in app/models/football_team.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return league.pts_all_34 if points <= 34
      Severity: Major
      Found in app/models/football_team.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return league.pts_all_45 if points <= 45
        Severity: Major
        Found in app/models/football_team.rb - About 30 mins to fix

          Method player_stats has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          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}"
          Severity: Minor
          Found in lib/interface.rb - About 25 mins to fix

          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

          Severity
          Category
          Status
          Source
          Language