Showing 41 of 57 total issues
Class Division
has 41 methods (exceeds 20 allowed). Consider refactoring. Open
class Division < ApplicationRecord
# debate_gid is currently used to generate links to debates on openaustralia.org.au. It would be better
# to use the debate_url field for that. Currently that's completely ignored as it's overridden
# below.
# TODO: Do a data migration so that the debate_url field is the openaustralia.org.au url and debate_gid can be removed
Method load!
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def self.load!(url)
Rails.logger.info "Loading Popolo data from #{url}..."
data = JSON.parse(URI.parse(url).open.read)
people = data["persons"]
vote_events = data["vote_events"]
- 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
Class Person
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Person < ApplicationRecord
has_many :members, -> { order(entered_house: :desc) }, inverse_of: :person, dependent: :destroy
has_many :policy_person_distances, dependent: :destroy
has_many :offices, dependent: :destroy
has_many :people_distances, foreign_key: :person1_id, dependent: :destroy, inverse_of: :person1
Class Member
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Member < ApplicationRecord
# TODO: Remove source_gid from schema as it's not being used (but still loaded by the loaders)
searchkick index_name: "tvfy_members_#{Settings.stage}"
has_one :member_info, dependent: :destroy
delegate :rebellions, :votes_attended, :votes_possible, :tells, to: :member_info, allow_nil: true
Method free_vote?
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def free_vote?
# Free votes from 2006 and onwards. This list from Appendix 3 of
# http://parlinfo.aph.gov.au/parlInfo/search/display/display.w3p;query=Id%3A%22library%2Fprspub%2FCQOS6%22
# TODO: Do we need to restrict this to only these parties? Are these votes free for all parties?
- 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 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.load!(url)
Rails.logger.info "Loading Popolo data from #{url}..."
data = JSON.parse(URI.parse(url).open.read)
people = data["persons"]
vote_events = data["vote_events"]
Method update_distance!
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def update_distance!
absentstrong = 0
absent = 0
samestrong = 0
same = 0
- 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 22 (exceeds 5 allowed). Consider refactoring. Open
def self.load!(from_date, to_date = nil)
agent = Mechanize.new
(from_date..(to_date || from_date)).each do |date|
House.australian.each do |house|
- 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 19 (exceeds 5 allowed). Consider refactoring. Open
def load!
Rails.logger.info "Reloading representatives and senators..."
agent = Mechanize.new
%w[representatives senators].each do |file|
Rails.logger.info "Loading #{file}..."
- 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
Class DivisionXML
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class DivisionXML
MAXIMUM_MOTION_TEXT_SIZE = 15000
attr_accessor :division_xml, :house
Method search
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def search
@current_members = Member.current.map { |m| m.name.downcase }
@mps = []
@divisions = []
- 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 free_vote?
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def free_vote?
# Free votes from 2006 and onwards. This list from Appendix 3 of
# http://parlinfo.aph.gov.au/parlInfo/search/display/display.w3p;query=Id%3A%22library%2Fprspub%2FCQOS6%22
# TODO: Do we need to restrict this to only these parties? Are these votes free for all parties?
Method load!
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.load!(from_date, to_date = nil)
agent = Mechanize.new
(from_date..(to_date || from_date)).each do |date|
House.australian.each do |house|
Method policy_version_sentence
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def policy_version_sentence(version)
changes = []
case version.event
when "create"
- 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 policy_version_sentence_text
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def policy_version_sentence_text(version)
case version.event
when "create"
name = version.changeset["name"].second
description = version.changeset["description"].second
- 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 38 lines of code (exceeds 25 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?
Method policy_version_sentence_text
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def policy_version_sentence_text(version)
case version.event
when "create"
name = version.changeset["name"].second
description = version.changeset["description"].second
Method load!
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load!
Rails.logger.info "Reloading representatives and senators..."
agent = Mechanize.new
%w[representatives senators].each do |file|
Rails.logger.info "Loading #{file}..."
Method policy_version_sentence
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def policy_version_sentence(version)
changes = []
case version.event
when "create"
Method update_distance!
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_distance!
absentstrong = 0
absent = 0
samestrong = 0
same = 0