loomio/loomio

View on GitHub

Showing 471 of 471 total issues

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

  canMovePoll(poll) {
    return (!poll.discussionId || !poll.discussion().closedAt) &&
    !poll.discussionId && poll.adminsInclude(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 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 64.

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

      addProseMirrorPlugins() {
        const attachFile = this.options.attachFile
        const attachImageFile = this.options.attachImageFile
        return [
          uploadPlaceholderPlugin,
    Severity: Minor
    Found in vue/src/components/lmo_textarea/extension_image.js - About 1 hr to fix

      Method redeem has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.redeem(membership:, actor:, notify: true)
          raise Membership::InvitationAlreadyUsed.new(membership) if membership.accepted_at
      
          # so we want to accept all the pending invitations this person has been sent within this org
          # and we dont want any surprises if they already have some memberships.
      Severity: Minor
      Found in app/services/membership_service.rb - About 1 hr to fix

        Function groupPrivacyConfirm has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export var groupPrivacyConfirm = function(group) {
          if (group.isNew()) { return ""; }
        
          if (group.attributeIsModified('groupPrivacy')) {
            if (group.privacyIsSecret()) {
        Severity: Minor
        Found in vue/src/shared/helpers/helptext.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

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

          defaultValues() {
            return {
              parentId: null,
              name: '',
              description: '',
        Severity: Minor
        Found in vue/src/shared/models/group_model.js - About 1 hr to fix

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

            def self.invite(poll:, actor:, params:)
              UserInviter.authorize!(
                user_ids: params[:recipient_user_ids],
                emails: params[:recipient_emails],
                audience: params[:recipient_audience],
          Severity: Minor
          Found in app/services/poll_service.rb - About 1 hr to fix

            Method find has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.find(group_ids, query, limit, offset)
                ids = []
                ids.concat ActiveStorage::Attachment.joins(:blob).
                  joins("LEFT OUTER JOIN groups ON active_storage_attachments.record_type = 'Group' AND active_storage_attachments.record_id = groups.id").
                  where('groups.id IN (:group_ids)', group_ids: group_ids).
            Severity: Minor
            Found in app/queries/attachment_query.rb - About 1 hr to fix

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

                tags() {
                  return this.recordStore.tags.collection.chain().find({groupId: this.id}).simplesort('priority').data();
                }
              Severity: Major
              Found in vue/src/shared/models/group_model.js and 1 other location - About 1 hr to fix
              vue/src/shared/models/group_model.js on lines 90..92

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

              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

                tagsByName() {
                  return this.recordStore.tags.collection.chain().find({groupId: this.id}).simplesort('name').data();
                }
              Severity: Major
              Found in vue/src/shared/models/group_model.js and 1 other location - About 1 hr to fix
              vue/src/shared/models/group_model.js on lines 86..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 63.

              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

                    make_a_copy: {
                      icon: 'mdi-content-copy',
                      name: 'templates.make_a_copy',
                      menu: true,
                      canPerform() { return Session.user(); },
              Severity: Major
              Found in vue/src/shared/services/poll_service.js and 1 other location - About 1 hr to fix
              vue/src/shared/services/thread_service.js on lines 13..19

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

              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

                    make_a_copy: {
                      icon: 'mdi-content-copy',
                      name: 'templates.make_a_copy',
                      menu: true,
                      canPerform() { return Session.user(); },
              Severity: Major
              Found in vue/src/shared/services/thread_service.js and 1 other location - About 1 hr to fix
              vue/src/shared/services/poll_service.js on lines 80..86

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

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

              export default function(options) {
                let chain = Records.discussions.collection.chain();
                chain = chain.find({discardedAt: null});
                if (options.group) { chain = chain.find({groupId: { $in: options.group.organisationIds() }}); }
                if (options.from) { chain = chain.find({lastActivityAt: { $gt: options.from }}); }
              Severity: Minor
              Found in vue/src/shared/services/thread_filter.js - About 1 hr to fix

                Method export has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.export(groups, group_name)
                    filename = export_filename_for(group_name)
                    ids = Hash.new { |hash, key| hash[key] = [] }
                    File.open(filename, 'w') do |file|
                      groups.each do |group|
                Severity: Minor
                Found in app/services/group_export_service.rb - About 1 hr to fix

                  Method initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def initialize(user)
                      super(user)
                  
                      can [:create], ::Comment do |comment|
                        comment.discussion &&
                  Severity: Minor
                  Found in app/models/ability/comment.rb - About 1 hr to fix

                    Method fake_poll has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def fake_poll(args = {})
                        names = option_names(args.delete(:option_count) || (2..7).to_a.sample)
                    
                        closing_at = args[:wip] ? nil : 3.days.from_now
                        options = {
                    Severity: Minor
                    Found in app/helpers/dev/fake_data_helper.rb - About 1 hr to fix

                      Function downcode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                      var downcode= function( slug )
                      {
                          Downcoder.Initialize() ;
                          var downcoded =""
                          var pieces = slug.match(Downcoder.regex);
                      Severity: Minor
                      Found in vue/src/shared/helpers/parameterize.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

                      Function actions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        actions(poll, vm, event) {
                          if (!poll || !poll.config()) { return {}; }
                          return {
                            translate_poll: {
                              icon: 'mdi-translate',
                      Severity: Minor
                      Found in vue/src/shared/services/poll_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

                      Method add_events_complete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def add_events_complete(collection)
                          ids = {discussion: [], comment: [], group: [], poll: []}.with_indifferent_access
                      
                      
                          Event.includes(:eventable).where(id: collection.map(&:id)).each do |e|
                      Severity: Minor
                      Found in app/services/record_cache.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

                      Function constructor has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        constructor() {
                          const defaults = {
                            parentId: null,
                            name: I18n.t('discussion.direct_thread'),
                            description: '',
                      Severity: Minor
                      Found in vue/src/shared/models/null_group_model.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language