SumOfUs/Champaign

View on GitHub

Showing 157 of 338 total issues

Function click has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          click: function() {
            function clearSelection() {
              if (document.selection) {
                document.selection.empty();
              } else if (window.getSelection) {
Severity: Minor
Found in app/javascript/packs/summernote-rtl-plugin.js - About 1 hr to fix

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

      render() {
        const prefix = 'BraintreeCardFields';
        const classNames = classnames({
          [prefix]: true,
          [`${prefix}--active`]: this.props.isActive,
    Severity: Minor
    Found in app/javascript/components/Braintree/BraintreeCardFields.js - About 1 hr to fix

      Function configureWysiwyg has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function configureWysiwyg(id, editorOptions = []) {
        const $editor = $('#' + id);
        if ($editor.length === 0) {
          return;
        }
      Severity: Minor
      Found in app/javascript/legacy/campaigner_facing/configure_wysiwyg.js - About 1 hr to fix

        Function submit has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          submit(event) {
            if (event) event.preventDefault();
            const donationAmount = this.props.amount;
            this.resetErrors();
        
        
        Severity: Minor
        Found in app/javascript/components/Braintree/BraintreeCardFields.js - About 1 hr to fix

          Function configureStore has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const configureStore = (data, dispatch) => {
            const search = qs.parse(location.search, {
              arrayFormat: 'bracket',
            });
            dispatch({
          Severity: Minor
          Found in app/javascript/plugins/fundraiser/utils.ts - About 1 hr to fix

            Function SearchByPostcode has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const SearchByPostcode = props => {
              const [loading, setLoading] = useState(false);
              const [error, setError] = useState(false);
              const [postcode, setPostcode] = useState(null);
              const [input, setInput] = useState('');
            Severity: Minor
            Found in app/javascript/modules/EmailParliament/SearchByPostcode.js - About 1 hr to fix

              Function constructor has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                constructor(props) {
                  super(props);
                  const lang = window.champaign.page.language_code;
                  this.state = {
                    hostedFields: null,
              Severity: Minor
              Found in app/javascript/components/Braintree/BraintreeCardFields.js - About 1 hr to fix

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

                  render() {
                    const { errors } = this.state;
                    return (
                      <div>
                        {this.props.title && <h1> {this.props.title} </h1>}
                Severity: Minor
                Found in app/javascript/plugins/call_tool/CallToolView.js - About 1 hr to fix

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

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

                    Function Thermometer has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function Thermometer(props) {
                      // Only render if active
                      if (isEmpty(props) || !props.active) return null;
                      const currency = props.currency;
                      const goal = props.goals[currency];
                    Severity: Minor
                    Found in app/javascript/components/Thermometer.js - About 1 hr to fix

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

                        render() {
                          const { consented, showConsentRequired } = this.props;
                          const wrapperClass = classnames('ConsentControls', {
                            warning: showConsentRequired,
                          });
                      Severity: Minor
                      Found in app/javascript/components/consent/ConsentControls.js - About 1 hr to fix

                        Method choices_is_valid has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def choices_is_valid
                            return if choices.nil?
                        
                            if choices.class != Array
                              errors.add(:choices, 'must be an array of options')
                        Severity: Minor
                        Found in app/models/form_element.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

                        Function reducer has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const reducer = (state = initialState, action) => {
                          switch (action.type) {
                            case 'email_target:change_submitting':
                              return { ...state, isSubmitting: action.submitting };
                            case 'email_target:change_country':
                        Severity: Minor
                        Found in app/javascript/state/email_pension/actions.js - About 1 hr to fix

                          Function PopupMemberConsent has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export default function PopupMemberConsent(props: IProps) {
                            const member = useSelector((state: IAppState) => state.member);
                            const onClose = () => props.toggleModal(false);
                            const onConsent = e => {
                              e.preventDefault();
                          Severity: Minor
                          Found in app/javascript/components/consent/PopupMemberConsent.tsx - About 1 hr to fix

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

                              render() {
                                return (
                                  <div className="SelectPensionFund">
                                    <FormGroup>
                                      <SelectCountry
                            Severity: Minor
                            Found in app/javascript/plugins/email_pension/SelectPensionFund.js - About 1 hr to fix

                              Function getErrorsByCode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function getErrorsByCode(code) {
                                let errors = [];
                                switch (code) {
                                  case '':
                                  case undefined:
                              Severity: Minor
                              Found in app/javascript/util/getBraintreeErrorMessages.js - About 1 hr to fix

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

                                  render() {
                                    if (!this.props.member || !this.props.isRequiredExisting) return null;
                                    return (
                                      <Popup
                                        open={this.props.open}
                                Severity: Minor
                                Found in app/javascript/components/consent/ExistingMemberConsent.js - About 1 hr to fix

                                  Method search_by_plugin_type has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    def search_by_plugin_type(query)
                                      matches_by_plugins = []
                                      filtered_pages = @collection.pluck(:id)
                                      query.each do |plugin_type|
                                        begin
                                  Severity: Minor
                                  Found in app/services/search/page_searcher.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_action has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def create_action
                                      action_params = {
                                        page: page
                                      }.merge(@extra_attrs)
                                  
                                  
                                  Severity: Minor
                                  Found in app/services/manage_action.rb - About 1 hr to fix

                                    Function renderField has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      renderField(type) {
                                        const fieldProps = this.fieldProps();
                                        const {
                                          field: { default_value, name, choices },
                                        } = this.props;
                                    Severity: Minor
                                    Found in app/javascript/components/FieldShape/FieldShape.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language