Showing 84 of 154 total issues
File rails.validations.js
has 617 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function() {
var $, validateElement, validateForm, validatorsFor,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
$ = jQuery;
Class PagesController
has 41 methods (exceeds 20 allowed). Consider refactoring. Open
class PagesController < ApplicationController
DEFAULT_GEOJSON_CENTER = [-73.9998334, 40.7195898]
DEFAULT_MUNICIPALITY = "New York"
skip_before_filter :verify_authenticity_token, :only => [:locator, :identifier]
Function main
has 125 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
Method add_attributes_to
has a Cognitive Complexity of 29 (exceeds 5 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
- 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
File pages_controller.rb
has 339 lines of code (exceeds 250 allowed). Consider refactoring. Open
class PagesController < ApplicationController
DEFAULT_GEOJSON_CENTER = [-73.9998334, 40.7195898]
DEFAULT_MUNICIPALITY = "New York"
skip_before_filter :verify_authenticity_token, :only => [:locator, :identifier]
Method get
has a Cognitive Complexity of 27 (exceeds 5 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']
- 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 main
has 91 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
Class Person
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Person
include Mongoid::Document
# authorization based on roles
# i.e. a user.can_respond_as?(person) to answer questions
Class QuestionsController
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class QuestionsController < ApplicationController
before_filter :force_http
inherit_resources
belongs_to :jurisdiction, parent_class: Metadatum, finder: :find_by_abbreviation, param: :jurisdiction
File questions_controller.rb
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
class QuestionsController < ApplicationController
before_filter :force_http
inherit_resources
belongs_to :jurisdiction, parent_class: Metadatum, finder: :find_by_abbreviation, param: :jurisdiction
Function main
has 74 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 _placeholder_shim
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
_placeholder_shim: function(config) {
function calcPositionCss(target)
{
var op = $(target).offsetParent().offset();
var ot = $(target).offset();
File cached_official.rb
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
class CachedOfficial
include Mongoid::Document
# The person's jurisdiction in askthem
belongs_to :metadatum, foreign_key: "state"
Method create
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def create
@question = Question.new(params[:question])
if @question.person_id.present?
@person = @question.person
@question.state = @person.state
- 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 input
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
input: function(input) {
var $form, $input, binding, event, form, _ref;
$input = $(input);
form = input.form;
$form = $(form);
Method create
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def create
person_id = params[:user].delete(:person_id)
build_resource(sign_up_params)
- 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 17 (exceeds 5 allowed). Consider refactoring. Open
def show
@user = user_signed_in? ? current_user : User.new
if params[:code]
confirmed_question = Question.where(id: params[:id])
.where(confirm_code: params[:code]).first
- 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 all
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.all
[ # In both OpenStates and VoteSmart: # Additional VoteSmart subjects:
'Agriculture and Food',
'Business and Consumers',
'Civil Liberties and Civil Rights', # Women
Function uniqueness
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
uniqueness: function(element, options) {
var data, key, message, name, scope_value, scoped_element, scoped_name, _ref;
message = ClientSideValidations.validators.local.presence(element, options);
if (message) {
if (options.allow_blank === true) {
Method create
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@question = Question.new(params[:question])
if @question.person_id.present?
@person = @question.person
@question.state = @person.state