oneclickorgs/one-click-orgs

View on GitHub

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
Severity: Minor
Found in app/models/constitution_proposal_bundle.rb - About 2 days to fix

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
Severity: Major
Found in app/models/constitution_proposal_bundle.rb - About 2 days to fix

    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
    Severity: Major
    Found in app/models/coop.rb - About 1 day to fix

      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]
      
      
      Severity: Minor
      Found in app/models/constitution_wrapper.rb - About 1 day to fix

      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.
      Severity: Major
      Found in app/models/constitution_proposal_bundle.rb - About 1 day to fix

        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
        Severity: Major
        Found in app/models/coop.rb - About 1 day to fix

          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
          Severity: Minor
          Found in app/models/ability.rb - About 1 day to fix

          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
          Severity: Minor
          Found in app/models/constitution_proposal_bundle.rb - About 5 hrs to fix

          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',
          Severity: Minor
          Found in app/models/constitution_proposal_bundle.rb - About 4 hrs to fix

          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',
          Severity: Major
          Found in app/models/constitution_proposal_bundle.rb - About 3 hrs to fix

            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
            Severity: Minor
            Found in app/controllers/application_controller.rb - About 3 hrs to fix

              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]
              
              
              Severity: Major
              Found in app/models/constitution_wrapper.rb - About 3 hrs to fix

                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
                Severity: Major
                Found in app/models/registration_form.rb - About 3 hrs to fix

                  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
                  Severity: Major
                  Found in app/models/ability.rb - About 3 hrs to fix

                    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
                    
                    
                    Severity: Minor
                    Found in app/models/proposal.rb - About 3 hrs to fix

                      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
                      Severity: Minor
                      Found in app/models/member.rb - About 2 hrs to fix

                        Method dashboard has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def dashboard
                        
                            @new_proposal = co.proposals.new
                        
                            case co
                        Severity: Minor
                        Found in app/controllers/one_click_controller.rb - About 1 hr to fix

                          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]
                          Severity: Minor
                          Found in app/models/constitution.rb - About 1 hr to fix

                            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 = []
                            Severity: Minor
                            Found in app/controllers/associations_controller.rb - About 1 hr to fix

                              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
                              Severity: Minor
                              Found in app/models/directorship.rb - About 1 hr to fix

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language