Drosty/truegm

View on GitHub

Showing 27 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

Similar blocks of code found in 3 locations. 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: Major
Found in app/models/nfl_player_view_model.rb and 2 other locations - About 2 hrs to fix
app/models/nfl_player_view_model.rb on lines 56..80
app/models/nfl_player_view_model.rb on lines 83..108

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 88.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. 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: Major
Found in app/models/nfl_player_view_model.rb and 2 other locations - About 2 hrs to fix
app/models/nfl_player_view_model.rb on lines 83..108
app/models/nfl_player_view_model.rb on lines 111..136

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 88.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. 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: Major
Found in app/models/nfl_player_view_model.rb and 2 other locations - About 2 hrs to fix
app/models/nfl_player_view_model.rb on lines 56..80
app/models/nfl_player_view_model.rb on lines 111..136

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 88.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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
Severity
Category
Status
Source
Language