SumOfUs/Champaign

View on GitHub

Showing 338 of 338 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  return new Promise((resolve, reject) => {
    $.post(`/api/pages/${page_id}/pension_emails`, payload)
      .done((data, textStatus, jqXHR) => {
        // Facebook pixel tracking
        const tracking = data.tracking;
Severity: Major
Found in app/javascript/util/ChampaignClient/MailerClient.js and 1 other location - About 5 hrs to fix
app/javascript/util/ChampaignClient/MailerClient.js on lines 7..25

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

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

Function render has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    if (!this.props.paymentMethods.length || this.props.hidden) return null;

    return (
      <div className="ExpressDonation">
Severity: Major
Found in app/javascript/components/ExpressDonation/ExpressDonation.js - About 5 hrs to fix

    File EmailComposer.js has 385 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useState } from 'react';
    import { FormattedMessage } from 'react-intl';
    import { isEmpty } from 'lodash';
    import { useDispatch, useSelector } from 'react-redux';
    
    
    Severity: Minor
    Found in app/javascript/modules/EmailParliament/EmailComposer.js - About 5 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            this.state.currencyDropdVisible && (
              <select
                value={this.props.currency}
                className="AmountSelection__currency-selector"
                onChange={e => this.onSelectCurrency(e.currentTarget.value)}
      app/javascript/components/AmountSelection/AmountSelection.js on lines 94..108

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

      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

              {this.state.currencyDropdVisible && (
                <select
                  value={this.props.currency}
                  className="AmountSelection__currency-selector"
                  onChange={e => this.onSelectCurrency(e.currentTarget.value)}
      Severity: Major
      Found in app/javascript/components/AmountSelection/AmountSelection.js and 1 other location - About 5 hrs to fix
      app/javascript/components/CurrencySelector/CurrencySelector.js on lines 27..41

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

      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

      Function render has 118 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          const {
            fundraiser: {
              formId,
              fields,
      Severity: Major
      Found in app/javascript/plugins/fundraiser/FundraiserView.js - About 4 hrs to fix

        File reducer.js has 356 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { isEmpty, keys, pick, reduce } from 'lodash';
        import ee from '../../shared/pub_sub';
        
        import { isDirectDebitSupported } from '../../util/directDebitDecider';
        
        
        Severity: Minor
        Found in app/javascript/state/fundraiser/reducer.js - About 4 hrs to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                              <tr>
                                <td>
                                  <span>
                                    <FormattedMessage
                                      id="email_tool.form.copy_email_subject"
          Severity: Major
          Found in app/javascript/modules/EmailParliament/EmailComposer.js and 2 other locations - About 4 hrs to fix
          app/javascript/modules/EmailParliament/EmailComposer.js on lines 319..338
          app/javascript/modules/EmailParliament/EmailComposer.js on lines 359..378

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

          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 3 locations. Consider refactoring.
          Open

                              <tr>
                                <td>
                                  <span>
                                    <FormattedMessage
                                      id="email_tool.form.copy_email_body"
          Severity: Major
          Found in app/javascript/modules/EmailParliament/EmailComposer.js and 2 other locations - About 4 hrs to fix
          app/javascript/modules/EmailParliament/EmailComposer.js on lines 319..338
          app/javascript/modules/EmailParliament/EmailComposer.js on lines 339..358

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

          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 3 locations. Consider refactoring.
          Open

                              <tr>
                                <td>
                                  <span>
                                    <FormattedMessage
                                      id="email_tool.form.copy_target_email_address"
          Severity: Major
          Found in app/javascript/modules/EmailParliament/EmailComposer.js and 2 other locations - About 4 hrs to fix
          app/javascript/modules/EmailParliament/EmailComposer.js on lines 339..358
          app/javascript/modules/EmailParliament/EmailComposer.js on lines 359..378

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

          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

          File ExpressDonation.js has 348 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import $ from 'jquery';
          import React, { Component } from 'react';
          import { connect } from 'react-redux';
          import { FormattedMessage } from 'react-intl';
          import { isEmpty, snakeCase } from 'lodash';
          Severity: Minor
          Found in app/javascript/components/ExpressDonation/ExpressDonation.js - About 4 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                MailerClient.sendPensionEmail({ page_id: this.props.pageId, payload }).then(
                  response => {
                    window.location.href = URI(`${response.data.follow_up_page}`);
                  },
                  ({ errors }) => {
            Severity: Major
            Found in app/javascript/plugins/email_pension/EmailPensionView.js and 1 other location - About 4 hrs to fix
            app/javascript/plugins/email_pension/EmailRepresentativeView.js on lines 115..122

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

            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

                MailerClient.sendPensionEmail({ page_id: this.props.pageId, payload }).then(
                  response => {
                    window.location.href = URI(`${response.data.follow_up_page}`);
                  },
                  ({ errors }) => {
            app/javascript/plugins/email_pension/EmailPensionView.js on lines 210..217

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

            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

            Function render has 101 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render() {
                if (!this.state.data) {
                  return this.renderLoading();
                }
            
            
            Severity: Major
            Found in app/javascript/plugins/call_tool_analytics/CallToolAnalyticsView.js - About 4 hrs to fix

              File action_form.js has 334 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import $ from 'jquery';
              import I18n from 'champaign-i18n';
              import React from 'react';
              import { render } from 'react-dom';
              import _ from 'lodash';
              Severity: Minor
              Found in app/javascript/legacy/member-facing/backbone/action_form.js - About 4 hrs to fix

                Function EmailComposer has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                export function EmailComposer(props) {
                  const dispatch = useDispatch();
                
                  const member = window.champaign.personalization.member;
                  const [name, setName] = useState(member.name || '');
                Severity: Minor
                Found in app/javascript/modules/EmailParliament/EmailComposer.js - About 3 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

                Function render has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  render() {
                    return (
                      <div className="email-target">
                        <div className="email-target-form">
                          <form
                Severity: Major
                Found in app/javascript/plugins/email_pension/EmailRepresentativeView.js - About 3 hrs to fix

                  Similar blocks of code found in 12 locations. Consider refactoring.
                  Open

                    test(`data_type: email => <FormField .../>`, () => {
                      const cnf = { ...config, data_type: 'email' };
                      const wrapper = shallow(<FormField {...cnf} />);
                      const input = wrapper.children();
                  
                  
                  Severity: Major
                  Found in app/javascript/components/Form/FormField.test.tsx and 11 other locations - About 3 hrs to fix
                  app/javascript/components/Form/FormField.test.tsx on lines 45..52
                  app/javascript/components/Form/FormField.test.tsx on lines 54..61
                  app/javascript/components/Form/FormField.test.tsx on lines 63..70
                  app/javascript/components/Form/FormField.test.tsx on lines 72..79
                  app/javascript/components/Form/FormField.test.tsx on lines 81..88
                  app/javascript/components/Form/FormField.test.tsx on lines 90..97
                  app/javascript/components/Form/FormField.test.tsx on lines 99..106
                  app/javascript/components/Form/FormField.test.tsx on lines 108..115
                  app/javascript/components/Form/FormField.test.tsx on lines 117..124
                  app/javascript/components/Form/FormField.test.tsx on lines 126..133
                  app/javascript/components/Form/FormField.test.tsx on lines 135..142

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

                  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 12 locations. Consider refactoring.
                  Open

                    test(`data_type: phone => <FormField .../>`, () => {
                      const cnf = { ...config, data_type: 'phone' };
                      const wrapper = shallow(<FormField {...cnf} />);
                      const input = wrapper.children();
                  
                  
                  Severity: Major
                  Found in app/javascript/components/Form/FormField.test.tsx and 11 other locations - About 3 hrs to fix
                  app/javascript/components/Form/FormField.test.tsx on lines 36..43
                  app/javascript/components/Form/FormField.test.tsx on lines 45..52
                  app/javascript/components/Form/FormField.test.tsx on lines 63..70
                  app/javascript/components/Form/FormField.test.tsx on lines 72..79
                  app/javascript/components/Form/FormField.test.tsx on lines 81..88
                  app/javascript/components/Form/FormField.test.tsx on lines 90..97
                  app/javascript/components/Form/FormField.test.tsx on lines 99..106
                  app/javascript/components/Form/FormField.test.tsx on lines 108..115
                  app/javascript/components/Form/FormField.test.tsx on lines 117..124
                  app/javascript/components/Form/FormField.test.tsx on lines 126..133
                  app/javascript/components/Form/FormField.test.tsx on lines 135..142

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

                  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 12 locations. Consider refactoring.
                  Open

                    test(`data_type: hidden => <FormField .../>`, () => {
                      const cnf = { ...config, data_type: 'hidden' };
                      const wrapper = shallow(<FormField {...cnf} />);
                      const input = wrapper.children();
                  
                  
                  Severity: Major
                  Found in app/javascript/components/Form/FormField.test.tsx and 11 other locations - About 3 hrs to fix
                  app/javascript/components/Form/FormField.test.tsx on lines 36..43
                  app/javascript/components/Form/FormField.test.tsx on lines 45..52
                  app/javascript/components/Form/FormField.test.tsx on lines 54..61
                  app/javascript/components/Form/FormField.test.tsx on lines 63..70
                  app/javascript/components/Form/FormField.test.tsx on lines 81..88
                  app/javascript/components/Form/FormField.test.tsx on lines 90..97
                  app/javascript/components/Form/FormField.test.tsx on lines 99..106
                  app/javascript/components/Form/FormField.test.tsx on lines 108..115
                  app/javascript/components/Form/FormField.test.tsx on lines 117..124
                  app/javascript/components/Form/FormField.test.tsx on lines 126..133
                  app/javascript/components/Form/FormField.test.tsx on lines 135..142

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language