loomio/loomio

View on GitHub

Showing 267 of 502 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 'discussion_edited';
    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 method.
        Open

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

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

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

            actions(comment, vm, event) {
              const isOwnComment = comment.authorId === Session.userId;
              return {
                translate_comment: {
                  name: 'common.action.translate',
          Severity: Minor
          Found in vue/src/shared/services/comment_service.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 update_reader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def update_reader(ranges: nil, volume: nil, participate: false, dismiss: false)
              viewed!(ranges, persist: false)     if ranges
              set_volume!(volume, persist: false) if volume && (volume != :loud || user.email_on_participation?)
              dismiss!(persist: false)            if dismiss
              save!                               if changed?
          Severity: Minor
          Found in app/models/discussion_reader.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

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

            canEdit(model) {
              return (model.isA('discussion') && this.canEditThread(model)) ||
              (model.isA('comment') && this.canEditComment(model)) ||
              (model.isA('poll') && this.canEditPoll(model)) ||
              (model.isA('stance') && this.canEditStance(model));
          Severity: Minor
          Found in vue/src/shared/services/ability_service.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 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 buildModelRoute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            static buildModelRoute(path, key, name, params, options) {
              let result = options.absolute ? AppConfig.baseUrl : "/";
              if ((options.namespace || path || "").length > 0) { result += `${options.namespace || path}/`; }
              result += `${key}`;
              if (!(name == null) && (options.noStub == null)) { result += "/" + this.stub(name); }
          Severity: Minor
          Found in vue/src/shared/services/lmo_url_service.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 next_position! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def next_position!
              return 0 unless (discussion_id and parent_id)
              unless SequenceService.seq_present?('events_position', parent_id)
                val = Event.where(parent_id: parent_id,
                                 discussion_id: discussion_id).
          Severity: Minor
          Found in app/models/event.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 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.create(poll:, actor:, params: {})
              actor.ability.authorize! :create, poll
          
              poll.assign_attributes(author: actor)
              poll.prioritise_poll_options!
          Severity: Minor
          Found in app/services/poll_service.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 accept_pending_membership has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def accept_pending_membership
              group = @group or (@discussion && @discussion.group) or (@poll && @poll.group)
              return unless group
              MembershipService.redeem_if_pending!(group.membership_for(current_user))
            end
          Severity: Minor
          Found in app/helpers/pending_actions_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 add_stances has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def add_stances(collection)
              return [] if exclude_types.include?('stance')
              scope[:stances_by_id] ||= {}
              scope[:my_stances_by_poll_id] ||= {}
              collection.each do |stance|
          Severity: Minor
          Found in app/services/record_cache.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 visible_to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.visible_to(user: LoggedOutUser.new,
                                chain: start,
                                group_ids: [],
                                show_public: false)
          
          
          Severity: Minor
          Found in app/queries/poll_query.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