loomio/loomio

View on GitHub

Showing 259 of 471 total issues

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

  def reply_to_address_with_group_name(model:, user:)
    return nil unless user.is_logged_in?
    return nil unless model.respond_to?(:discussion) && model.discussion.present?
    if model.discussion.group.present?
      "\"#{I18n.transliterate(model.discussion.group.full_name).truncate(50).delete('"')}\" <#{reply_to_address(model: model, user: user)}>"
Severity: Minor
Found in app/mailers/event_mailer.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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.update(stance: , actor: , params: ) 
    actor.ability.authorize!(:update, stance)
    is_update = !!stance.cast_at

    new_stance = stance.build_replacement
Severity: Minor
Found in app/services/stance_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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create(group:, actor: , skip_authorize: false)
    actor.ability.authorize!(:create, group) unless skip_authorize

    return false unless group.valid?

Severity: Minor
Found in app/services/group_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 translate_group_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.translate_group_record(group, record, locale, cache_only = false, ignore: [])
    translate_record = if source_record_id = group.info.dig('source_record_ids', "#{record.class.to_s}-#{record.id}")
      record.class.find(source_record_id)
    else
      record
Severity: Minor
Found in app/services/translation_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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create(model:, to:)
    locale = locale_for_google(to)
    translation = model.translations.find_by(language: locale) ||
                  Translation.new(translatable: model, language: locale, fields: {})

Severity: Minor
Found in app/services/translation_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 tracked_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def tracked_url(model, args = {})
    args.merge!({utm_medium: 'email', utm_campaign: @event&.kind })

    if model.is_a?(Poll) or model.is_a?(Outcome)
      if stance = model.poll.stances.latest.find_by(participant: @recipient)
Severity: Minor
Found in app/helpers/email_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

Avoid too many return statements within this function.
Open

    return 'discussion_edited';
Severity: Major
Found in vue/src/shared/helpers/helptext.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return 'group_form.confirm_change_to_private_discussions_only';
    Severity: Major
    Found in vue/src/shared/helpers/helptext.js - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return parse(ranges)                 if ranges.is_a? String
      Severity: Major
      Found in app/extras/range_set.rb - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return 'group_form.subgroup_privacy_is_closed_description';
        Severity: Major
        Found in vue/src/shared/helpers/helptext.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return this.findByKeys(q);
          Severity: Major
          Found in vue/src/shared/record_store/base_records_interface.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return this.findByIds(q);
            Severity: Major
            Found in vue/src/shared/record_store/base_records_interface.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  if ((part[0] >  whole[0]) && (part[1] === whole[1])) { return [[whole[0], part[0] - 1]]; }
              Severity: Major
              Found in vue/src/shared/services/range_set.js - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return [[whole.first, part.first - 1]] if (part.first > whole.first) && (part.last == whole.last)
                Severity: Major
                Found in app/extras/range_set.rb - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return chain.data();
                  Severity: Major
                  Found in vue/src/shared/record_store/base_records_interface.js - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return
                    Severity: Major
                    Found in app/services/received_email_service.rb - About 30 mins to fix

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

                        def poll_option_names=(names)
                          names    = Array(names)
                          existing = Array(poll_options.pluck(:name))
                          names = names.sort if poll_type == 'meeting'
                          names.each_with_index do |name, priority|
                      Severity: Minor
                      Found in app/models/poll.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

                      Function pieSlices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        pieSlices() {
                          let slices = [];
                          if ((this.pollType === 'count') && this.results.find(r => r.icon === 'agree')) {
                            const agree = this.results.find(r => r.icon === 'agree');
                            if (agree.score < this.agreeTarget) {
                      Severity: Minor
                      Found in vue/src/shared/models/poll_model.js - 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

                      Function bestNamedId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        bestNamedId() {
                          return ((this.id && this) || (this.pollId && this.poll()) || (this.groupId && this.group()) || {namedId() {}}).namedId();
                        }
                      Severity: Minor
                      Found in vue/src/shared/models/outcome_model.js - 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 to_ranges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def self.to_ranges(ranges)
                          # ranges is supposed to be an array of ranges.
                          # but it's useful to support
                          # range set
                          return []                            if ranges.nil?
                      Severity: Minor
                      Found in app/extras/range_set.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

                      Severity
                      Category
                      Status
                      Source
                      Language