fairmondo/fairmondo

View on GitHub

Showing 56 of 56 total issues

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

  def to_s
    company_part = company_name.present? ? "#{company_name}, " : ''
    title_part = title.present? ? "#{title} " : ''
    address_line_2_part = address_line_2.present? ? "#{address_line_2}, " : ''

Severity: Minor
Found in app/models/address.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 params
    build_form_objects_from checkout ? session[:cart_checkout] : params
    return :invalid unless valid?
    if checkout
      get_seller_specifics_from session
Severity: Minor
Found in app/forms/cart_checkout_form.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 sanitize_tiny_mce has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.sanitize_tiny_mce field, admin_mode = false, remove_spaces = false
    modify Sanitize.clean(
      field,
      elements: admin_mode ?
        %w(a b i strong em p h1 h2 h3 h4 h5 h6 br hr ul ol li img div span iframe) :
Severity: Minor
Found in app/models/concerns/sanitization.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 index_title_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def index_title_for search_cache
    attribute_list = ::HumanLanguageList.new
    attribute_list << t('article.show.title.new') if search_cache.condition == 'new'
    attribute_list << t('article.show.title.old') if search_cache.condition == 'old'
    attribute_list << t('article.show.title.fair') if search_cache.fair
Severity: Minor
Found in app/helpers/articles_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 write_path_to_file_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def write_path_to_file_for(type)
    if Rails.env == 'production'
      arr = []
      File.open("/var/www/fairnopoly/shared/backup_info/#{type}_#{Time.now.strftime('%Y_%m_%d')}", 'a') do |file|
        self.image.styles.each_key do |style|
Severity: Minor
Found in app/models/image.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 breadcrumbs_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def breadcrumbs_for category
    output = ''
    category.self_and_ancestors.each do |c|
      last = c == category
      output << '<span>'
Severity: Minor
Found in app/helpers/articles_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 deserialize_checkboxes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.deserialize_checkboxes(attributes)
      attributes.each do |k, v|
        if k.include?('checkboxes')
          if v
            attributes[k] = v.split(',').map { |i| i.strip } # strip needed to inculde not just the first element because of white space
Severity: Minor
Found in app/models/concerns/mass_upload_concerns/questionnaire.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 store_external_images has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def store_external_images
        return if self.errors.any?
        replace_image true, :external_title_image_url if external_title_image_url.present?
        replace_image false, :image_2_url if image_2_url.present?
      end
Severity: Minor
Found in app/models/concerns/article_concerns/images.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 update_rating_counter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def update_rating_counter
      number_of_ratings = self.ratings.count

      self.update_attributes(percentage_of_positive_ratings: calculate_percentage_of_biased_ratings('positive', 50),
                            percentage_of_neutral_ratings:  calculate_percentage_of_biased_ratings('neutral', 50),
Severity: Minor
Found in app/models/concerns/user_concerns/ratings.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.parse(payload, sso_secret = nil)
    sso = new
    sso.sso_secret = sso_secret if sso_secret
    parsed = Rack::Utils.parse_query(payload)

Severity: Minor
Found in lib/autoload/single_sign_on.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 actions_for_successful_update_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def actions_for_successful_update_for resource, prev_unconfirmed_email = nil
    resource.save_already_validated_standard_address!

    if is_navigational_format?
      flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
Severity: Minor
Found in app/controllers/registrations_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 validate_each has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    case record.country
    when 'Deutschland'
      length = 5
      if value.to_s.length != length
Severity: Minor
Found in app/validators/zip_validator.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 common_sense_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def common_sense_check selected_payment, selected_transport
    if (selected_payment == 'cash_on_delivery' && selected_transport == 'pickup') || (selected_payment == 'cash' && selected_transport != 'pickup')
      I18n.t 'transaction.errors.combination_invalid',
             selected_payment: I18n.t("enumerize.business_transaction.selected_payment.#{selected_payment}")
    elsif (selected_payment != 'paypal' && selected_transport == 'bike_courier')
Severity: Minor
Found in app/validators/common_sense_validator.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 normalize_filename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def normalize_filename
      self.class.attachment_definitions.each do |name, _hash|
        attachment = self.send(name)
        if attachment.present?
          if self.new_record? || self.changed_attributes.keys.include?("#{name}_file_name")
Severity: Minor
Found in lib/autoload/assets/normalizer.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

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

    if cart = Cart.find_by_id(cookies.signed[:cart])
      cart.update_attribute :user_id, current_user.id unless cart.user_id
    else # user probably doesn't have cart cookie set
      @current_cart = Cart.current_for current_user
      cookies.signed[:cart] = @current_cart.id if @current_cart
Severity: Minor
Found in app/controllers/sessions_controller.rb and 1 other location - About 25 mins to fix
app/controllers/passwords_controller.rb on lines 11..15

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

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 cart = Cart.find_by_id(cookies.signed[:cart])
        cart.update_attribute :user_id, current_user.id unless cart.user_id
      else # user probably doesn't have cart cookie set
        @current_cart = Cart.current_for current_user
        cookies.signed[:cart] = @current_cart.id if @current_cart
Severity: Minor
Found in app/controllers/passwords_controller.rb and 1 other location - About 25 mins to fix
app/controllers/sessions_controller.rb on lines 13..17

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

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