loomio/loomio

View on GitHub

Showing 471 of 471 total issues

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

      webhooks: {
        name: 'webhook.api_keys',
        icon: 'mdi-key-variant',
        menu: true,
        canPerform() {
Severity: Major
Found in vue/src/shared/services/group_service.js and 1 other location - About 2 hrs to fix
vue/src/shared/services/group_service.js on lines 111..126

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

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

      uncast_stance: {
        name: (stance.poll().config().has_options && 'poll_common.remove_your_vote') || 'poll_common.remove_your_response',
        icon: 'mdi-cancel',
        dock: 1,
        canPerform: () => this.canUpdateStance(stance),
Severity: Major
Found in vue/src/shared/services/stance_service.js and 1 other location - About 2 hrs to fix
vue/src/shared/services/stance_service.js on lines 62..68

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

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

      edit_stance: {
        name: (stance.poll().config().has_options && 'poll_common.change_vote') || 'poll_common.change_response',
        icon: 'mdi-pencil',
        dock: 1,
        canPerform: () => this.canUpdateStance(stance),
Severity: Major
Found in vue/src/shared/services/stance_service.js and 1 other location - About 2 hrs to fix
vue/src/shared/services/stance_service.js on lines 91..97

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

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

      chatbots: {
        name: 'chatbot.chatbots',
        icon: 'mdi-robot',
        menu: true,
        canPerform() {
Severity: Major
Found in vue/src/shared/services/group_service.js and 1 other location - About 2 hrs to fix
vue/src/shared/services/group_service.js on lines 128..143

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

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 Base has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class Clients::Base
  attr_reader :key

  def self.instance
    new(
Severity: Minor
Found in app/extras/clients/base.rb - About 2 hrs to fix

    UserModel has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class UserModel extends BaseModel {
      static singular = 'user';
      static plural = 'users';
      static uniqueIndices = ['id'];
    
    
    Severity: Minor
    Found in vue/src/shared/models/user_model.js - About 2 hrs to fix

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

        bestNamedId() {
          return ((this.id && this) || (this.pollId && this.poll()) || (this.groupId && this.group()) || {namedId() {}}).namedId();
        }
      Severity: Major
      Found in vue/src/shared/models/outcome_model.js and 1 other location - About 2 hrs to fix
      vue/src/shared/models/poll_model.js on lines 208..210

      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

        bestNamedId() {
          return ((this.id && this) || (this.discusionId && this.discussion()) || (this.groupId && this.group()) || {namedId() {}}).namedId();
        }
      Severity: Major
      Found in vue/src/shared/models/poll_model.js and 1 other location - About 2 hrs to fix
      vue/src/shared/models/outcome_model.js on lines 94..96

      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

        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

      Function groupPrivacy has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export var groupPrivacy = function(group, privacy) {
        privacy = privacy || group.groupPrivacy;
      
        if (group.isParent()) {
          switch (privacy) {
      Severity: Minor
      Found in vue/src/shared/helpers/helptext.js - About 2 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 create_chatbots_for_group has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create_chatbots_for_group(group)
          event_kinds = %w[
            new_discussion
            discussion_edited
            poll_created
      Severity: Major
      Found in app/helpers/dev/fake_data_helper.rb - About 2 hrs to fix

        Method for_collection has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.for_collection(collection, user_id, exclude_types = [])
            obj = self.new
            obj.exclude_types = exclude_types
            obj.current_user_id = user_id
            return obj unless item = collection.to_a.first
        Severity: Major
        Found in app/services/record_cache.rb - About 2 hrs to fix

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

            actions(attachment) {
              return {
                delete_attachment: {
                  icon: 'mdi-delete',
                  name: 'common.action.delete',
          Severity: Minor
          Found in vue/src/shared/services/attachment_service.js - About 2 hrs to fix

            Method create_all_notifications has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create_all_notifications
                #'reaction_created'
                patrick_comment = Comment.new(discussion: create_discussion, body: 'I\'m rather likeable')
                reaction = Reaction.new(reactable: patrick_comment, reaction: ":heart:")
                new_comment_event = CommentService.create(comment: patrick_comment, actor: patrick)
            Severity: Minor
            Found in app/helpers/dev/ninties_movies_helper.rb - About 2 hrs to fix

              Method invite has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.invite(group:, params:, actor:)
                  group_ids = if params[:invited_group_ids]
                    Array(params[:invited_group_ids]).map(&:to_i)
                  else
                    Array(group.id)
              Severity: Minor
              Found in app/services/group_service.rb - About 2 hrs to fix

                Method create_stances has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.create_stances(poll:, actor:, user_ids: [], emails: [], audience: nil, include_actor: false)
                    existing_voter_ids = Stance.latest.where(poll_id: poll.id).pluck(:participant_id)
                
                    users = UserInviter.where_or_create!(
                      actor: actor,
                Severity: Minor
                Found in app/services/poll_service.rb - About 1 hr to fix

                  Function insertImage has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function insertImage(file, view, coordinates, attachImageFile) {
                    const { schema } = view.state
                  
                    const id = "image"+(count++)
                    // Replace the selection with a placeholder
                  Severity: Minor
                  Found in vue/src/components/lmo_textarea/extension_image.js - About 1 hr to fix

                    Function MentionPluginConfig has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export var MentionPluginConfig = function() {
                      // is called when a suggestion starts
                      return {
                        HTMLAttributes: {
                          class: 'mention'
                    Severity: Minor
                    Found in vue/src/components/lmo_textarea/mentioning.js - About 1 hr to fix

                      Function enqueueFetch has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                        enqueueFetch(model) {
                          if (typeof model.isA === 'function' ? model.isA('stance') : undefined) { ids['stance_ids'].push(model.id); }
                          if (typeof model.isA === 'function' ? model.isA('comment') : undefined) { ids['comment_ids'].push(model.id); }
                          if (typeof model.isA === 'function' ? model.isA('discussion') : undefined) { ids['discussion_ids'].push(model.id); }
                          if (typeof model.isA === 'function' ? model.isA('poll') : undefined) { ids['poll_ids'].push(model.id); }
                      Severity: Minor
                      Found in vue/src/shared/services/reaction_service.js - 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

                      Severity
                      Category
                      Status
                      Source
                      Language