loomio/loomio

View on GitHub

Showing 469 of 469 total issues

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

    return thread.closedAt && (
      thread.adminsInclude(Session.user()) ||
      (thread.membersInclude(Session.user()) && (thread.group().membersCanEditDiscussions || (thread.author() === Session.user())))
    );
Severity: Major
Found in vue/src/shared/services/ability_service.js and 1 other location - About 1 hr to fix
vue/src/shared/services/ability_service.js on lines 57..60

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 73.

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

      move: {
        name: 'common.action.move',
        icon: 'mdi-arrow-up-down',
        menu: true,
        canPerform() { return !pollTemplate.discardedAt && group.adminsInclude(Session.user()); },
Severity: Major
Found in vue/src/shared/services/poll_template_service.js and 1 other location - About 1 hr to fix
vue/src/shared/services/discussion_template_service.js on lines 36..42

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 73.

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

    return !thread.closedAt && (
      thread.adminsInclude(Session.user()) ||
      (thread.membersInclude(Session.user()) && (thread.group().membersCanEditDiscussions || (thread.author() === Session.user())))
    );
Severity: Major
Found in vue/src/shared/services/ability_service.js and 1 other location - About 1 hr to fix
vue/src/shared/services/ability_service.js on lines 64..67

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 73.

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

Method poll_attributes has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def poll_attributes
    [ 
      :agree_target,
      :title,
      :details,
Severity: Minor
Found in app/models/permitted_params.rb - About 1 hr to fix

    Function webhookActions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      webhookActions(webhook) {
        return {
          showApiDocs: {
            name: 'webhook.show_docs',
            icon: 'mdi-key-variant',
    Severity: Minor
    Found in vue/src/shared/services/webhook_service.js - About 1 hr to fix

      Method calculate_results has 47 lines of code (exceeds 25 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 1 hr to fix

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

                perform() {
                  if (event.depth === stance.discussion().maxDepth) {
                    return EventBus.$emit('toggle-reply', stance, event.parentId);
                  } else {
                    return EventBus.$emit('toggle-reply', stance, event.id);
        Severity: Major
        Found in vue/src/shared/services/stance_service.js and 1 other location - About 1 hr to fix
        vue/src/shared/services/comment_service.js on lines 50..56

        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 72.

        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

                perform() {
                  if (event.depth === comment.discussion().maxDepth) {
                    return EventBus.$emit('toggle-reply', comment, event.parentId);
                  } else {
                    return EventBus.$emit('toggle-reply', comment, event.id);
        Severity: Major
        Found in vue/src/shared/services/comment_service.js and 1 other location - About 1 hr to fix
        vue/src/shared/services/stance_service.js on lines 82..88

        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 72.

        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 defaultValues has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          defaultValues() {
            return {
              discussionId: null,
              title: '',
              titlePlaceholder: null,
        Severity: Minor
        Found in vue/src/shared/models/poll_model.js - About 1 hr to fix

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

            actions(event, vm) {
              return {
                move_event: {
                  name: 'action_dock.move_item',
                  menu: true,
          Severity: Minor
          Found in vue/src/shared/services/event_service.js - About 1 hr to fix

            Method perform has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def perform
                Poll.where(template: true).where("group_id is not null").find_each do |p|
                  pt = PollTemplate.new
            
                  [
            Severity: Minor
            Found in app/workers/migrate_poll_templates_worker.rb - About 1 hr to fix

              Method ransackable_attributes has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.ransackable_attributes(auth_object = nil)
                  [
                  "avatar_initials",
                  "avatar_kind",
                  "city",
              Severity: Minor
              Found in app/models/user.rb - About 1 hr to fix

                Method relations has 45 lines of code (exceeds 25 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 1 hr to fix

                  Function updateCollection has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    updateCollection() {
                      this.records = [];
                      this.rules.forEach(rule => {
                        let chain = Records.events.collection.chain();
                        chain.find(rule.local.find);
                  Severity: Minor
                  Found in vue/src/shared/loaders/thread_loader.js - About 1 hr to fix

                    Method repair_thread has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.repair_thread(discussion_id)
                        discussion = Discussion.find_by(id: discussion_id)
                        return unless discussion
                    
                        # ensure discussion.created_event exists
                    Severity: Minor
                    Found in app/services/event_service.rb - About 1 hr to fix

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

                        def add_member!(user, inviter: nil)
                          save! unless persisted?
                          user.save! unless user.persisted?
                      
                          if membership = Membership.find_by(user_id: user.id, group_id: id)
                      Severity: Minor
                      Found in app/models/group.rb - About 1 hr 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

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

                            notification_history: {
                              name: 'action_dock.notification_history',
                              icon: 'mdi-alarm-check',
                              menu: true,
                              perform() {
                      Severity: Major
                      Found in vue/src/shared/services/comment_service.js and 1 other location - About 1 hr to fix
                      vue/src/shared/services/poll_service.js on lines 209..222

                      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 70.

                      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

                        const spacePadDay = function() {
                          const pad = parseInt(format(utcToZonedTime(date, zone), "d", {timeZone: zone, locale: i18n.dateLocale})) < 10;
                          if (pad) { return ' '; } else { return ''; }
                        };
                      Severity: Major
                      Found in vue/src/shared/helpers/format_time.js and 1 other location - About 1 hr to fix
                      vue/src/shared/helpers/format_time.js on lines 49..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 70.

                      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

                        const spacePadHour = function() {
                          const pad = parseInt(format(utcToZonedTime(date, zone), "h", {timeZone: zone, locale: i18n.dateLocale})) < 10;
                          if (pad) { return ' '; } else { return ''; }
                        };
                      Severity: Major
                      Found in vue/src/shared/helpers/format_time.js and 1 other location - About 1 hr to fix
                      vue/src/shared/helpers/format_time.js on lines 54..57

                      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 70.

                      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

                            notification_history: {
                              name: 'action_dock.notification_history',
                              icon: 'mdi-alarm-check',
                              menu: true,
                              perform() {
                      Severity: Major
                      Found in vue/src/shared/services/poll_service.js and 1 other location - About 1 hr to fix
                      vue/src/shared/services/comment_service.js on lines 25..38

                      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 70.

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language