foodcoops/foodsoft

View on GitHub

Showing 182 of 182 total issues

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

    def navigation(primary, context)
      return unless FoodsoftDocuments.enabled?
      return if primary[:foodcoop].nil?

      sub_nav = primary[:foodcoop].sub_navigation
Severity: Minor
Found in plugins/documents/lib/foodsoft_documents/engine.rb and 1 other location - About 1 hr to fix
plugins/polls/lib/foodsoft_polls/engine.rb on lines 3..13

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

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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    @page = Page.find(params[:id])
    @page.attributes = params[:page].merge({ user: current_user })

    if params[:preview]
Severity: Minor
Found in plugins/wiki/app/controllers/pages_controller.rb - About 55 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 mail has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def mail(args)
    args[:message_id] ||= "<#{Mail.random_tag}@#{default_url_options[:host]}>"
    args[:subject] = "[#{FoodsoftConfig[:name]}] #{args[:subject]}"

    if args[:from].is_a? User
Severity: Minor
Found in app/mailers/mailer.rb - About 55 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

Function data_delta_update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function data_delta_update(el, direction) {
  var id = $(el).attr('id');

  var min = $(el).data('min');
  var max = $(el).data('max');
Severity: Minor
Found in app/assets/javascripts/delta_input.js - About 55 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 received has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def received(data)
    mail = Mail.new data

    mail_part = get_mail_part(mail)
    raise 'No valid content could be found' if mail_part.nil?
Severity: Minor
Found in plugins/messages/app/mail_receivers/messages_mail_receiver.rb - About 55 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 perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(order)
    order.group_orders.each do |group_order|
      next unless group_order.ordergroup

      group_order.ordergroup.users.each do |user|
Severity: Minor
Found in app/jobs/notify_received_order_job.rb - About 55 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 navigation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def navigation(primary, context)
      return unless FoodsoftMessages.enabled?

      unless primary[:foodcoop].nil?
        sub_nav = primary[:foodcoop].sub_navigation
Severity: Minor
Found in plugins/messages/lib/foodsoft_messages/engine.rb - About 55 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 perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(order)
    order.group_orders.each do |group_order|
      next unless group_order.ordergroup

      group_order.ordergroup.users.each do |user|
Severity: Minor
Found in app/jobs/notify_finished_order_job.rb - About 55 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 body has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def body
    each_order_article do |order_article|
      dimrows = []
      rows = [[
        GroupOrder.human_attribute_name(:ordergroup),
Severity: Minor
Found in app/documents/order_by_articles.rb - About 55 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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def verify(message)
    r = super(message)
    raise InvalidMessage unless r.is_a?(Array) && r.length >= 2 && r.length <= 3
    raise InvalidScope unless r[0] == FoodsoftConfig.scope
    raise InvalidPrefix unless r[1] == @_prefix
Severity: Minor
Found in app/lib/token_verifier.rb - About 55 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 body has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def body
    contact = FoodsoftConfig[:contact].symbolize_keys

    # From paragraph
    bounding_box [margin_box.right - 200, margin_box.top], width: 200 do
Severity: Minor
Found in app/documents/order_fax.rb - About 55 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

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

  $(document).on('click', 'button[data-decrement]', function() {
    data_delta_update($('#'+$(this).data('decrement')), -1);
  });
Severity: Minor
Found in app/assets/javascripts/delta_input.js and 1 other location - About 50 mins to fix
app/assets/javascripts/delta_input.js on lines 3..5

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

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

    var $el   = $('#q_' + item),
        value = Number($el.val()) - 1,
        min   = $el.data('min') || 0;
Severity: Minor
Found in app/assets/javascripts/ordering.js and 1 other location - About 50 mins to fix
app/assets/javascripts/ordering.js on lines 78..80

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

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

  $(document).on('click', 'button[data-increment]', function() {
    data_delta_update($('#'+$(this).data('increment')), +1);
  });
Severity: Minor
Found in app/assets/javascripts/delta_input.js and 1 other location - About 50 mins to fix
app/assets/javascripts/delta_input.js on lines 6..8

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

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

    var $el   = $('#t_' + item),
        value = Number($el.val()) - 1,
        min   = $el.data('min') || 0;
Severity: Minor
Found in app/assets/javascripts/ordering.js and 1 other location - About 50 mins to fix
app/assets/javascripts/ordering.js on lines 61..63

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

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

    begin
      @group_order.save_ordering!
      redirect_to group_order_url(@group_order), notice: I18n.t('group_orders.create.notice')
    rescue ActiveRecord::StaleObjectError
      redirect_to group_orders_url, alert: I18n.t('group_orders.create.error_stale')
Severity: Minor
Found in app/controllers/group_orders_controller.rb and 1 other location - About 45 mins to fix
app/controllers/group_orders_controller.rb on lines 46..54

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

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

    begin
      @group_order.save_ordering!
      redirect_to group_order_url(@group_order), notice: I18n.t('group_orders.update.notice')
    rescue ActiveRecord::StaleObjectError
      redirect_to group_orders_url, alert: I18n.t('group_orders.update.error_stale')
Severity: Minor
Found in app/controllers/group_orders_controller.rb and 1 other location - About 45 mins to fix
app/controllers/group_orders_controller.rb on lines 32..40

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

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 uniqueness_of_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def uniqueness_of_name
    matches = Article.where(name: name, supplier_id: supplier_id, deleted_at: deleted_at, type: type)
    matches = matches.where.not(id: id) unless new_record?
    # supplier should always be there - except, perhaps, on initialization (on seeding)
    if supplier && (supplier.shared_sync_method.blank? || supplier.shared_sync_method == 'import')
Severity: Minor
Found in app/models/article.rb - About 45 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 link_to_ordering has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def link_to_ordering(order, options = {}, &block)
    group_order = order.group_order(current_user.ordergroup)
    path = if options[:show] && group_order
             group_order_path(group_order)
           elsif group_order
Severity: Minor
Found in app/helpers/group_orders_helper.rb - About 45 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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    sort = if params['sort']
             case params['sort']
             when 'date' then 'created_on'
             when 'note'   then 'note'
Severity: Minor
Found in app/controllers/finance/financial_transactions_controller.rb - About 45 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

Severity
Category
Status
Source
Language