3scale/porta

View on GitHub

Showing 5,380 of 5,717 total issues

Class FrontendController has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class FrontendController < ApplicationController
  SecureHeaders::Configuration.override(:disable_x_frame) do |config|
    config.x_frame_options = SecureHeaders::OPT_OUT
  end

Severity: Minor
Found in app/controllers/frontend_controller.rb - About 2 hrs to fix

    Class Contract has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Contract < ApplicationRecord
      # Need to define table_name before audited because of
      # https://github.com/collectiveidea/audited/blob/f03c5b5d1717f2ebec64032d269316dc74476056/lib/audited/auditor.rb#L305-L311
      self.table_name = 'cinstances'
    
    
    Severity: Minor
    Found in app/models/contract.rb - About 2 hrs to fix

      Class ClientBase has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class ClientBase
            class ClientError < StandardError
              include Bugsnag::MetaData
      
              def initialize(error_message, options = {})
      Severity: Minor
      Found in app/lib/three_scale/oauth2/client_base.rb - About 2 hrs to fix

        Method assert_line_items has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def assert_line_items(items)
          items.hashes.each_with_index do |line, i|
            name = line['name']
            cost = line['cost']
            cost = /#{cost}\./ unless cost.include?('.')
        Severity: Minor
        Found in features/step_definitions/finance/invoicing_steps.rb - About 2 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 email_template.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class CMS::EmailTemplate < CMS::Template
        
          validates :system_name, presence: true
          validates :current, presence: true
          validates :system_name, uniqueness: { scope: %i[provider_id], allow_blank: true, case_sensitive: true }
        Severity: Minor
        Found in app/models/cms/email_template.rb - About 2 hrs to fix

          Class Event has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Event
              class Error < ::StandardError; end
              class MissingResourceError < Error; end
          
              # This object represents one webhook event
          Severity: Minor
          Found in app/models/web_hook/event.rb - About 2 hrs to fix

            Class Section has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class CMS::Section < ApplicationRecord
              include ThreeScale::Search::Scopes
              include CMS::Filtering
              extend System::Database::Scopes::IdOrSystemName
              include NormalizePathAttribute
            Severity: Minor
            Found in app/models/cms/section.rb - About 2 hrs to fix

              Class ApplicationKey has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class ApplicationKey < ApplicationRecord
                include SaveDestroyForApplicationAssociation
              
                KEYS_LIMIT = 5
              
              
              Severity: Minor
              Found in app/models/application_key.rb - About 2 hrs to fix

                Class ApplicationsController has 21 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class DeveloperPortal::Admin::ApplicationsController < ::DeveloperPortal::BaseController
                  self.responder = ThreeScale::Api::Responder
                
                  include Liquid::TemplateSupport
                
                

                  Class SimpleLayout has 21 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class SimpleLayout
                  
                    attr_reader :provider
                  
                    def initialize(provider)
                  Severity: Minor
                  Found in app/lib/simple_layout.rb - About 2 hrs to fix

                    Class Service has 21 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        class Service < Drops::Model
                    
                          allowed_name :service
                    
                          def initialize(service, opts = {})
                    Severity: Minor
                    Found in lib/developer_portal/lib/liquid/drops/service.rb - About 2 hrs to fix

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

                              def verify!(object)
                      
                                # this controller shouldnt be checked
                                return true if @env["action_controller.request.path_parameters"]["controller"] == "provider/domains"
                      
                      
                      Severity: Minor
                      Found in lib/three_scale/middleware/multitenant.rb - About 2 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

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

                           if ($("#fields_definition_required")[0].checked){
                             $("#fields_definition_hidden")[0].checked=false;
                             $("#fields_definition_read_only")[0].checked=false;
                             $("#fields_definition_hidden").attr('disabled',true);
                             $("#fields_definition_read_only").attr('disabled',true);
                      Severity: Major
                      Found in app/assets/javascripts/application.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/application.js on lines 98..104

                      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 74.

                      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

                                 if (($("#fields_definition_required").size() != 0 ) &&
                                 ($("#fields_definition_required")[0].checked)){
                                   $("#fields_definition_hidden")[0].checked=false;
                                   $("#fields_definition_read_only")[0].checked=false;
                                   $("#fields_definition_hidden").attr('disabled',true);
                      Severity: Major
                      Found in app/assets/javascripts/application.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/application.js on lines 122..131

                      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 74.

                      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 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.up
                          create_table :contracts do |t|
                            t.column :id, :int, :null => false, :autoincrement => true
                            
                            #the provider
                      Severity: Minor
                      Found in db/migrate/011_create_contracts.rb - About 1 hr to fix

                        Method down has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.down
                            create_table "news_article_versions", :force => true do |t|
                              t.integer  "news_article_id"
                              t.integer  "version"
                              t.string   "name"
                        Severity: Minor
                        Found in db/migrate/20120109110445_removing_the_news_portlets.rb - About 1 hr to fix

                          Method freeze_closed_invoices has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def self.freeze_closed_invoices
                                Invoice.reset_column_information
                                all = Invoice.count
                                count = 0
                          
                          
                          Severity: Minor
                          Found in lib/migration/finance.rb - About 1 hr to fix

                            Method to_xml has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def to_xml(options = {})
                                result = options[:builder] || ThreeScale::XML::Builder.new
                            
                                result.application do |xml|
                                  unless new_record?
                            Severity: Minor
                            Found in app/models/cinstance.rb - About 1 hr to fix

                              Method down has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def self.down
                                  create_table :liquid_pages do |table|
                                    table.integer :account_id
                                    table.string  :title
                                    table.text    :content

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

                                  def self.up
                                    pages = LiquidPage.find_all_by_title('layout')
                                    pages.each do |page|
                                      puts "Hacking layout of: #{page.account.try!(:org_name)}"
                                
                                
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language