loomio/loomio

View on GitHub

Showing 469 of 469 total issues

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

      Class ProfileController has 31 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 3 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        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 and 1 other location - About 3 hrs to fix
        vue/src/shared/services/announcement_service.js on lines 29..33

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 111.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        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 and 1 other location - About 3 hrs to fix
        vue/src/shared/services/announcement_service.js on lines 23..27

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 111.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        File user.rb has 321 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if (discussion.groupId) {
                return discussion.group().adminsInclude(Session.user()) ||
                (discussion.group().membersCanAnnounce && discussion.group().membersInclude(Session.user()));
              } else {
                return !discussion.id || discussion.adminsInclude(Session.user());
          Severity: Major
          Found in vue/src/shared/services/ability_service.js and 1 other location - About 3 hrs to fix
          vue/src/shared/services/ability_service.js on lines 157..162

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 109.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if (discussion.groupId) {
                return discussion.group().adminsInclude(Session.user()) ||
                (discussion.group().membersCanAddGuests && discussion.group().membersInclude(Session.user()));
              } else {
                return !discussion.id || discussion.adminsInclude(Session.user());
          Severity: Major
          Found in vue/src/shared/services/ability_service.js and 1 other location - About 3 hrs to fix
          vue/src/shared/services/ability_service.js on lines 127..132

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 109.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                discard: {
                  icon: 'mdi-eye-off',
                  name: 'common.action.hide',
                  menu: true,
                  canPerform() { return discussionTemplate.id && !discussionTemplate.discardedAt && group.adminsInclude(Session.user()); },
          Severity: Major
          Found in vue/src/shared/services/discussion_template_service.js and 1 other location - About 3 hrs to fix
          vue/src/shared/services/poll_template_service.js on lines 56..64

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 108.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                discard: {
                  icon: 'mdi-eye-off',
                  name: 'common.action.hide',
                  menu: true,
                  canPerform() { return pollTemplate.id && !pollTemplate.discardedAt && group.adminsInclude(Session.user()); },
          Severity: Major
          Found in vue/src/shared/services/poll_template_service.js and 1 other location - About 3 hrs to fix
          vue/src/shared/services/discussion_template_service.js on lines 44..52

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 108.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        undiscard: {
                          icon: 'mdi-eye',
                          name: 'common.action.unhide',
                          menu: true,
                          canPerform() { return discussionTemplate.id && discussionTemplate.discardedAt && group.adminsInclude(Session.user()); },
                  Severity: Major
                  Found in vue/src/shared/services/discussion_template_service.js and 1 other location - About 3 hrs to fix
                  vue/src/shared/services/poll_template_service.js on lines 66..74

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 106.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        undiscard: {
                          icon: 'mdi-eye',
                          name: 'common.action.unhide',
                          menu: true,
                          canPerform() { return pollTemplate.id && pollTemplate.discardedAt && group.adminsInclude(Session.user()); },
                  Severity: Major
                  Found in vue/src/shared/services/poll_template_service.js and 1 other location - About 3 hrs to fix
                  vue/src/shared/services/discussion_template_service.js on lines 54..62

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 106.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language