Showing 41 of 57 total issues
Method search
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def search
@current_members = Member.current.map { |m| m.name.downcase }
@mps = []
@divisions = []
Method policy_division_version_sentence
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def policy_division_version_sentence(version)
vote = policy_division_version_vote(version)
division = policy_division_version_division(version)
division_link = content_tag(:em, link_to(division.name, division_url_simple(division)))
out = []
Method category_words_sentence
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def category_words_sentence(category, person: nil, policy: nil)
out = []
if category == :not_enough
# For this category we have to order the sentence differently because it doesn't have the
# same structure as the other sentences
Function changeSubscribeButtons
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function changeSubscribeButtons(new_text, new_class_name) {
// test environment
if (!document.getElementsByClassName) return false;
if (!document.getElementsByTagName) return false;
if (!document.getElementsByClassName("subscribe-button-form")) return false;
Consider simplifying this complex logical expression. Open
if votes
whip.aye_votes = votes[["aye", 0]] || 0
whip.aye_tells = votes[["aye", 1]] || 0
whip.no_votes = votes[["no", 0]] || 0
whip.no_tells = votes[["no", 1]] || 0
Method index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def index
@years = (Division.order(:date).first.date.year..Division.order(:date).last.date.year).to_a
begin
@date_start, @date_end, @date_range = date_range(params[:date])
- Read upRead up
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 member_rebellion_record_sentence
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def member_rebellion_record_sentence(member)
if member.person.rebellions_fraction.zero?
member.currently_in_parliament? ? "Never rebels" : "Never rebelled"
else
# TODO: Should this be an absolute count rather than percentage?
- Read upRead up
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 category_words_sentence
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def category_words_sentence(category, person: nil, policy: nil)
out = []
if category == :not_enough
# For this category we have to order the sentence differently because it doesn't have the
# same structure as the other sentences
- Read upRead up
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
Function changeSubscribeButtons
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function changeSubscribeButtons(new_text, new_class_name) {
// test environment
if (!document.getElementsByClassName) return false;
if (!document.getElementsByTagName) return false;
if (!document.getElementsByClassName("subscribe-button-form")) return false;
- Read upRead up
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 majority_strength_in_words
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def majority_strength_in_words(division)
if division.unanimous?
"unanimously"
elsif division.tied?
""
- Read upRead up
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 show
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
yield resource if block_given?
if resource.errors.empty?
- Read upRead up
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 fraction_to_percentage_display
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def fraction_to_percentage_display(fraction)
if fraction
percentage = fraction * 100
# Special handling for number very close to 0 or 100
# These are numbers that would get rounded to 0% or 100% but are not exactly that so we want
- Read upRead up
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 overlap_dates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def overlap_dates
result = []
person1.members.reorder(:entered_house).each do |member1|
person2.members.reorder(:entered_house).each do |member2|
r = PeopleDistance.overlap_dates_members(member1, member2)
- Read upRead up
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 index
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def index
@sort = params[:sort]
@house = params[:house]
members = Member.current
- Read upRead up
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 show_redirect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def show_redirect
member = if params[:mpid]
Member.find(params[:mpid])
elsif params[:id]
begin
- Read upRead up
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 function. Open
if (button.lastChild.nodeType !== 3) return false;
Method show
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show
member1 = Member.find_with_url_params(house: params[:house], mpc: params[:mpc], mpn: params[:mpn])
member2 = Member.find_with_url_params(house: params[:house2], mpc: params[:mpc2], mpn: params[:mpn2])
return render "members/member_not_found", status: :not_found if member1.nil? || member2.nil?
- Read upRead up
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 vote_words
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def vote_words(vote)
if vote
if vote.rebellion?
"voted #{vote_display(vote.vote)}, rebelling against the #{vote.party_name}"
elsif vote.free_vote?
- Read upRead up
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 load!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.load!
Rails.logger.info "Reloading offices..."
agent = Mechanize.new
ministers_xml = agent.get "#{Settings.xml_data_base_url}members/ministers.xml"
Rails.logger.info "Deleted #{Office.delete_all} offices"
- Read upRead up
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 randomise_people_voting_on_policy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def randomise_people_voting_on_policy(policy)
distances = policy.policy_person_distances.currently_in_parliament.includes(:person, person: :members)
# Insert people into each category
people_category_table = {}
- Read upRead up
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"