Showing 65 of 108 total issues
Method build_proposals_for_coop
has a Cognitive Complexity of 134 (exceeds 5 allowed). Consider refactoring. Open
def build_proposals_for_coop
ability = Ability.new(proposer)
# Organisation name
if organisation.name != organisation_name
- 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 build_proposals_for_coop
has 421 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_proposals_for_coop
ability = Ability.new(proposer)
# Organisation name
if organisation.name != organisation_name
Class Coop
has 102 methods (exceeds 20 allowed). Consider refactoring. Open
class Coop < Organisation
# http://www.legislation.gov.uk/ukpga/2014/14/part/2/crossheading/maximum-shareholding/enacted
MAXIMUM_SHAREHOLDING_IN_POUNDS = 100_000
include OneClickOrgs::CastToBoolean
Method update_attributes
has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring. Open
def update_attributes(options={})
case organisation
when Association
organisation.clauses.set_text!('organisation_name', options[:organisation_name]) if organisation_name != options[:organisation_name]
- 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 constitution_proposal_bundle.rb
has 593 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'one_click_orgs/model_wrapper'
# Provides an ActiveModel like interface to a bundle of ConstitutionProposals.
# The attributes exposed are the constitution settings themselves (e.g. organisation_name,
# voting_period, etc.), plus a single 'proposer' attribute.
File coop.rb
has 590 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'one_click_orgs/cast_to_boolean'
class Coop < Organisation
# http://www.legislation.gov.uk/ukpga/2014/14/part/2/crossheading/maximum-shareholding/enacted
MAXIMUM_SHAREHOLDING_IN_POUNDS = 100_000
Method initialize
has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
return unless user
if user.has_permission(:vote)
can :create, 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 after_initialize
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def after_initialize
# Load existing settings from organisation, if given, but don't
# overwrite new settings that have been passed directly in as attributes.
if organisation
case organisation
- 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 build_proposals_for_association
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def build_proposals_for_association
# Organisation name
if organisation.name != organisation_name
proposal = (organisation.change_text_proposals.new(
:name => 'organisation_name',
- 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 build_proposals_for_association
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_proposals_for_association
# Organisation name
if organisation.name != organisation_name
proposal = (organisation.change_text_proposals.new(
:name => 'organisation_name',
Class ApplicationController
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :ensure_set_up
before_filter :ensure_organisation_exists
Method update_attributes
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_attributes(options={})
case organisation
when Association
organisation.clauses.set_text!('organisation_name', options[:organisation_name]) if organisation_name != options[:organisation_name]
Method to_pdf
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_pdf
template = File.expand_path(File.join(Rails.root, 'data', 'pdf_form_filler', 'fca_2014', 'mutuals-new-ip-form.pdf'))
definition = File.expand_path(File.join(Rails.root, 'data', 'pdf_form_filler', 'fca_2014', 'mutuals-new-ip-form.yml'))
# Load default filled-in data for form
Method initialize
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
return unless user
if user.has_permission(:vote)
can :create, Vote
Class Proposal
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Proposal < ActiveRecord::Base
include OneClickOrgs::ParametersSerialisation
attr_accessible :title, :proposer_member_id, :description, :parameters
Class Member
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Member < ActiveRecord::Base
attr_accessible :email, :first_name, :last_name, :role, :terms_and_conditions,
:password, :password_confirmation, :send_welcome,
:address, :certify_share_application, :certify_age,
:phone, :member_class_id
Method dashboard
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dashboard
@new_proposal = co.proposals.new
case co
Method document
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def document
# TODO Make this work for Organisation subclasses other than Coop.
if document_template
document = document_template
elsif document_id = Setting[:coop_constitution_document_id]
Method create
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@association = Association.new(params[:association])
@founder = Member.new(params[:founder])
errors = []
Method set_member_class
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def set_member_class
return unless director && (elected_on || ended_on)
if ended_on
member_member_class = organisation.member_classes.find_by_name('Member')
director.member_class = member_member_class if member_member_class
- 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"