3scale/porta

View on GitHub

Showing 308 of 5,717 total issues

Avoid too many return statements within this method.
Open

    return false unless cms.admin?
Severity: Major
Found in lib/developer_portal/lib/cms/toolbar.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return if @env["action_controller.request.query_parameters"]["provider_key"] == @master.api_key
    Severity: Major
    Found in lib/three_scale/middleware/multitenant.rb - About 30 mins to fix

      Method charge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def charge!(amount, options = {})
          unless credit_card_stored?
            logger.info("Buyer #{self.id} was not charged: credit card missing")
            raise Finance::Payment::CreditCardMissing
          end
      Severity: Minor
      Found in app/models/account/billing.rb - About 25 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          user = domain_account.users.find_by_activation_code(activation_code)
      
          return redirect_to provider_login_path unless user
      
      
      Severity: Minor
      Found in app/controllers/provider/activations_controller.rb - About 25 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 numberPadding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        numberPadding: function(number, decimals){
          var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals,
              d = ".",
              t = ",",
              i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
      Severity: Minor
      Found in app/assets/javascripts/threescale.js - About 25 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 deliver_approved_notification has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def deliver_approved_notification
          if buyer? && approval_required?
            unless admins.empty? || admins.first.created_by_provider_signup?
              run_after_commit do
                AccountMailer.approved(self).deliver_later
      Severity: Minor
      Found in app/models/account/states.rb - About 25 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(provider_account, cinstance, service)
      
            # If we got object which responds to id - it is AR object
            # we wan't to cache it and do not query DB again
            # but in case it is id, we will load it - check #provider_account and others
      Severity: Minor
      Found in app/models/backend/cinstance_data.rb - About 25 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 default_service_plan_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def default_service_plan_state
          return unless account && account.provider_can_use?(:published_service_plan_signup)
          return if account.should_be_deleted?
          account.settings.service_plans_ui_visible? ? 'hidden' : 'published'
        end
      Severity: Minor
      Found in app/models/service.rb - About 25 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 next_available_friendly_id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def next_available_friendly_id(month, step = 1)
          return unless month
          id_prefix = billing_monthly? ? month : month.begin.year
      
          last_of_period = Invoice.by_provider(account)
      Severity: Minor
      Found in app/models/finance/billing_strategy.rb - About 25 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 dateFormat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          dateFormat: function(format, timestamp, capitalize) {
              function pad (number) {
                  return number.toString().replace(/^([0-9])$/, '0$1');
              }
      
      
      Severity: Minor
      Found in app/assets/javascripts/threescale.js - About 25 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 attach_layout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def attach_layout
            return unless resource_class == CMS::Page
      
            layout = find_layout
            if layout.present?
      Severity: Minor
      Found in app/services/admin/api/cms/template_service.rb - About 25 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 fetch_policies_from_apicast has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def fetch_policies_from_apicast
          begin
            response = ::JSONClient.get(apicast_registry_url)
          rescue *HTTP_ERRORS => error
            error_message = 'Please provide an apicast registry url in your configuration.' if apicast_registry_url.blank?
      Severity: Minor
      Found in app/services/policies/policies_list_service.rb - About 25 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_user? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def push_user?
            return true unless user
      
            # return if providers accounts do not match
            return unless resource.provider_account == self.provider
      Severity: Minor
      Found in app/models/web_hook/event.rb - About 25 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 human_filesize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def human_filesize(bytes)
          amount, units = bytes, 'bytes'
          kilos = bytes / 1024
          if kilos > 1
            amount, units = kilos, 'KB'
      Severity: Minor
      Found in app/helpers/file_size_helper.rb - About 25 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 attach_section has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def attach_section(template)
            return unless type == :page
      
            section = find_section
            if section.present?
      Severity: Minor
      Found in app/services/admin/api/cms/template_service.rb - About 25 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 process! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def process!(credit_card_auth_code, gateway, options)
          unless System::Application.config.three_scale.payments.enabled
            logger.info "Skipping payment transaction #process! - not in production"
            return
          end
      Severity: Minor
      Found in app/models/payment_transaction.rb - About 25 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 cost_for_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def cost_for_value(value)
          if value < min
            0
          elsif value == max && value == min
            cost_per_unit
      Severity: Minor
      Found in app/models/pricing_rule.rb - About 25 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 add_remove_by_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_remove_by_ids( model_type, inside_ids)
          all = provider.send(model_type.to_s.pluralize)
          inside = self.send(model_type.to_s.pluralize)
      
          inside_ids = (inside_ids || []).uniq
      Severity: Minor
      Found in app/models/cms/section.rb - About 25 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 find_cinstance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_cinstance
          begin
            @cinstance = if current_account.buyer?
                           #TODO: this allows a buyer to pass any app_id, and it will show no matter the app not being 'live'
                           if params[:application_id]
      Severity: Minor
      Found in app/controllers/stats/api/applications_controller.rb - About 25 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 notify_entitlements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def notify_entitlements
          return unless entitlements_notification_enabled?
      
          if plan_downgrade? || recently_suspended?
            notify_entitlements_revoked
      Severity: Minor
      Found in app/services/support_entitlements_service.rb - About 25 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