SumOfUs/Champaign

View on GitHub

Showing 157 of 338 total issues

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

export default function Form(props: IProps, second?: any) {
  const dispatch = useDispatch();
  const values = useSelector((state: IAppState) => state.forms[props.id]);
  const member = useSelector((state: IAppState) => state.member);
  const [highlightConsent, setHighlightConsent] = React.useState(false);
Severity: Minor
Found in app/javascript/components/Form/index.tsx - 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 render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { amounts } = this.props;
    return (
      <div className="DonationBands-container">
        {amounts.map((amount, i) => (
Severity: Minor
Found in app/javascript/components/DonationBands/DonationBands.js - About 1 hr to fix

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

      def show
        respond_to :html
    
        one_click_processor = process_one_click
    
    
    Severity: Minor
    Found in app/controllers/pages_controller.rb - About 1 hr to fix

      Function setSelectedAmountButton has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function setSelectedAmountButton(payload) {
        return (dispatch, getState) => {
          const state = getState();
          const { selectedAmountButton, donationAmount, isCustomAmount } =
            state.fundraiser || {};
      Severity: Minor
      Found in app/javascript/state/fundraiser/actions.js - About 1 hr to fix

        Function TargetsStatusTable has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function TargetsStatusTable(props) {
          const data = props.data;
          return (
            <table className="table totals">
              <tbody>
        Severity: Minor
        Found in app/javascript/components/CallToolAnalytics/TargetsStatusTable.js - About 1 hr to fix

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

            Method subscription_payload has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def subscription_payload
                  {
                    type: 'donation',
                    payment_provider: 'braintree',
                    params: {
            Severity: Minor
            Found in app/services/action_queue.rb - About 1 hr to fix

              Method total_donations has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def total_donations
                  @page = Page.find(params[:page_id])
              
                  if @page.campaign.blank?
                    amount = @page.total_donations
              Severity: Minor
              Found in app/controllers/api/pages_controller.rb - About 1 hr to fix

                Function PetitionComponent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function PetitionComponent(props: IProps) {
                  const dispatch = useDispatch();
                  const member: IChampaignMember = useSelector((state: any) => state.member);
                  const fields = filterNonEmptyFields(props.config.fields, member);
                
                
                Severity: Minor
                Found in app/javascript/plugins/petition/PetitionComponent.tsx - About 1 hr to fix

                  Method initialize has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def initialize(nonce, amount, currency, user, page_id, store_in_vault, device_data, extra_params)
                  Severity: Major
                  Found in app/lib/payment_processor/braintree/subscription.rb - About 1 hr to fix

                    Method initialize has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                          def initialize(nonce, amount, currency, user, page_id,
                                         store_in_vault = false, device_data = {}, extra_params = {})
                    Severity: Major
                    Found in app/lib/payment_processor/braintree/transaction.rb - About 1 hr to fix

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

                        def redirect_to_donations_experiment
                          return unless @page.published?
                          return unless @page.language_code
                          return unless @page.donation_page?
                          return if user_signed_in?
                      Severity: Minor
                      Found in app/controllers/pages_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

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

                        render() {
                          const {
                            member,
                            onlyRecurring,
                            recurringDonor,
                      Severity: Minor
                      Found in app/javascript/components/Payment/Payment.js - 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 write_subscription has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def write_subscription(subscription_gc_id, amount, currency, page_id, action_id, customer_id, payment_method_id)
                      Severity: Major
                      Found in app/models/payment/go_cardless.rb - About 50 mins to fix

                        Method plugins_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def plugins_config(page)
                            return {} unless page
                        
                            page.plugins.each_with_object({}) do |plugin, hsh|
                              return hsh unless plugin.present?
                        Severity: Minor
                        Found in app/helpers/pages_helper.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

                        Function handleClick has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          handleClick() {
                            const loginHandler = resp => {
                              if (
                                resp.status !== 'connected' ||
                                resp.authResponse.grantedScopes.indexOf('publish_actions') === -1
                        Severity: Minor
                        Found in app/javascript/legacy/member-facing/backbone/facebook_share_view.js - 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 write_subscription has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def write_subscription(payment_method_id, customer_id, subscription_result, page_id, action_id, currency)
                        Severity: Minor
                        Found in app/models/payment/braintree.rb - About 45 mins to fix

                          Method call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def call(env)
                              @status, @headers, @response = @app.call(env)
                              req = Rack::Request.new(env)
                          
                              path_match = PathMatcher.match(req.path)
                          Severity: Minor
                          Found in lib/middleware/pronto.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

                          Function setModeValues has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            setModeValues(mode) {
                              if (!this.hasField('choices', mode)) {
                                this.resetChoices();
                              }
                              if (!this.hasField('defaultValue', mode)) {
                          Severity: Minor
                          Found in app/javascript/legacy/campaigner_facing/form_element_creator.js - 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 push has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def self.push(event, action, mailing_id)
                                case event
                                when :new_action
                                  if action.donation
                                    if action.form_data.fetch('payment_provider', '').inquiry.go_cardless?
                          Severity: Minor
                          Found in app/services/action_queue.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