loomio/loomio

View on GitHub

Showing 259 of 471 total issues

Class ApplicationSerializer has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationSerializer < ActiveModel::Serializer
  embed :ids, include: true

  def scope
    super || {}
Severity: Minor
Found in app/serializers/application_serializer.rb - About 4 hrs to fix

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

      def initialize(user)
        super(user)
    
        can :vote_in, ::Poll do |poll|
          user.is_logged_in? &&
    Severity: Minor
    Found in app/models/ability/poll.rb - About 4 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

    Class User has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < ApplicationRecord
      include CustomCounterCache::Model
      include ReadableUnguessableUrls
      include MessageChannel
      include HasExperiences
    Severity: Minor
    Found in app/models/user.rb - About 4 hrs to fix

      ThreadLoader has 34 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class ThreadLoader {
        constructor(discussion) {
          this.discussion = discussion;
          this.reset();
        }
      Severity: Minor
      Found in vue/src/shared/loaders/thread_loader.js - About 4 hrs to fix

        File poll_model.js has 343 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 HasDocuments     from '@/shared/mixins/has_documents';
        import HasTranslations  from '@/shared/mixins/has_translations';
        Severity: Minor
        Found in vue/src/shared/models/poll_model.js - About 4 hrs to fix

          NullGroupModel has 32 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class NullGroupModel {
            static singular = 'group';
            static plural = 'groups';
            static subscription = {};
          
          
          Severity: Minor
          Found in vue/src/shared/models/null_group_model.js - About 4 hrs to fix

            Class ProfileController has 32 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class API::V1::ProfileController < API::V1::RestfulController
              before_action :require_current_user, only: [:index, :contactable]
            
              def index
                ids = UserQuery.invitable_user_ids(model: nil, actor: current_user, user_ids: params[:xids].split('x').map(&:to_i).compact)
            Severity: Minor
            Found in app/controllers/api/v1/profile_controller.rb - About 4 hrs to fix

              File html_diff.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              var Match, calculate_operations, consecutive_where, create_index, diff, find_match, find_matching_blocks, html_to_tokens, is_end_of_tag, is_start_of_tag, is_tag, is_whitespace, isnt_tag, op_map, recursively_find_matching_blocks, render_operations, wrap;
              
              is_end_of_tag = function(char) {
                return char === '>';
              };
              Severity: Minor
              Found in vue/src/shared/helpers/html_diff.js - About 3 hrs to fix

                File thread_service.js has 330 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/thread_service.js - About 3 hrs to fix

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

                    actions(user, vm) {
                      return {
                        change_password: {
                          icon: 'mdi-lock-reset',
                          name: 'profile_page.change_password_link',
                  Severity: Major
                  Found in vue/src/shared/services/user_service.js - About 3 hrs to fix

                    Function addActions has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      addActions(group) {
                        return {
                          matrix: {
                            name: 'chatbot.matrix',
                            icon: 'mdi-matrix',
                    Severity: Major
                    Found in vue/src/shared/services/chatbot_service.js - About 3 hrs to fix

                      File ninties_movies_helper.rb has 318 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      module Dev::NintiesMoviesHelper
                        include Dev::FakeDataHelper
                      
                        private
                      
                      
                      Severity: Minor
                      Found in app/helpers/dev/ninties_movies_helper.rb - About 3 hrs to fix

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

                          actions(pollTemplate, group) {
                            return {
                              edit_default_template: {
                                name: 'poll_common.edit_template',
                                icon: 'mdi-pencil',
                        Severity: Major
                        Found in vue/src/shared/services/poll_template_service.js - About 3 hrs to fix

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

                            actions(discussionTemplate, group) {
                              return {
                                edit_default_template: {
                                  name: 'poll_common.edit_template',
                                  icon: 'mdi-pencil',
                          Severity: Major
                          Found in vue/src/shared/services/discussion_template_service.js - About 3 hrs to fix

                            Class Discussion has 29 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            class Discussion < ApplicationRecord
                              include CustomCounterCache::Model
                              include ReadableUnguessableUrls
                              include Translatable
                              include Reactable
                            Severity: Minor
                            Found in app/models/discussion.rb - About 3 hrs to fix

                              File user.rb has 311 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              class User < ApplicationRecord
                                include CustomCounterCache::Model
                                include ReadableUnguessableUrls
                                include MessageChannel
                                include HasExperiences
                              Severity: Minor
                              Found in app/models/user.rb - About 3 hrs to fix

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

                                  def initialize(user)
                                    super(user)
                                
                                    can [:show], ::Group do |group|
                                      !group.archived_at &&
                                Severity: Minor
                                Found in app/models/ability/group.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 calculate_results has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def self.calculate_results(poll, poll_options)
                                    sorted_poll_options = case poll.order_results_by
                                    when 'priority'
                                      poll_options.sort_by {|o| o.priority }
                                    else
                                Severity: Minor
                                Found in app/services/poll_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 publish_event! has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def self.publish_event!(event_id)
                                    event = Event.find(event_id)
                                    event.reload
                                    return if event.eventable.nil?
                                    
                                Severity: Minor
                                Found in app/services/chatbot_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

                                Class Stance has 28 methods (exceeds 20 allowed). Consider refactoring.
                                Open

                                class Stance < ApplicationRecord
                                  include CustomCounterCache::Model
                                  include HasMentions
                                  include Reactable
                                  include HasEvents
                                Severity: Minor
                                Found in app/models/stance.rb - About 3 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language