3scale/porta

View on GitHub

Showing 5,269 of 5,606 total issues

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

  def to_xml(options = {})
    xml = options[:builder] || ThreeScale::XML::Builder.new

    xml.__send__(:method_missing, type) do |xml|
      xml.id_           id unless new_record?
Severity: Minor
Found in app/models/metric.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

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

  def create_payment_intent(amount)
    response = gateway.purchase(amount.cents, payment_method_id, gateway_options)

    with_payment_intent_data_from(response) do |payment_intent_data|
      next unless invoice
Severity: Minor
Found in app/services/finance/stripe_charge_service.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

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

  def user_key_is_unique
    if provider_account
      others = provider_account.provided_cinstances.by_user_key(user_key)
      others = others.without_ids(self.id) unless new_record?
      errors.add(:user_key, :taken) unless others.empty?
Severity: Minor
Found in app/models/cinstance.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

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

  def set_timezone
    if current_account && (current_account.provider? || current_account.master?)
      Time.zone = current_account.timezone if current_account
    elsif current_account
      Time.zone = current_account.provider_account.timezone
Severity: Minor
Found in app/controllers/application_controller.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

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

  def providers_failed_count
    @providers.inject(0) do |sum, provider|
      id, status = provider
      status[:success] ? sum : sum + 1
    end
Severity: Minor
Found in app/models/finance/billing_strategy/results.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

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

  def menu_link(level, title, path, options = {}, li_options = {}, &block)
    current_title = options.delete(:title) || title
    if active_menu?(level, current_title) || current_page?(path)
      li_options[:class] = :active
    end
Severity: Minor
Found in app/helpers/menu_helper.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

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

    def bill_for_variable(period, invoice, plan_to_bill = self.plan)
      # TODO: this makes the bill_for method dependent on Time.zone.now
      # so it should be handled differently
      #
      return false if trial?
Severity: Minor
Found in app/lib/finance/variable_cost.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

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

      def plan_change_permission_warning
        permission = self.plan.issuer.plan_change_permission(self.plan.class)
        direct = 'Are you sure you want to change your plan?'
        request = 'Are you sure you want to request a plan change?'

Severity: Minor
Found in app/lib/logic/plan_changes.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

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

      def authenticate_with_sso(token, expires_at = nil)
        encryptor = ThreeScale::SSO::Encryptor.new site_account.settings.sso_key, expires_at.to_i
        user_id, username = encryptor.extract! token

        user = if user_id.present?
Severity: Minor
Found in app/lib/authentication/strategy/sso.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

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

  def self.up
    add_column :services, :system_name, :string
    add_column :plans, :system_name, :string

    Plan.reset_column_information
Severity: Minor
Found in db/migrate/20120120151742_adding_system_names.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

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

  def self.update_state(invoice)   
    today = Time.zone.today

    if invoice.issued_on
      invoice.state = :pending
Severity: Minor
Found in db/migrate/20101026173617_fill_in_new_finance_fields.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

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

      def command
        return unless proxy
        return if base_endpoint.blank?

        credentials = proxy.authentication_params_for_proxy
Severity: Minor
Found in app/lib/apicast/curl_command_builder.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

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

    def extract_metric(options)
      unless options[:metric] || options[:metric_name] || options[:response_code]
        raise InvalidParameterError, "Missing key(s): metric_name"
      end

Severity: Minor
Found in app/lib/stats/base.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

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

  def initialize(*args)
    ALLOWED_ATTRIBUTES.each do |attr|
      if attr == :country
        value = args.shift

Severity: Minor
Found in app/lib/three_scale/address.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

Method up has a Cognitive Complexity of 7 (exceeds 5 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: Minor
Found in db/migrate/20100929103536_inject_essential_assets_to_liquid_layouts.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

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

    def verify_path_format(*attrs)
      attrs.each do |attr|
        validate do |record|
          value = record.read_attribute(attr)

Severity: Minor
Found in app/lib/normalize_path_attribute.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

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

    t.bigint "account_id"
    t.bigint "system_operation_id"
    t.text "emails"
    t.boolean "dispatch", default: true
    t.datetime "created_at"
Severity: Minor
Found in db/schema.rb and 1 other location - About 35 mins to fix
db/postgres_schema.rb on lines 747..755

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

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 3 locations. Consider refactoring.
Open

    create_table "assets", :force => true do |t|
      t.integer  "account_id",              :limit => 8
      t.string   "attachment_file_name"
      t.string   "attachment_content_type"
      t.integer  "attachment_file_size"
Severity: Minor
Found in db/migrate/20121018100514_removing_bcms_tables.rb and 2 other locations - About 35 mins to fix
db/migrate/20121018100514_removing_bcms_tables.rb on lines 489..497
db/migrate/20121018100514_removing_bcms_tables.rb on lines 623..631

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

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 3 locations. Consider refactoring.
Open

    create_table "page_route_options", :force => true do |t|
      t.integer  "page_route_id", :limit => 8
      t.string   "type"
      t.string   "name"
      t.string   "value"
Severity: Minor
Found in db/migrate/20121018100514_removing_bcms_tables.rb and 2 other locations - About 35 mins to fix
db/migrate/20121018100514_removing_bcms_tables.rb on lines 66..74
db/migrate/20121018100514_removing_bcms_tables.rb on lines 623..631

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

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 3 locations. Consider refactoring.
Open

    create_table "wiki_pages", :force => true do |t|
      t.integer  "account_id", :limit => 8
      t.string   "title"
      t.text     "content"
      t.datetime "created_at"
Severity: Minor
Found in db/migrate/20121018100514_removing_bcms_tables.rb and 2 other locations - About 35 mins to fix
db/migrate/20121018100514_removing_bcms_tables.rb on lines 66..74
db/migrate/20121018100514_removing_bcms_tables.rb on lines 489..497

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

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

Severity
Category
Status
Source
Language