Showing 108 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('#change_meeting_notice_period_resolution_pass_immediately').change(function () {
if ($('#change_meeting_notice_period_resolution_pass_immediately:checked').val() == '1') {
$('.pass_immediately_true').show();
$('.pass_immediately_false').hide();
} else {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 102.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('#change_quorum_resolution_pass_immediately').change(function () {
if ($('#change_quorum_resolution_pass_immediately:checked').val() == '1') {
$('.pass_immediately_true').show();
$('.pass_immediately_false').hide();
} else {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 102.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('body.setup input#coop_name').keyup(function() {
var text = $('input#coop_name').val();
text = text.toLowerCase();
// Regex to whitelist organisation name to generate a subdomain
// Obviously, we still need to validate this in the app
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 88.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('body.setup input#association_name').keyup(function() {
var text = $('input#association_name').val();
text = text.toLowerCase();
// Regex to whitelist organisation name to generate a subdomain
// Obviously, we still need to validate this in the app
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 88.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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