loomio/loomio

View on GitHub
vue/src/shared/models/discussion_model.js

Summary

Maintainability
F
3 days
Test Coverage

DiscussionModel has 59 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class DiscussionModel extends BaseModel {
  static singular = 'discussion';
  static plural = 'discussions';
  static uniqueIndices = ['id', 'key'];
  static indices = ['groupId', 'authorId'];
Severity: Major
Found in vue/src/shared/models/discussion_model.js - About 1 day to fix

    File discussion_model.js has 298 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 RangeSet         from '@/shared/services/range_set';
    import HasDocuments     from '@/shared/mixins/has_documents';
    Severity: Minor
    Found in vue/src/shared/models/discussion_model.js - About 3 hrs to fix

      Function defaultValues has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        defaultValues() {
          return {
            id: null,
            key: null,
            private: true,
      Severity: Minor
      Found in vue/src/shared/models/discussion_model.js - About 1 hr to fix

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

          moveComments() {
            this.processing = true;
            return this.remote.patchMember(this.keyOrId(), 'move_comments', { forked_event_ids: this.forkedEventIds }).finally(() => { return this.processing = false; });
          }
        Severity: Major
        Found in vue/src/shared/models/discussion_model.js and 1 other location - About 2 hrs to fix
        vue/src/shared/models/discussion_model.js on lines 311..314

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

        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() {
            this.processing = true;
            return this.remote.patchMember(this.keyOrId(), 'move', { group_id: this.groupId }).finally(() => { return this.processing = false; });
          }
        Severity: Major
        Found in vue/src/shared/models/discussion_model.js and 1 other location - About 2 hrs to fix
        vue/src/shared/models/discussion_model.js on lines 336..339

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

        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 4 locations. Consider refactoring.
        Open

          saveUnpin() {
            this.processing = true;
            return this.remote.patchMember(this.keyOrId(), 'unpin').finally(() => { return this.processing = false; });
          }
        Severity: Major
        Found in vue/src/shared/models/discussion_model.js and 3 other locations - About 1 hr to fix
        vue/src/shared/models/discussion_model.js on lines 316..319
        vue/src/shared/models/discussion_model.js on lines 326..329
        vue/src/shared/models/discussion_model.js on lines 331..334

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

        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 4 locations. Consider refactoring.
        Open

          savePin() {
            this.processing = true;
            return this.remote.patchMember(this.keyOrId(), 'pin').finally(() => { return this.processing = false; });
          }
        Severity: Major
        Found in vue/src/shared/models/discussion_model.js and 3 other locations - About 1 hr to fix
        vue/src/shared/models/discussion_model.js on lines 321..324
        vue/src/shared/models/discussion_model.js on lines 326..329
        vue/src/shared/models/discussion_model.js on lines 331..334

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

        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 4 locations. Consider refactoring.
        Open

          reopen() {
            this.processing = true;
            return this.remote.patchMember(this.keyOrId(), 'reopen').finally(() => { return this.processing = false; });
          }
        Severity: Major
        Found in vue/src/shared/models/discussion_model.js and 3 other locations - About 1 hr to fix
        vue/src/shared/models/discussion_model.js on lines 316..319
        vue/src/shared/models/discussion_model.js on lines 321..324
        vue/src/shared/models/discussion_model.js on lines 326..329

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

        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 4 locations. Consider refactoring.
        Open

          close() {
            this.processing = true;
            return this.remote.patchMember(this.keyOrId(), 'close').finally(() => { return this.processing = false; });
          }
        Severity: Major
        Found in vue/src/shared/models/discussion_model.js and 3 other locations - About 1 hr to fix
        vue/src/shared/models/discussion_model.js on lines 316..319
        vue/src/shared/models/discussion_model.js on lines 321..324
        vue/src/shared/models/discussion_model.js on lines 331..334

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

        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

          forkedEvent() {
            const res = this.recordStore.events.find({kind: 'discussion_forked', eventableId: this.id});
            if (!isEmpty(res)) { return res[0]; }
          }
        Severity: Major
        Found in vue/src/shared/models/discussion_model.js and 1 other location - About 1 hr to fix
        vue/src/shared/models/discussion_model.js on lines 149..152

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

        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

          createdEvent() {
            const res = this.recordStore.events.find({kind: 'new_discussion', eventableId: this.id});
            if (!isEmpty(res)) { return res[0]; }
          }
        Severity: Major
        Found in vue/src/shared/models/discussion_model.js and 1 other location - About 1 hr to fix
        vue/src/shared/models/discussion_model.js on lines 154..157

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

        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

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

          pollTemplates() {
            return compact(this.pollTemplateKeysOrIds.map(keyOrId => {
              return this.recordStore.pollTemplates.find(keyOrId);
            })
            );
        Severity: Minor
        Found in vue/src/shared/models/discussion_model.js and 1 other location - About 50 mins to fix
        vue/src/shared/models/discussion_template_model.js on lines 49..54

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

        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