danielweinmann/unlock_moip

View on GitHub

Showing 9 of 12 total issues

Method create has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

  def create

    # Getting the date from Pickadate
    if params[:pickadate_birthdate_submit]
      params[:contribution][:user_attributes][:birthdate] = params[:pickadate_birthdate_submit]
Severity: Minor
Found in app/controllers/unlock_moip/contributions_controller.rb - About 1 day 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 122 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create

    # Getting the date from Pickadate
    if params[:pickadate_birthdate_submit]
      params[:contribution][:user_attributes][:birthdate] = params[:pickadate_birthdate_submit]
Severity: Major
Found in app/controllers/unlock_moip/contributions_controller.rb - About 4 hrs to fix

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

          def state_on_gateway
            begin
              response = Moip::Assinaturas::Subscription.details(self.subscription_code, self.moip_auth)
            rescue
              return nil
    Severity: Minor
    Found in lib/unlock_moip/models/contribution.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 method.
    Open

            return render '/initiatives/contributions/new'
    Severity: Major
    Found in app/controllers/unlock_moip/contributions_controller.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return render '/initiatives/contributions/new'
      Severity: Major
      Found in app/controllers/unlock_moip/contributions_controller.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return redirect_to edit_moip_contribution_path(@contribution)
        Severity: Major
        Found in app/controllers/unlock_moip/contributions_controller.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return render '/initiatives/contributions/new'
          Severity: Major
          Found in app/controllers/unlock_moip/contributions_controller.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return render '/initiatives/contributions/new'
            Severity: Major
            Found in app/controllers/unlock_moip/contributions_controller.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return render '/initiatives/contributions/new'
              Severity: Major
              Found in app/controllers/unlock_moip/contributions_controller.rb - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language