oneclickorgs/one-click-orgs

View on GitHub

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
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

                    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 {
                    app/assets/javascripts/change_quorum_resolutions.js on lines 4..12

                    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

                    Further Reading

                    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 {
                    Severity: Major
                    Found in app/assets/javascripts/change_quorum_resolutions.js and 1 other location - About 3 hrs to fix
                    app/assets/javascripts/change_meeting_notice_period_resolutions.js on lines 21..29

                    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

                    Further Reading

                    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

                      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
                      Severity: Major
                      Found in app/assets/javascripts/coops_new.js and 1 other location - About 2 hrs to fix
                      app/assets/javascripts/associations_new.js on lines 11..18

                      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

                      Further Reading

                      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
                      Severity: Major
                      Found in app/assets/javascripts/associations_new.js and 1 other location - About 2 hrs to fix
                      app/assets/javascripts/coops_new.js on lines 5..12

                      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

                      Further Reading

                      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
                        Severity
                        Category
                        Status
                        Source
                        Language