loomio/loomio

View on GitHub

Showing 259 of 471 total issues

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

  def initialize(user)
    super(user)

    can :vote_in, ::Poll do |poll|
      user.is_logged_in? &&
Severity: Major
Found in app/models/ability/poll.rb - About 2 hrs to fix

    StanceModel has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class StanceModel extends BaseModel {
      static singular = 'stance';
      static plural = 'stances';
      static indices = ['pollId', 'latest', 'participantId'];
      static uniqueIndices = ['id'];
    Severity: Minor
    Found in vue/src/shared/models/stance_model.js - About 2 hrs to fix

      Function insertImage has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      export function insertImage(file, view, coordinates, attachImageFile) {
        const { schema } = view.state
      
        const id = "image"+(count++)
        // Replace the selection with a placeholder
      Severity: Minor
      Found in vue/src/components/lmo_textarea/extension_image.js - 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 index has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def index
          if group_or_org_id.to_i == 0
            rel = PgSearch.multisearch(params[:query]).where("group_id is null and discussion_id IN (:discussion_ids)", discussion_ids: current_user.guest_discussion_ids)
          end
      
      
      Severity: Major
      Found in app/controllers/api/v1/search_controller.rb - About 2 hrs to fix

        Class RecordCloner has 23 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class RecordCloner
          def initialize(recorded_at:)
            @recorded_at = recorded_at
            @cache = {}
          end
        Severity: Minor
        Found in app/services/record_cloner.rb - About 2 hrs to fix

          File poll_service.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import Session       from '@/shared/services/session';
          import Records       from '@/shared/services/records';
          import Flash         from '@/shared/services/flash';
          import EventBus       from '@/shared/services/event_bus';
          import AbilityService from '@/shared/services/ability_service';
          Severity: Minor
          Found in vue/src/shared/services/poll_service.js - About 2 hrs to fix

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

              actions(outcome) {
                const poll = outcome.poll();
                const user = Session.user();
            
                return {
            Severity: Major
            Found in vue/src/shared/services/outcome_service.js - About 2 hrs to fix

              File record_cache.rb has 268 lines of code (exceeds 250 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 2 hrs to fix

                Method relations has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.relations(model:, actor:)
                    rels = []
                    if model.is_a?(Group) and model.members.exists?(actor.id)
                      rels.push User.joins('LEFT OUTER JOIN memberships m ON m.user_id = users.id').
                                     where('m.group_id IN (:group_ids) AND m.revoked_at IS NULL', {group_ids: model.group.id})
                Severity: Minor
                Found in app/queries/user_query.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 import has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.import(filename, group_id)
                    user_ids = {}
                    discussion_ids = {}
                    comment_ids = {}
                
                
                Severity: Major
                Found in app/services/mybb_service.rb - About 2 hrs to fix

                  Method import has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.import(filename, group_id)
                      user_ids = {}
                      discussion_ids = {}
                      comment_ids = {}
                  
                  
                  Severity: Minor
                  Found in app/services/mybb_service.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 initialize has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def initialize(user)
                      super(user)
                  
                      can [:show,
                           :print,
                  Severity: Major
                  Found in app/models/ability/discussion.rb - About 2 hrs to fix

                    Function default has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function(callback) {
                      const client = new RestfulClient('boot');
                      client.get('site').then(function(appConfig) {
                        appConfig.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
                        forEach(appConfig, (v, k) => Vue.set(AppConfig, k, v));
                    Severity: Major
                    Found in vue/src/shared/helpers/boot.js - About 2 hrs to fix

                      Method new_clone_poll has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def new_clone_poll(poll)
                          copy_fields = %w[
                            author_id
                            closing_at
                            closed_at
                      Severity: Major
                      Found in app/services/record_cloner.rb - About 2 hrs to fix

                        Class Base has 21 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class Clients::Base
                          attr_reader :key
                        
                          def self.instance
                            new(
                        Severity: Minor
                        Found in app/extras/clients/base.rb - About 2 hrs to fix

                          UserModel has 21 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          export default class UserModel extends BaseModel {
                            static singular = 'user';
                            static plural = 'users';
                            static uniqueIndices = ['id'];
                          
                          
                          Severity: Minor
                          Found in vue/src/shared/models/user_model.js - About 2 hrs to fix

                            Function groupPrivacy has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export var groupPrivacy = function(group, privacy) {
                              privacy = privacy || group.groupPrivacy;
                            
                              if (group.isParent()) {
                                switch (privacy) {
                            Severity: Minor
                            Found in vue/src/shared/helpers/helptext.js - 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 create_chatbots_for_group has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def create_chatbots_for_group(group)
                                event_kinds = %w[
                                  new_discussion
                                  discussion_edited
                                  poll_created
                            Severity: Major
                            Found in app/helpers/dev/fake_data_helper.rb - About 2 hrs to fix

                              Method for_collection has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def self.for_collection(collection, user_id, exclude_types = [])
                                  obj = self.new
                                  obj.exclude_types = exclude_types
                                  obj.current_user_id = user_id
                                  return obj unless item = collection.to_a.first
                              Severity: Major
                              Found in app/services/record_cache.rb - About 2 hrs to fix

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

                                  actions(attachment) {
                                    return {
                                      delete_attachment: {
                                        icon: 'mdi-delete',
                                        name: 'common.action.delete',
                                Severity: Minor
                                Found in vue/src/shared/services/attachment_service.js - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language