loomio/loomio

View on GitHub

Showing 267 of 502 total issues

Method update_model has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.update_model(model, tasks_data)
    uids = tasks_data.map {|t| t[:uid] }
    existing_uids = model.tasks.pluck(:uid)
    new_uids = uids - existing_uids
    removed_uids = existing_uids - uids
Severity: Minor
Found in app/services/task_service.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
    instantiate_collection do |collection|
      if !@poll.anonymous && name = params[:name].presence
        collection = collection.
          joins('LEFT OUTER JOIN users on stances.participant_id = users.id').
Severity: Minor
Found in app/controllers/api/v1/stances_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

Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @email_can_be_verified = email_can_be_verified?
    self.resource = UserService.create(params: sign_up_params)
    if !resource.errors.any?
      save_detected_locale(resource)
Severity: Minor
Found in app/controllers/api/v1/registrations_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

Method bug_tunnel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def bug_tunnel
    raise "no sentry dsn" unless ENV['SENTRY_PUBLIC_DSN']

    uri = URI(ENV['SENTRY_PUBLIC_DSN'])
    known_host = uri.host
Severity: Minor
Found in app/controllers/application_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

Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    email = params[:user_email].strip

    user = User.verified.find_by(email: email)
    if !user
Severity: Minor
Found in app/controllers/api/v1/trials_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

Method commit! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def commit!
    @changed.each do |attribute|
      case attribute
      when 'is_visible_to_public'
        if group.is_hidden_from_public?
Severity: Minor
Found in app/services/group_service/privacy_change.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 create_stances has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create_stances(poll:, actor:, user_ids: [], emails: [], audience: nil, include_actor: false)
    existing_voter_ids = Stance.latest.where(poll_id: poll.id).pluck(:participant_id)

    users = UserInviter.where_or_create!(
      actor: actor,
Severity: Minor
Found in app/services/poll_service.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

Avoid deeply nested control flow statements.
Open

            if discussion = DiscussionService.create(discussion: Discussion.new(discussion_params(email)), actor: actor)
              email.update(released: true) if discussion.persisted?
            end
Severity: Major
Found in app/services/received_email_service.rb - About 45 mins to fix

    Method parse_tasks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.parse_tasks(rich_text, author)
        Nokogiri::HTML::fragment(rich_text).search('li[data-type="taskItem"]').map do |el|
          identifiers = Nokogiri::HTML::fragment(el).
                        search("span[data-mention-id]").map do |el|
                          el['data-mention-id']
    Severity: Minor
    Found in app/services/task_service.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 redirect_to has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def redirect_to(url, opts = {})
        return super unless url.is_a? String # GK: for now this override only covers cases where a string has been passed in, so it does not cover cases of a Hash or a Record being passed in
        host = URI(url).host
        if ENV['USE_VUE'] && Rails.env.development? && host == "localhost"
          path = URI(url).path
    Severity: Minor
    Found in app/controllers/application_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

    Consider simplifying this complex logical expression.
    Open

        if (model.poll && model.poll().id && model.poll().decidedVotersCount && model.poll().undecidedVotersCount) {
          model.adminsInclude(user()) ||
           (model.group().membersCanAnnounce && model.membersInclude(user()));
          audiences.push('decided_voters');
        }
    Severity: Major
    Found in vue/src/shared/services/announcement_service.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

          if (model.poll && model.poll().id && model.poll().decidedVotersCount && model.poll().undecidedVotersCount) {
            model.adminsInclude(user()) ||
             (model.group().membersCanAnnounce && model.membersInclude(user()));
            audiences.push('undecided_voters');
          }
      Severity: Major
      Found in vue/src/shared/services/announcement_service.js - About 40 mins to fix

        Method perform has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def perform(method, path, params, headers, options)
        Severity: Minor
        Found in app/extras/clients/base.rb - About 35 mins to fix

          Method perform has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def perform(method, url, params, headers, options)
          Severity: Minor
          Found in app/extras/clients/oauth.rb - About 35 mins to fix

            Method audience_users has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def self.audience_users(model, kind, actor, exclude_members = false, include_actor = false)
            Severity: Minor
            Found in app/services/announcement_service.rb - About 35 mins to fix

              Method contact_message has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def contact_message(name, email, subject, body, details = {})
              Severity: Minor
              Found in app/mailers/contact_mailer.rb - About 35 mins to fix

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

                  actions(discussion, vm) {
                    return {
                      make_a_copy: {
                        icon: 'mdi-content-copy',
                        name: 'templates.make_a_copy',
                Severity: Minor
                Found in vue/src/shared/services/thread_service.js - 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

                Function canAnnouncePoll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  canAnnouncePoll(poll) {
                    user = Session.user();
                    if (poll.discardedAt) { return false; }
                    if (poll.groupId) {
                      return poll.group().adminsInclude(user) ||
                Severity: Minor
                Found in vue/src/shared/services/ability_service.js - 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

                Function suggestedTitle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  suggestedTitle() {
                    const model = this.model();
                    if (!model) { return ''; }
                
                    if (model.title) {
                Severity: Minor
                Found in vue/src/shared/models/event_model.js - 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 avatar_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def avatar_url(size = 512)
                    if avatar_kind == 'uploaded' && (!uploaded_avatar.attached? or uploaded_avatar.attachment.nil?)
                      update_columns(avatar_kind: set_default_avatar_kind)
                    end
                
                
                Severity: Minor
                Found in app/models/concerns/has_avatar.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

                Severity
                Category
                Status
                Source
                Language