Drosty/truegm

View on GitHub

Showing 20 of 27 total issues

Method process_spotrac_salary_data has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def self.process_spotrac_salary_data
      NflPlayer.find_each do |player|
        next if player.full_name == "Kevin Norwood"
        next if player.full_name == "Rueben Randle"
        next if player.full_name == "Chris Givens"
Severity: Minor
Found in app/services/spotrac/spotrac_service.rb - About 4 hrs 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

Method process_spotrac_player_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def self.process_spotrac_player_data
      NflTeam.all.each do |nfl_team|
        puts "processing: " + nfl_team.full_name + " " + nfl_team.spotrac_url

        nfl_page = Nokogiri::HTML(open(nfl_team.spotrac_url))
Severity: Minor
Found in app/services/spotrac/spotrac_service.rb - About 2 hrs 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

Class NflPlayer has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class NflPlayer < ActiveRecord::Base
  attr_accessible :first_name, :last_name, :position, :salary,
                  :nfl_team_id, :spotrac_url, :full_name, :jersey,
                  :height, :weight, :dob, :college, :active, :current_status,
                  :depth_order, :experience, :photo_url, :fantasy_data_id
Severity: Minor
Found in app/models/nfl_player.rb - About 2 hrs to fix

Method update_stat_with_data_by_position has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def update_stat_with_data_by_position stat, position
      stat.played = rand(0..1)
      stat.started = rand(0..1)

      if position == Position::QUARTERBACK
Severity: Minor
Found in app/services/fantasy_data/data_generator_service.rb - About 2 hrs 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

Method update_stat_with_data_by_position has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def update_stat_with_data_by_position stat, position
      stat.played = rand(0..1)
      stat.started = rand(0..1)

      if position == Position::QUARTERBACK
Severity: Major
Found in app/services/fantasy_data/data_generator_service.rb - About 2 hrs to fix

Method col4_for_header has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def col4_for_header header_category, year, week
    val = 0
    if is_passing_header?(header_category)
      stat = @player.passing_stats.where({season: year, week: week}).first
      val = stat.passing_interceptions if stat
Severity: Minor
Found in app/models/nfl_player_view_model.rb - About 1 hr 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

Method col2_for_header has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def col2_for_header header_category, year, week
    val = 0
    if is_passing_header?(header_category)
      stat = @player.passing_stats.where({season: year, week: week}).first
      val = stat.passing_yards if stat
Severity: Minor
Found in app/models/nfl_player_view_model.rb - About 1 hr 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

Method col3_for_header has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def col3_for_header header_category, year, week
    val = 0
    if is_passing_header?(header_category)
      stat = @player.passing_stats.where({season: year, week: week}).first
      val = stat.passing_touchdowns if stat
Severity: Minor
Found in app/models/nfl_player_view_model.rb - About 1 hr 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

Method process_box_score has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def process_box_score stat_data
      week = stat_data.score.week
      season = stat_data.score.season

      # process_defense_stat stat_data["AwayFantasyDefense"], week, season
Severity: Minor
Found in app/services/fantasy_data/stat_import_processing.rb - About 1 hr to fix

Method import_nfl_player_data has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def import_nfl_player_data
      NflPlayer.update_all(active: false)
      teams = NflTeam.all

      Fantasydata.player_details_available.each do |player|
Severity: Minor
Found in app/services/fantasy_data/import_service.rb - About 1 hr to fix

Method defensive_points_allowed_points has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def defensive_points_allowed_points league
      return 0 if nfl_player.nil?
      return 0 unless nfl_player.position.upcase == "DEF"

      if self.points_allowed.to_i < 7
Severity: Minor
Found in app/models/stat.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 deeply nested control flow statements.
Open

      val = stat.field_goals_made if stat
Severity: Major
Found in app/models/nfl_player_view_model.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

      val = stat.extra_points_made if stat
Severity: Major
Found in app/models/nfl_player_view_model.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

      val = stat.field_goals_attempted if stat
Severity: Major
Found in app/models/nfl_player_view_model.rb - About 45 mins to fix

Method import_nfl_player_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def import_nfl_player_data
      NflPlayer.update_all(active: false)
      teams = NflTeam.all

      Fantasydata.player_details_available.each do |player|
Severity: Minor
Found in app/services/fantasy_data/import_service.rb - About 35 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.defensive_points_allowed_under_35_points
Severity: Major
Found in app/models/stat.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return league.defensive_points_allowed_under_28_points
Severity: Major
Found in app/models/stat.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return league.defensive_points_allowed_under_21_points
Severity: Major
Found in app/models/stat.rb - About 30 mins to fix

Method stat_catagories_headers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def stat_catagories_headers
    if @player.position == Position::QUARTERBACK
      ["Passing", "Rushing"]

    elsif @player.position == Position::RUNNINGBACK
Severity: Minor
Found in app/models/nfl_player_view_model.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

Method sortable_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def sortable_link(column, title = nil)
    title ||= column.titleize
    css_class = column == sort_column ? "current #{sort_direction}" : nil
    direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
    link_to title, params.merge(:sort => column, :direction => direction, :page => nil), {:class => css_class}
Severity: Minor
Found in app/helpers/nfl_players_helper.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