SumOfUs/Champaign

View on GitHub

Showing 157 of 338 total issues

Method csv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def csv
    rows = @actions.map do |action|
      keys.map do |k|
        value = val(k, action)
        value.is_a?(String) && value.index(COMMA).present? ? "\"#{value}\"" : value
Severity: Minor
Found in app/services/action_collator.rb - About 35 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 round_fundraising_goals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def round_fundraising_goals(values)
      values.map do |value|
        value = value.to_f
        if value.zero?
          value
Severity: Minor
Found in app/lib/donations/utils.rb - About 35 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 member_phone_number_is_valid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def member_phone_number_is_valid
    return if member_phone_number.blank?

    valid_characters = (/\A[0-9\-\+\(\) \.]+\z/i =~ member_phone_number).present?
    has_at_least_six_numbers = (member_phone_number.scan(/[0-9]/).size > 5)
Severity: Minor
Found in app/models/call.rb - About 35 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

Avoid too many return statements within this function.
Open

      return {
        ...state,
        recurring: action.payload,
        showDirectDebit,
        localPaymentTypes,
Severity: Major
Found in app/javascript/state/fundraiser/reducer.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return {
            ...state,
            ...featuredAmountState(preselectAmount, { donationBands, currency }),
            currency,
            donationBands,
    Severity: Major
    Found in app/javascript/state/fundraiser/reducer.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return {
              ...state,
              ...data,
              showDirectDebit,
              localPaymentTypes,
      Severity: Major
      Found in app/javascript/state/fundraiser/reducer.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return {
                ...state,
                directDebitOnly: action.payload,
                paymentTypes,
                currentPaymentType,
        Severity: Major
        Found in app/javascript/state/fundraiser/reducer.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return {
                  ...state,
                  form,
                  formValues,
                  outstandingFields,
          Severity: Major
          Found in app/javascript/state/fundraiser/reducer.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return {
                    ...state,
                    currentPaymentType: safePaymentType(action.payload, state.paymentTypes),
                  };
            Severity: Major
            Found in app/javascript/state/fundraiser/reducer.js - About 30 mins to fix

              Function triggerRegistrationSuccessEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                triggerRegistrationSuccessEvent(data) {
                  const tracking = data.tracking;
                  const member = window.champaign.personalization.member;
                  if (tracking && !member.id) {
                    if (typeof window.fbq === 'function') {

              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 update_page has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def update_page
                  return unless @params[:page]
              
                  plugins_before = @page.plugins
              
              
              Severity: Minor
              Found in app/services/page_updater.rb - About 25 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 search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def search
                  @queries.each_pair do |search_type, query|
                    next unless query.present?
              
                    case search_type.to_sym
              Severity: Minor
              Found in app/services/search/page_searcher.rb - About 25 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 express_payment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def express_payment
                  @page = Page.find(params[:page_id])
                  @follow_up_url = ''
              
                  begin
              Severity: Minor
              Found in app/controllers/api/payment/braintree_controller.rb - About 25 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

              Function showOneOffButton has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                showOneOffButton() {
                  if (this.state.recurringDonor) {
                    return true;
                  } else {
                    if (this.state.recurringDefault === 'only_one_off') {
              Severity: Minor
              Found in app/javascript/components/Payment/Payment.js - About 25 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 place_call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def place_call
                  client = Twilio::REST::Client.new(Settings.twilio.account_sid, Settings.twilio.auth_token)
                  params = {
                    from: call.caller_id,
                    to: call.member_phone_number,
              Severity: Minor
              Found in app/services/call_creator.rb - About 25 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 genuine_user? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def genuine_user?
                  unless user.has_account?
                    return true if email_account_exist?(email)
              
                    log_error_message('Recaptcha: Failed, UserAccountNotExist, EmailAccountExistence: false', true)
              Severity: Minor
              Found in app/services/payment_request_authorizer.rb - About 25 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 import has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def import
                  return false unless valid?
              
                  begin
                    funds = JSON.parse(File.read(file.tempfile))
              Severity: Minor
              Found in app/services/pension_funds_json_importer.rb - About 25 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

              Function render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                render() {
                  if (!this.props.paymentMethods.length || this.props.hidden) return null;
              
                  return (
                    <div className="ExpressDonation">
              Severity: Minor
              Found in app/javascript/components/ExpressDonation/ExpressDonation.js - About 25 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

              Function updateSummaryRows has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                updateSummaryRows: function(data) {
                  // this only updates existing shares. new ones are appended by
                  // code in view/share/shares/create.js.erb, using rails UJS
                  $.get(`/api/pages/${data.id}/share-rows`, rows => {
                    _.each(rows, row => {
              Severity: Minor
              Found in app/javascript/legacy/campaigner_facing/shares_editor.js - About 25 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 location has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def location
                  return @location if @location.blank?
              
                  country_code = if @member.try(:country) && @member.country.length == 2
                                   @member.country
              Severity: Minor
              Found in app/liquid/liquid_renderer.rb - About 25 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