oneclickorgs/one-click-orgs

View on GitHub

Showing 65 of 108 total issues

Method dashboard has a Cognitive Complexity of 12 (exceeds 5 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

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 create has a Cognitive Complexity of 11 (exceeds 5 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

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 to_pdf has a Cognitive Complexity of 11 (exceeds 5 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: Minor
Found in app/models/registration_form.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

Method create_default_member_classes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_default_member_classes
    members = member_classes.find_or_create_by_name('Member')
    members.set_permission!(:resolution_proposal, true)
    members.set_permission!(:vote, true)

Severity: Minor
Found in app/models/coop.rb - About 1 hr to fix

    Method index has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def index
        case co
        when Association
          @page_title = "Members"
          @members = co.members.active
    Severity: Minor
    Found in app/controllers/members_controller.rb - About 1 hr to fix

      Method create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          HANDLED_RESOLUTION_TYPES.each do |resolution_type|
            if params[resolution_type]
              resolution_class = co.send(resolution_type.to_s.pluralize)
              resolution_parameters = params[resolution_type] || {}
      Severity: Minor
      Found in app/controllers/resolutions_controller.rb - About 1 hr to fix

        Method create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create
            @commentable = if params[:proposal_id]
              co.proposals.find(params[:proposal_id])
            elsif params[:meeting_id]
              co.meetings.find(params[:meeting_id])
        Severity: Minor
        Found in app/controllers/comments_controller.rb - About 1 hr to fix

          Method generate_pdf has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def generate_pdf(filename='Download', options={})
              options = {
                :header_right => "Printed on #{Time.now.utc.to_s(:long_date)}",
                :header_line => true
              }.with_indifferent_access.merge(options)
          Severity: Minor
          Found in app/controllers/application_controller.rb - About 1 hr to fix

            Method after_initialize has 28 lines of code (exceeds 25 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 1 hr to fix

              Method name_for_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.name_for_value(value)
                  value = value.to_i
                  case value
                  when 0..3600
                    minutes = (value / 60.0).round
              Severity: Minor
              Found in app/models/voting_periods.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

              Method prepare_notifications has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def prepare_notifications
                  return unless current_user
              
                  # If you have a notification you want to show the user, put the
                  # logic in here, and the template in shared/notifications.
              Severity: Minor
              Found in app/controllers/application_controller.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

              Method passed_resolutions_attributes= has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def passed_resolutions_attributes=(attributes)
                  @resolutions_to_pass = []
                  @resolutions_to_record_additional_votes = []
              
                  attributes.values.each do |v|
              Severity: Minor
              Found in app/models/general_meeting.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

              Method generate_csv has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def generate_csv
                  case co
                  when Association
                    # Only Associations use the 'inducted_at' field.
                    headers = ["First name", "Last name", "Email", "Date joined", "Time of last login"]
              Severity: Minor
              Found in app/controllers/members_controller.rb - About 1 hr to fix

                Method after_initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def after_initialize
                    # TODO ? only use constitution's original values as defaults; allow
                    # new values to be passed in via the attributes
                    case organisation
                    when Association
                Severity: Minor
                Found in app/models/constitution_wrapper.rb - About 1 hr to fix

                  Method edit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def edit
                      @page_title = "Amendments"
                  
                      case co
                      when Association
                  Severity: Minor
                  Found in app/controllers/constitutions_controller.rb - About 55 mins 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 notify_foundation_decision has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def notify_foundation_decision(member, decision)
                      default_url_options[:host] = member.organisation.domain(:only_host => true)
                  
                      @decision = decision
                      @member = member
                  Severity: Minor
                  Found in app/mailers/decision_mailer.rb - About 55 mins 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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def create
                      HANDLED_RESOLUTION_TYPES.each do |resolution_type|
                        if params[resolution_type]
                          resolution_class = co.send(resolution_type.to_s.pluralize)
                          resolution_parameters = params[resolution_type] || {}
                  Severity: Minor
                  Found in app/controllers/resolutions_controller.rb - About 55 mins 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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def create
                      @commentable = if params[:proposal_id]
                        co.proposals.find(params[:proposal_id])
                      elsif params[:meeting_id]
                        co.meetings.find(params[:meeting_id])
                  Severity: Minor
                  Found in app/controllers/comments_controller.rb - About 55 mins 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 attributes_for_resolutions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def attributes_for_resolutions
                      result = []
                      [:user, :employee, :supporter, :producer, :consumer].each do |member_type|
                        method = member_type.to_s + '_members'
                        if send(method) == '1'
                  Severity: Minor
                  Found in app/models/change_membership_criteria_resolution.rb - About 45 mins 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_transition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def after_transition(member, transition)
                      case transition.event
                      when :induct
                        case member.organisation
                        when Coop
                  Severity: Minor
                  Found in app/observers/member_mailer_observer.rb - About 45 mins 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