Class has too many lines. [255/250] Open
class ShowDataGenerator < Jekyll::Generator
priority :high
# From years.rb
def years_by_slug
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [64/30] Open
def generate_show(show)
# Set year attributes
show.data["year"] = get_show_year(show)
show.data["year_page"] = get_show_year_page(show)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method generate_show
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def generate_show(show)
# Set year attributes
show.data["year"] = get_show_year(show)
show.data["year_page"] = get_show_year_page(show)
- 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
Cyclomatic complexity for generate_show is too high. [23/6] Open
def generate_show(show)
# Set year attributes
show.data["year"] = get_show_year(show)
show.data["year_page"] = get_show_year_page(show)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method has too many lines. [45/30] Open
def missing_majority(show)
# We don't have crew_incomplete yet, so let's work it out.
show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
amount_missing = 0
missing_fields = ''
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method generate_show
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_show(show)
# Set year attributes
show.data["year"] = get_show_year(show)
show.data["year_page"] = get_show_year_page(show)
- Create a ticketCreate a ticket
Cyclomatic complexity for missing_majority is too high. [12/6] Open
def missing_majority(show)
# We don't have crew_incomplete yet, so let's work it out.
show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
amount_missing = 0
missing_fields = ''
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
File show.rb
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Jekyll
class ShowDataGenerator < Jekyll::Generator
priority :high
# From years.rb
- Create a ticketCreate a ticket
Method missing_majority
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def missing_majority(show)
# We don't have crew_incomplete yet, so let's work it out.
show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
amount_missing = 0
missing_fields = ''
- 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
Cyclomatic complexity for get_show_playwright is too high. [8/6] Open
def get_show_playwright(show)
if show.data.key?("playwright") and not show.data["playwright"].nil?
if show.data["playwright"] == "various"
# Is various, special case
["various", nil, "Various Writers"]
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method missing_majority
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def missing_majority(show)
# We don't have crew_incomplete yet, so let's work it out.
show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
amount_missing = 0
missing_fields = ''
- Create a ticketCreate a ticket
Method get_show_playwright
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_show_playwright(show)
if show.data.key?("playwright") and not show.data["playwright"].nil?
if show.data["playwright"] == "various"
# Is various, special case
["various", nil, "Various Writers"]
- 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 get_show_asset_type
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_show_asset_type(show, key, image_only=true)
show.data["assets"].select do |i|
# Skip non-images if image_only
if image_only and not i.key?("image") then next end
- 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 get_show_display_image
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_show_display_image(show)
# Assets required
return nil unless show.data.key?("assets")
# Find assets that fit the criteria for being a display image
- 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 programmes[0]
- Create a ticketCreate a ticket
Useless assignment to variable - show_crew_count
. Open
show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Literal """Send a person_list to the reverse index"""
used in void context. Open
"""Send a person_list to the reverse index"""
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for operators, variables and literals used in void context.
Example:
# bad
def some_method
some_num * 10
do_something
end
Example:
# bad
def some_method(some_var)
some_var
do_something
end
Example:
# good
def some_method
do_something
some_num * 10
end
Example:
# good
def some_method(some_var)
do_something
some_var
end
Literal """Returns a hash of shows by year"""
used in void context. Open
"""Returns a hash of shows by year"""
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for operators, variables and literals used in void context.
Example:
# bad
def some_method
some_num * 10
do_something
end
Example:
# bad
def some_method(some_var)
some_var
do_something
end
Example:
# good
def some_method
do_something
some_num * 10
end
Example:
# good
def some_method(some_var)
do_something
some_var
end