3scale/porta

View on GitHub

Showing 5,299 of 5,637 total issues

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

  def self.down
    change_table :contracts do |t|
      t.string :limit_hits
      t.string :limit_stored
      t.string :limit_transfer
db/migrate/20080731075548_remove_obsolte_columns_from_contracts.rb on lines 2..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 102.

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

  def self.up
    change_table :contracts do |t|
      t.remove :limit_hits
      t.remove :limit_stored
      t.remove :limit_transfer
db/migrate/20080731075548_remove_obsolte_columns_from_contracts.rb on lines 42..79

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

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

Function disableInterface has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     function disableInterface(){
       function enable_checkboxes(){
         checkboxes_disabled(false);
       }

Severity: Major
Found in app/assets/javascripts/application.js - About 2 hrs to fix

    Method extract_range_and_granularity has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

          def extract_range_and_granularity(options)
            if options[:period]
              period = sanitize_period(options[:period])
              granularity = options[:granularity] || GRANULARITIES[period]
              length = 1.send(period)
    Severity: Minor
    Found in app/lib/stats/views/usage.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

    Class Provider has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Provider < Drops::Base
    
          example %(
            <div>Domain {{ provider.domain }}</div>
    
    
    Severity: Minor
    Found in lib/developer_portal/lib/liquid/drops/provider.rb - About 2 hrs to fix

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

        box.find(".select-plan-button").click(function(){
          var planID = $(this).attr('data-plan-id');
          var planName = $(this).attr('data-plan-name');
          box.fadeOut();
          PlanWidget.callback(planName, planID);
      Severity: Major
      Found in lib/developer_portal/app/assets/javascripts/plans_widget.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/provider/plans_widget.js on lines 76..81

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

      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

        box.find(".select-plan-button").click(function(){
          var planID = $(this).attr('data-plan-id');
          var planName = $(this).attr('data-plan-name');
          box.fadeOut();
          PlanWidget.callback(planName, planID);
      Severity: Major
      Found in app/assets/javascripts/provider/plans_widget.js and 1 other location - About 2 hrs to fix
      lib/developer_portal/app/assets/javascripts/plans_widget.js on lines 69..74

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

      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

      File provider_steps.rb has 276 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      def import_simple_layout(provider)
        simple_layout = SimpleLayout.new(provider)
        simple_layout.import_pages!
        simple_layout.import_js_and_css! if @javascript
      end
      Severity: Minor
      Found in features/step_definitions/provider_steps.rb - About 2 hrs to fix

        Class InvoiceReportData has 23 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Pdf::Finance::InvoiceReportData
        
          LINE_ITEMS_HEADING = %w[Name Quantity Cost Charged].freeze
          DATE_FORMAT = "%e %B, %Y"
          LOGO_ATTACHMENT_STYLE = :invoice
        Severity: Minor
        Found in app/lib/pdf/finance/invoice_report_data.rb - About 2 hrs to fix

          File application_helper.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module ApplicationHelper # rubocop:disable Metrics/ModuleLength
          
            # this is used just to not load font awesome in tests
            def capybara_webkit?
              Rails.env.test? && defined?(Capybara.current_driver) && Capybara.current_driver == :webkit
          Severity: Minor
          Found in app/helpers/application_helper.rb - About 2 hrs to fix

            Method friendly_service_setting has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

              def friendly_service_setting service, setting
                value = service.send setting
                message, value = case setting
                                 when :custom_keys_enabled
                  ['Custom application keys are VALUE', value ? 'enabled' : 'disabled']
            Severity: Minor
            Found in app/helpers/api/services_helper.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 rolling_updates.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Logic
              module RollingUpdates
                class UnknownFeatureError < StandardError; end
                class UnknownFeatureConfigError < StandardError
                  include Bugsnag::MetaData
            Severity: Minor
            Found in app/lib/logic/rolling_updates.rb - About 2 hrs to fix

              File simple_layout.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'sprockets'
              require 'compass-rails'
              require 'sass'
              
              class SimpleLayout
              Severity: Minor
              Found in app/lib/simple_layout.rb - About 2 hrs to fix

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

                module Liquid
                  module Drops
                    class Account < Drops::Model
                
                      info %{
                Severity: Minor
                Found in lib/developer_portal/lib/liquid/drops/account.rb - About 2 hrs to fix

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

                  class CMS::Template < ApplicationRecord
                    include Symbolize
                    include ThreeScale::Search::Scopes
                    include CMS::Filtering
                  
                  
                  Severity: Minor
                  Found in app/models/cms/template.rb - About 2 hrs to fix

                    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 ClusterClient has 22 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                        class ClusterClient
                          class ClusterClientError < StandardError; end
                      
                          class ResourceNotFound < ClusterClientError
                            def initialize(resource_type, name, namespace, labels = {})
                      Severity: Minor
                      Found in app/models/service_discovery/cluster_client.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

                            Severity
                            Category
                            Status
                            Source
                            Language