Showing 84 of 154 total issues
Method type
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def type
@type ||=
case office_level
when "city", "other"
case division_scope.downcase
Method add_attributes_to
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_attributes_to(person)
unless person.read_attribute(:ocd_division_id)
person.write_attribute(:ocd_division_id, ocd_division_id)
end
Function numericality
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
numericality: function(element, options) {
var CHECKS, check, check_value, fn, form, operator, val;
val = jQuery.trim(element.val());
if (!ClientSideValidations.patterns.numericality.test(val)) {
if (options.allow_blank === true && this.presence(element, {
Function main
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function main() {
jQuery(document).ready(function($) {
// We can use jQuery here
// load css, only if it hasn't been loaded
Function form
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
form: function(form) {
var $form, binding, event, _ref;
$form = $(form);
form.ClientSideValidations = {
settings: window.ClientSideValidations.forms[$form.attr('id')],
Function autogrow
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.autogrow = function(options)
{
return this.filter('textarea').each(function()
{
var self = this;
Method translate_arguments
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def translate_arguments
@translate_arguments ||= begin
args = {}
if @jurisdiction
Method roles_from_api
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def roles_from_api(terms)
write_attribute(:roles, []) unless read_attribute(:roles)
terms.each do |term|
role = { term_years: [] }
- 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 guess_division_scope
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def guess_division_scope(office, division)
if office.is_governor? ||
(office.is_federal_legislator? &&
office.roles.include?("legislatorUpperBody"))
GoogleCivicInfo::Division::STATEWIDE
- 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 tab
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tab(tab)
@governor = Governor.connected_to(@jurisdiction.abbreviation).active.first
@mayor = Mayor.connected_to(@jurisdiction.abbreviation).active.first ||
Councilmember.connected_to(@jurisdiction.abbreviation).active
.where(district: "Mayor").first
Method og_image_tag
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def og_image_tag
urls = ["http://www.askthem.io/assets/mark.png"]
if @question
if @question.media.present? && is_image?(@question.media.url)
- 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 people_and_committee_sponsors
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def people_and_committee_sponsors(opts = {})
sponsors = read_attribute(:sponsors)
case opts[:only]
when :people
sponsors.select!{|x| x['leg_id']}
- 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 htmlTemplate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function htmlTemplate(tagId, options) {
headline = options.headline;
summary = options.questionSummary;
body = options.questionBody;
name = options.partner.name;
Method people_and_committee_sponsors
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def people_and_committee_sponsors(opts = {})
sponsors = read_attribute(:sponsors)
case opts[:only]
when :people
sponsors.select!{|x| x['leg_id']}
Method copy_to_new_person
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def copy_to_new_person
unless Metadatum.where(id: state).first
copy_to_new_metadatum
end
Function inWords
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
inWords: function(distanceMillis) {
var $l = this.settings.strings;
var prefix = $l.prefixAgo;
var suffix = $l.suffixAgo;
if (this.settings.allowFuture) {
Method roles_from_api
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def roles_from_api(terms)
write_attribute(:roles, []) unless read_attribute(:roles)
terms.each do |term|
role = { term_years: [] }
Method sentence
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def sentence(person = nil, metadatum = nil)
if ratingText?
person ||= self.person # avoid N+1 query
metadatum ||= self.metadatum # avoid N+1 query
sentence = ratingText
- 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 local_jurisdiction
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def local_jurisdiction
return @local_jurisdiction if @local_jurisdiction
if @jurisdiction && @jurisdiction.id.include?("-")
return @local_jurisdiction = @jurisdiction
end
- 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 get
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get(endpoint, params = {})
begin
result = JSON.parse(RestClient.get("http://api.votesmart.org/#{endpoint}", params: params.merge(key: @api_key, o: 'JSON')))
if result['error']