loomio/loomio

View on GitHub

Showing 471 of 471 total issues

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

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

                      raw_attrs.each_pair do |key, value|
                        if key.match /_i18n$/
                          attrs[key.gsub(/_i18n$/, '')] = value.is_a?(Array) ? value.map {|v| I18n.t(v)} : I18n.t(value)
                        else
                          attrs[key] = value
                Severity: Minor
                Found in app/services/discussion_template_service.rb and 1 other location - About 30 mins to fix
                app/services/poll_template_service.rb on lines 26..30

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

                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

                      raw_attrs.each_pair do |key, value|
                        if key.match /_i18n$/
                          attrs[key.gsub(/_i18n$/, '')] = value.is_a?(Array) ? value.map {|v| I18n.t(v)} : I18n.t(value)
                        else
                          attrs[key] = value
                Severity: Minor
                Found in app/services/poll_template_service.rb and 1 other location - About 30 mins to fix
                app/services/discussion_template_service.rb on lines 45..49

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

                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

                    ids.concat ActiveStorage::Attachment.joins(:blob).
                      joins("LEFT OUTER JOIN polls ON active_storage_attachments.record_type = 'Poll' AND polls.id = active_storage_attachments.record_id").
                      where('polls.group_id IN (:group_ids)', group_ids: group_ids).
                      where('active_storage_attachments.name': :files).
                      where("active_storage_blobs.filename ilike ?", "%#{query}%").limit(limit).offset(offset).order('id desc').pluck(:id)
                Severity: Minor
                Found in app/queries/attachment_query.rb and 2 other locations - About 25 mins to fix
                app/queries/attachment_query.rb on lines 4..8
                app/queries/attachment_query.rb on lines 31..35

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

                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

                    ids.concat ActiveStorage::Attachment.joins(:blob).
                      joins("LEFT OUTER JOIN groups ON active_storage_attachments.record_type = 'Group' AND active_storage_attachments.record_id = groups.id").
                      where('groups.id IN (:group_ids)', group_ids: group_ids).
                      where('active_storage_attachments.name': :files).
                      where("active_storage_blobs.filename ilike ?", "%#{query}%").limit(limit).offset(offset).order('id desc').pluck(:id)
                Severity: Minor
                Found in app/queries/attachment_query.rb and 2 other locations - About 25 mins to fix
                app/queries/attachment_query.rb on lines 31..35
                app/queries/attachment_query.rb on lines 37..41

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

                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

                    ids.concat ActiveStorage::Attachment.joins(:blob).
                      joins("LEFT OUTER JOIN discussions ON active_storage_attachments.record_type = 'Discussion' AND discussions.id = active_storage_attachments.record_id").
                      where('discussions.group_id IN (:group_ids)', group_ids: group_ids).
                      where('active_storage_attachments.name': :files).
                      where("active_storage_blobs.filename ilike ?", "%#{query}%").limit(limit).offset(offset).order('id desc').pluck(:id)
                Severity: Minor
                Found in app/queries/attachment_query.rb and 2 other locations - About 25 mins to fix
                app/queries/attachment_query.rb on lines 4..8
                app/queries/attachment_query.rb on lines 37..41

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

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

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

                  def self.pg_search_insert_statement(id: nil, author_id: nil, discussion_id: nil)
                    content_str = "regexp_replace(CONCAT_WS(' ', polls.title, polls.details, users.name), E'<[^>]+>', '', 'gi')"
                    <<~SQL.squish
                      INSERT INTO pg_search_documents (
                        searchable_type,
                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

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

                  def dump_i18n
                    out = {}
                    [
                    :title,
                    :title_placeholder,
                Severity: Minor
                Found in app/models/discussion_template.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 notify_mentions! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def notify_mentions!
                    return unless eventable.newly_mentioned_users.any?
                    if eventable.respond_to?(:discussion)
                      eventable.newly_mentioned_users.each do |guest|
                        if !eventable.group.members.exists?(guest.id)
                Severity: Minor
                Found in app/models/concerns/events/notify/mentions.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 getEmbedLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                export var getEmbedLink = function(link) {
                  link = link || "";
                  if (link.includes("youtube.com") || link.includes("youtu.be")) {
                    return getYoutubeEmbedLink(link);
                  } else if (link.includes("vimeo.com/")) {
                Severity: Minor
                Found in vue/src/shared/helpers/embed_link.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

                Severity
                Category
                Status
                Source
                Language