3scale/porta

View on GitHub

Showing 5,377 of 5,713 total issues

Method provider_request has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

  def provider_request
    return unless provider?

    hourly(&:group)

Severity: Minor
Found in lib/tracking_notifications.rb - About 7 hrs 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

Class Cinstance has 52 methods (exceeds 20 allowed). Consider refactoring.
Open

class Cinstance < Contract
  include SaveDestroyForServiceAssociation
  # Maximum number of cinstances permitted between provider and buyer
  MAX = 10

Severity: Major
Found in app/models/cinstance.rb - About 7 hrs to fix

    Class Plan has 51 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Plan < ApplicationRecord
      include Searchable
      class PeriodRangeCalculationError < StandardError; end
      include Symbolize
    
    
    Severity: Major
    Found in app/models/plan.rb - About 7 hrs to fix

      File service.rb has 435 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'backend_client'
      
      class Service < ApplicationRecord # rubocop:disable Metrics/ClassLength
        include Searchable
        include Backend::ModelExtensions::Service
      Severity: Minor
      Found in app/models/service.rb - About 6 hrs to fix

        File invoice.rb has 426 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class Invoice < ApplicationRecord
          %I[due_on period issued_on last_charging_retry].each do |attr|
            attribute attr, :date
          end
        
        
        Severity: Minor
        Found in app/models/invoice.rb - About 6 hrs to fix

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            markCurrentPlan: function(planPreviewBoxId){
              var box = $('#' + planPreviewBoxId);
          
              var $current = box.find('div.plan-preview[data-plan-id="' + this.currentPlan + '"]');
              $(".current-plan-notice").hide();
          lib/developer_portal/app/assets/javascripts/plans_widget.js on lines 26..39

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 159.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            markCurrentPlan: function(planPreviewBoxId){
              var box = $('#' + planPreviewBoxId);
          
              var $current = box.find('div.plan-preview[data-plan-id="' + this.currentPlan + '"]');
              $(".current-plan-notice").hide();
          Severity: Major
          Found in lib/developer_portal/app/assets/javascripts/plans_widget.js and 1 other location - About 6 hrs to fix
          lib/developer_portal/app/assets/javascripts/plans_widget_v2.js on lines 37..50

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 159.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Class Account has 43 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class Account < Drops::Model
          
                info %{
          A developer account. See `User` drop if you are looking for the email addresses or similar information.
                }
          Severity: Minor
          Found in lib/developer_portal/lib/liquid/drops/account.rb - About 5 hrs to fix

            File account.rb has 403 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class Account < ApplicationRecord
              attribute :credit_card_expires_on, :date
              self.ignored_columns = %i[proxy_configs_file_name proxy_configs_content_type proxy_configs_file_size
                                        proxy_configs_updated_at proxy_configs_conf_file_name proxy_configs_conf_content_type
                                        proxy_configs_conf_file_size proxy_configs_conf_updated_at]
            Severity: Minor
            Found in app/models/account.rb - About 5 hrs to fix

              Method error_messages_for has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                def error_messages_for(*params)
                  ignore_me = ['Account is invalid', 'Bought cinstances is invalid']
                  options = params.extract_options!.symbolize_keys
              
                  objects = if object = options.delete(:object)
              Severity: Minor
              Found in app/helpers/application_helper.rb - About 5 hrs 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

              File 20100125103539_browser_cms_tables.rb has 398 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class BrowserCmsTables < ActiveRecord::Migration
                def self.up
                  create_table "attachment_versions", :force => true do |t|
                    t.integer  "attachment_id"
                    t.integer  "version"
              Severity: Minor
              Found in db/migrate/20100125103539_browser_cms_tables.rb - About 5 hrs to fix

                File user.rb has 389 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require 'digest/sha1'
                
                class User < ApplicationRecord
                  include Symbolize
                
                
                Severity: Minor
                Found in app/models/user.rb - About 5 hrs to fix

                  Class Application has 40 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class Application < Drops::Contract
                        drop_example "Using application drop in liquid.", %{
                          <h1>Application {{ application.name }} (<span title="Application ID">{{ application.application_id }}</span>)</h1>
                          <p>{{ application.description }}</p>
                        }
                  Severity: Minor
                  Found in lib/developer_portal/lib/liquid/drops/application.rb - About 5 hrs to fix

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      showPlan: function(previewBoxId, planID){
                        var box = $('#' + previewBoxId);
                    
                        if(typeof(planID) == 'undefined'){
                          planID = this.currentPlan;
                    Severity: Major
                    Found in lib/developer_portal/app/assets/javascripts/plans_widget.js and 1 other location - About 5 hrs to fix
                    lib/developer_portal/app/assets/javascripts/plans_widget_v2.js on lines 57..69

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 141.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      showPlan: function(previewBoxId, planID){
                        var box = $('#' + previewBoxId);
                    
                        if(typeof(planID) == 'undefined'){
                          planID = this.currentPlan;
                    lib/developer_portal/app/assets/javascripts/plans_widget.js on lines 46..58

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 141.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Method up has 128 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def self.up
                          create_table :blogs do |t|
                            t.string :name
                            t.string :format
                            t.text :template
                    Severity: Major
                    Found in db/migrate/20100216080646_cms_blog.rb - About 5 hrs to fix

                      Class BillingStrategy has 37 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Finance::BillingStrategy < ApplicationRecord
                        module NonAuditedColumns
                          def non_audited_columns
                            super - [inheritance_column]
                          end
                      Severity: Minor
                      Found in app/models/finance/billing_strategy.rb - About 4 hrs to fix

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

                          def charge!(automatic = true)
                            ensure_payable_state!
                        
                            unless chargeable?
                              logger.info "Not charging invoice #{id} (buyer #{buyer_account_id}), reason: #{reason_cannot_charge}"
                        Severity: Minor
                        Found in app/models/invoice.rb - About 4 hrs 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 clause has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def clause(*args)
                                model    = (args.length >= 2 ? args[0] : nil)
                                is_delta = (args.length >= 2 ? args[1] : args[0]) || false
                        
                                table_name  = (model.nil? ? adapter.quoted_table_name   : model.quoted_table_name)
                        Severity: Minor
                        Found in config/initializers/oracle.rb - About 4 hrs 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

                        Class NotificationMailer has 35 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class NotificationMailer < ActionMailer::Base
                          default from: Rails.configuration.three_scale.notification_email
                        
                          layout 'notification_email'
                        
                        
                        Severity: Minor
                        Found in app/mailers/notification_mailer.rb - About 4 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language