loomio/loomio

View on GitHub
vue/src/shared/loaders/thread_loader.js

Summary

Maintainability
D
2 days
Test Coverage

File thread_loader.js has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Records from '@/shared/services/records';
import { some, last, cloneDeep, max, uniq, compact, orderBy } from 'lodash-es';
import Vue from 'vue';
import RangeSet         from '@/shared/services/range_set';
import EventBus         from '@/shared/services/event_bus';
Severity: Minor
Found in vue/src/shared/loaders/thread_loader.js - About 6 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

      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

        Function addLoadPositionKeyRule has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          addLoadPositionKeyRule(positionKey) {
            this.loading = positionKey;
            this.addRule({
              name: "positionKey from url",
              local: {
        Severity: Minor
        Found in vue/src/shared/loaders/thread_loader.js - About 1 hr to fix

          Function addLoadUnreadRule has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            addLoadUnreadRule() {
              if (this.discussion.updatedAt > this.discussion.lastReadAt) {
                this.addRule({
                  name: "context updated",
                  local: {
          Severity: Minor
          Found in vue/src/shared/loaders/thread_loader.js - About 1 hr to fix

            Function addMetaData has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              addMetaData(collection) {
                const positions = collection.map(e => e.event.position);
                const ranges = RangeSet.arrayToRanges(positions);
                const parentExists = collection[0] && collection[0].event && collection[0].event.parent();
                const lastPosition = (parentExists && (collection[0].event.parent().childCount)) || 0;
            Severity: Minor
            Found in vue/src/shared/loaders/thread_loader.js - About 1 hr to fix

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

                    local: {
                      find: {
                        discussionId: this.discussion.id,
                        positionKey: {$jlt: positionKey}
                      },
              Severity: Major
              Found in vue/src/shared/loaders/thread_loader.js and 1 other location - About 1 hr to fix
              vue/src/shared/loaders/thread_loader.js on lines 237..244

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

              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

                    local: {
                      find: {
                        discussionId: this.discussion.id,
                        positionKey: {$jgte: positionKey}
                      },
              Severity: Major
              Found in vue/src/shared/loaders/thread_loader.js and 1 other location - About 1 hr to fix
              vue/src/shared/loaders/thread_loader.js on lines 255..262

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

              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

                    local: {
                      find: {
                        discussionId: this.discussion.id,
                        positionKey: {
                          $jgt: event.positionKey
              Severity: Minor
              Found in vue/src/shared/loaders/thread_loader.js and 1 other location - About 55 mins to fix
              vue/src/shared/loaders/thread_loader.js on lines 154..163

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

              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

                    local: {
                      find: {
                        discussionId: this.discussion.id,
                        positionKey: {
                          $jlt: event.positionKey
              Severity: Minor
              Found in vue/src/shared/loaders/thread_loader.js and 1 other location - About 55 mins to fix
              vue/src/shared/loaders/thread_loader.js on lines 132..141

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

              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

                    this.addRule({
                      name: "context updated",
                      local: {
                        find: {
                          id: this.discussion.createdEvent().id
              Severity: Minor
              Found in vue/src/shared/loaders/thread_loader.js and 1 other location - About 35 mins to fix
              vue/src/shared/loaders/thread_loader.js on lines 315..322

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

              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

                    remote: {
                      discussion_id: this.discussion.id,
                      parent_id: event.id,
                      order_by: 'position_key',
                      order_desc: 1,
              Severity: Minor
              Found in vue/src/shared/loaders/thread_loader.js and 1 other location - About 35 mins to fix
              vue/src/shared/loaders/thread_loader.js on lines 164..170

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

              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 this.addRule({
                    name: 'context',
                    local: {
                      find: {
                        id: this.discussion.createdEvent().id
              Severity: Minor
              Found in vue/src/shared/loaders/thread_loader.js and 1 other location - About 35 mins to fix
              vue/src/shared/loaders/thread_loader.js on lines 345..352

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

              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

                    remote: {
                      discussion_id: this.discussion.id,
                      position_key_lt: event.positionKey,
                      order_by: 'position_key',
                      order_desc: 1,
              Severity: Minor
              Found in vue/src/shared/loaders/thread_loader.js and 1 other location - About 35 mins to fix
              vue/src/shared/loaders/thread_loader.js on lines 185..191

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

              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

              There are no issues that match your filters.

              Category
              Status