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"
- Read upRead up
- Create a ticketCreate a ticket
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 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
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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))
- Read upRead up
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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 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|
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
val = stat.extra_points_made if stat
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
val = stat.field_goals_attempted if stat
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
val = stat.field_goals_made if stat
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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 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|
- Read upRead up
- Create a ticketCreate a ticket
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_21_points
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return league.defensive_points_allowed_under_35_points
- Create a ticketCreate a ticket