loomio/loomio

View on GitHub

Showing 259 of 471 total issues

Method default_templates has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def self.default_templates
    AppConfig.poll_templates.map do |key, raw_attrs|
      raw_attrs[:key] = key
      attrs = {}

Severity: Minor
Found in app/services/poll_template_service.rb - About 3 hrs 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 import has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.import(filename_or_url, reset_keys: false)
    group_ids = []
    migrate_ids = {}

    if URI.parse(filename_or_url).class == URI::Generic
Severity: Major
Found in app/services/group_export_service.rb - About 3 hrs to fix

    RestfulClient has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class RestfulClient {
    
      constructor(resourcePlural = null) {
        this.defaultParams = {};
        this.currentUpload = null;
    Severity: Minor
    Found in vue/src/shared/record_store/restful_client.js - About 3 hrs to fix

      Class RecordCache has 27 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class RecordCache
        attr_accessor :scope
        attr_accessor :exclude_types
        attr_accessor :user_ids
        attr_accessor :current_user_id
      Severity: Minor
      Found in app/services/record_cache.rb - About 3 hrs to fix

        File discussion_model.js has 298 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import BaseModel        from '@/shared/record_store/base_model';
        import AppConfig        from '@/shared/services/app_config';
        import Session          from '@/shared/services/session';
        import RangeSet         from '@/shared/services/range_set';
        import HasDocuments     from '@/shared/mixins/has_documents';
        Severity: Minor
        Found in vue/src/shared/models/discussion_model.js - About 3 hrs to fix

          Method accessible_records has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

            def accessible_records
              load_and_authorize(:discussion)
              records = Event.where(discussion_id: @discussion.id)
          
              if %w[position_key sequence_id].include?(params[:order_by])
          Severity: Minor
          Found in app/controllers/api/v1/events_controller.rb - About 3 hrs 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

          File poll_service.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class PollService
            def self.create(poll:, actor:, params: {})
              actor.ability.authorize! :create, poll
          
              poll.assign_attributes(author: actor)
          Severity: Minor
          Found in app/services/poll_service.rb - About 3 hrs to fix

            Method initialize has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def initialize(user)
                super(user)
            
                can [:show], ::Group do |group|
                  !group.archived_at &&
            Severity: Major
            Found in app/models/ability/group.rb - About 3 hrs to fix

              File group_export_service.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class GroupExportService
                RELATIONS = %w[
                  all_users
                  all_events
                  all_notifications
              Severity: Minor
              Found in app/services/group_export_service.rb - About 3 hrs to fix

                Class Event has 26 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Event < ApplicationRecord
                  include ActionView::Helpers::SanitizeHelper
                  include CustomCounterCache::Model
                  include HasTimeframe
                  extend HasCustomFields
                Severity: Minor
                Found in app/models/event.rb - About 3 hrs to fix

                  EventModel has 26 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export default class EventModel extends BaseModel {
                    static singular = 'event';
                    static plural = 'events';
                    static indices = ['discussionId', 'sequenceId', 'position', 'depth', 'parentId', 'positionKey'];
                    static uniqueIndices = ['id'];
                  Severity: Minor
                  Found in vue/src/shared/models/event_model.js - About 3 hrs to fix

                    Class DiscussionsController has 26 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class API::V1::DiscussionsController < API::V1::RestfulController
                      def create
                        instantiate_resource
                        if resource_params[:forked_event_ids] && resource_params[:forked_event_ids].any?
                          EventService.move_comments(discussion: create_action.discussion, params: resource_params, actor: current_user)
                    Severity: Minor
                    Found in app/controllers/api/v1/discussions_controller.rb - About 3 hrs to fix

                      File ability_service.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import AppConfig     from '@/shared/services/app_config';
                      import Records       from '@/shared/services/records';
                      import Session       from '@/shared/services/session';
                      import LmoUrlService from '@/shared/services/lmo_url_service';
                      import {intersection} from 'lodash-es';
                      Severity: Minor
                      Found in vue/src/shared/services/ability_service.js - About 3 hrs to fix

                        Function actions has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          actions(stance, vm, event) {
                            return {
                              react: {
                                dock: 1,
                                canPerform() {
                        Severity: Major
                        Found in vue/src/shared/services/stance_service.js - About 2 hrs to fix

                          File base_model.js has 288 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import utils from './utils';
                          import Vue from 'vue';
                          import { isEqual } from 'date-fns';
                          import { camelCase, union, each, isArray, keys, filter, snakeCase, defaults, orderBy, assign, includes, pick } from 'lodash-es';
                          
                          
                          Severity: Minor
                          Found in vue/src/shared/record_store/base_model.js - About 2 hrs to fix

                            Class SlackMrkdwn has 25 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            class SlackMrkdwn < Redcarpet::Render::Base
                              class << self
                                def from(markdown)
                                  renderer = SlackMrkdwn.new
                                  Redcarpet::Markdown.new(renderer, strikethrough: true, underline: true, fenced_code_blocks: true).render(markdown)
                            Severity: Minor
                            Found in lib/slack_mrkdwn.rb - About 2 hrs to fix

                              Method event has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def event(recipient_id, event_id)
                                  @current_user = @recipient = User.active.find_by!(id: recipient_id)
                                  @event = Event.find_by!(id: event_id)
                                  @notification = Notification.find_by(user_id: recipient_id, event_id: event_id)
                                  
                              Severity: Major
                              Found in app/mailers/event_mailer.rb - About 2 hrs to fix

                                Method initialize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def initialize(user)
                                    super(user)
                                
                                    can [:show,
                                         :print,
                                Severity: Minor
                                Found in app/models/ability/discussion.rb - About 2 hrs 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 ransackable_attributes has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def self.ransackable_attributes(auth_object = nil)
                                    [
                                    "admin_memberships_count",
                                    "admin_tags",
                                    "admins_can_edit_user_content",
                                Severity: Major
                                Found in app/models/group.rb - About 2 hrs to fix

                                  File scenarios_helper.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  module Dev::ScenariosHelper
                                    include Dev::FakeDataHelper
                                    
                                    def poll_created_scenario(params)
                                      group = create_group_with_members
                                  Severity: Minor
                                  Found in app/helpers/dev/scenarios_helper.rb - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language