SumOfUs/Champaign

View on GitHub

Showing 157 of 338 total issues

Function sendEmail has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const sendEmail = async params => {
  const data = {
    email: {
      body: params.body,
      recipients: params.recipients,
Severity: Minor
Found in app/javascript/modules/EmailParliament/api.js - About 1 hr to fix

    Function componentDidMount has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async componentDidMount() {
        if (window.dataLayer) {
          await window.dataLayer.push({
            event: unintendedDonationsExperiment.activationEvent,
          });
    Severity: Minor
    Found in app/javascript/plugins/fundraiser/FundraiserView.js - About 1 hr to fix

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

        render() {
          return (
            <div>
              <form className="form-inline" onSubmit={this.handleSubmit.bind(this)}>
                <div className="input-group">
      Severity: Minor
      Found in app/javascript/legacy/campaigner_facing/emails.js - About 1 hr to fix

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

          render() {
            const formClassNames = classnames({
              'action-form': true,
              'form--big': true,
              'single-country': !!this.props.restrictedCountryCode,
        Severity: Minor
        Found in app/javascript/components/CallTool/Form.js - About 1 hr to fix

          Function init has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const init = options => {
            if (!options.el) {
              options.el = document.getElementById('call-tool-component');
            }
            const { el, store } = options;
          Severity: Minor
          Found in app/javascript/plugins/call_tool/index.tsx - About 1 hr to fix

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

              render() {
                const className = classnames('sweet-placeholder', this.props.className);
                const labelClassName = classnames({
                  'sweet-placeholder__label': true,
                  'sweet-placeholder__label--full':
            Severity: Minor
            Found in app/javascript/components/SweetInput/SweetInput.js - About 1 hr to fix

              Function componentDidMount has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                async componentDidMount() {
                  if (window.dataLayer) {
                    await window.dataLayer.push({
                      event: unintendedDonationsExperiment.activationEvent,
                    });
              Severity: Minor
              Found in app/javascript/plugins/fundraiser/FundraiserView.js - 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

              Function handleSuccess has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                handleSuccess(e, data) {
                  ee.emit('petition:submitted');
              
                  const tracking = data.tracking;
                  const member = window.champaign.personalization.member;
              Severity: Minor
              Found in app/javascript/legacy/member-facing/backbone/petition.js - About 1 hr to fix

                Function paymentOptionsView has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  paymentOptionsView() {
                    return (
                      <div className="OneClick">
                        <div className="StepWrapper-root">
                          <div className="overlay-toggle__mobile-ui">
                Severity: Minor
                Found in app/javascript/components/OneClick/OneClick.js - About 1 hr to fix

                  Function composeEmailLink has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function composeEmailLink(email) {
                    const sanitizedToEmails = buildToEmailForCompose(
                      email.toEmails,
                      email.emailService
                    );
                  Severity: Minor
                  Found in app/javascript/util/util.js - About 1 hr to fix

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

                      render() {
                        const {
                          alwaysShow,
                          consented,
                          active,
                    Severity: Minor
                    Found in app/javascript/components/consent/ConsentComponent.js - About 1 hr to fix

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

                        def create
                          # TODO: Move form validator to ManageAction
                          validator = FormValidator.new(action_params.to_h)
                          action_params[:source] = action_params[:source] || detect_source
                      
                      
                      Severity: Minor
                      Found in app/controllers/api/actions_controller.rb - About 1 hr to fix

                        Function onSubmit has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          const onSubmit = async e => {
                            e.preventDefault();
                        
                            const valid = validateForm();
                            if (!valid) return;
                        Severity: Minor
                        Found in app/javascript/modules/EmailParliament/EmailComposer.js - About 1 hr to fix

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

                            render() {
                              const className = classnames('sweet-placeholder__label', {
                                'sweet-placeholder__label--full':
                                  !!this.props.value && !this.state.focused,
                                'sweet-placeholder__label--active': this.state.focused,
                          Severity: Minor
                          Found in app/javascript/components/SweetSelect/SweetSelect.js - About 1 hr to fix

                            Function InlineConsentRadiobuttons has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export default function InlineConsentRadiobuttons(props: IProps) {
                              const member = useSelector((state: IAppState) => state.member);
                              if (member && member.email) {
                                return null;
                              }
                            Severity: Minor
                            Found in app/javascript/components/consent/InlineConsentRadioButtons.tsx - About 1 hr to fix

                              Function componentDidUpdate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                componentDidUpdate(prevProps) {
                                  if (
                                    prevProps.experiments.length == 0 &&
                                    this.props.experiments.length > 0
                                  ) {
                              Severity: Minor
                              Found in app/javascript/plugins/fundraiser/FundraiserView.js - 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

                              Function getEventData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              const getEventData = (eventName, ...data) => {
                                switch (eventName) {
                                  case 'action:submitted_success':
                                    return ['action', 'submitted_success'];
                                  case '@@chmp:consent:change_country':
                              Severity: Minor
                              Found in app/javascript/util/log_event.js - 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 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def create
                                  # TODO: Move form validator to ManageAction
                                  validator = FormValidator.new(action_params.to_h)
                                  action_params[:source] = action_params[:source] || detect_source
                              
                              
                              Severity: Minor
                              Found in app/controllers/api/actions_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 previous_action has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def previous_action
                                  return nil unless existing_member.present?
                              
                                  @previous_action ||= Action.not_donation.where(member: existing_member, page_id: page).first
                              
                              
                              Severity: Minor
                              Found in app/services/manage_action.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 data_for_view has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def data_for_view(page, supplemental_data = {})
                                    default_ref = 'default'
                                    plugins_data = page.plugins.inject({}) do |memo, plugin|
                                      if plugin
                                        plugin_name = plugin.name.underscore
                              Severity: Minor
                              Found in app/models/plugins.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