loomio/loomio

View on GitHub

Showing 175 of 175 total issues

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

  get plugins() {
    const attachFile = this.options.attachFile
    const attachImageFile = this.options.attachImageFile
    return [
      uploadPlaceholderPlugin,
Severity: Minor
Found in vue/src/shared/tiptap_extentions/image.js - About 1 hr to fix

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

      def self.theme
        brand_colors = {
          gold: "#DCA034",
          ink: "#3D3D3D",
          sky: "#658AE7",
    Severity: Minor
    Found in app/extras/app_config.rb - About 1 hr to fix

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

          def payload
            @payload ||= {
              version:             Loomio::Version.current,
              release:             AppConfig.release,
              systemNotice:        ENV['LOOMIO_SYSTEM_NOTICE'],
      Severity: Minor
      Found in app/models/boot/site.rb - About 1 hr to fix

        Method add_events_complete has a Cognitive Complexity of 12 (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

        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

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

            def perform(user_id)
              user = User.find(user_id)
          
              User.transaction do
                email = user.email
          Severity: Minor
          Found in app/workers/deactivate_user_worker.rb - About 1 hr to fix

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

              def self.create_stances(poll:, actor:, user_ids: [], emails: [], audience: nil)
                # user_ids = poll.base_guest_audience_query.where('users.id': Array(user_ids)).pluck(:id)
                # audience_ids = AnnouncementService.audience_users(poll, audience).pluck('users.id')
            
                # filter user_ids from group or poll or discussion
            Severity: Minor
            Found in app/services/poll_service.rb - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  if persisted? && specified_voters_only && !admin
                    # voters
                    User.active.
                      joins("LEFT OUTER JOIN memberships m ON m.user_id = users.id AND m.group_id = #{self.group_id || 0}").
                      joins("LEFT OUTER JOIN stances s ON s.participant_id = users.id AND s.poll_id = #{self.id || 0}").
              Severity: Critical
              Found in app/models/poll.rb - About 1 hr to fix

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

                      if (action && action.add) {
                        let widget = document.createElement("progress")
                        widget.setAttribute("id", action.add.id)
                        widget.setAttribute("max", 100)
                        widget.setAttribute("value", 0)
                Severity: Major
                Found in vue/src/shared/tiptap_extentions/image.js and 1 other location - About 1 hr to fix
                vue/src/shared/tiptap_extentions/placeholder_plugin.js on lines 20..27

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

                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

                loki.Comparators.lt = function(a, b, eq) {
                    var result = cmp(a, b);
                    switch(result) {
                      case -1: return true;
                      case 0: return eq;
                Severity: Major
                Found in vue/src/shared/record_store/loki.js and 1 other location - About 1 hr to fix
                vue/src/shared/record_store/loki.js on lines 25..32

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

                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

                loki.Comparators.gt = function(a, b, eq) {
                  var result = cmp(a, b);
                    switch(result) {
                      case -1: return false;
                      case 0: return eq;
                Severity: Major
                Found in vue/src/shared/record_store/loki.js and 1 other location - About 1 hr to fix
                vue/src/shared/record_store/loki.js on lines 15..22

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

                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

                      if (action && action.add) {
                        let widget = document.createElement("placeholder")
                        let deco = Decoration.widget(action.add.pos, widget, {id: action.add.id})
                        set = set.add(tr.doc, [deco])
                      } else if (action && action.remove) {
                Severity: Major
                Found in vue/src/shared/tiptap_extentions/placeholder_plugin.js and 1 other location - About 1 hr to fix
                vue/src/shared/tiptap_extentions/image.js on lines 17..26

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

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

                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/shared/tiptap_extentions/image.js - About 1 hr to fix

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

                    def send_poll_email(recipient_id, event_id, action_name)
                      @recipient = User.find_by!(id: recipient_id)
                      @event = Event.find_by!(id: event_id)
                      @action_name = action_name
                      @poll = @event.eventable.poll
                  Severity: Minor
                  Found in app/mailers/poll_mailer.rb - About 1 hr to fix

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

                      def self.filter(chain: , params: )
                        # how to do this....
                        if group = Group.find_by(key: params[:group_key])
                          group_ids = (params[:subgroups] == "none") ? [group.id] : group.id_and_subgroup_ids
                          chain = chain.where(group_id: group_ids)
                    Severity: Minor
                    Found in app/queries/poll_query.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

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

                      def build_calendar(outcome)
                        return unless outcome.poll_option && outcome.dates_as_options
                        Icalendar::Calendar.new.tap do |calendar|
                          calendar.event do |event|
                            if outcome.poll_option.name.match /^\d+-\d+-\d+$/
                    Severity: Minor
                    Found in app/models/calendar_invite.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

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

                      def base_membership_query(admin: false)
                        if persisted? && specified_voters_only && !admin
                          # voters
                          User.active.
                            joins("LEFT OUTER JOIN memberships m ON m.user_id = users.id AND m.group_id = #{self.group_id || 0}").
                    Severity: Minor
                    Found in app/models/poll.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

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

                      def self.migrate!(attachments: Attachment.none)
                        Benchmark.realtime do
                          new_docs = []
                          attachments.unmigrated.find_each(batch_size: 1000) do |att|
                            new_docs << Document.new(
                    Severity: Minor
                    Found in app/services/migrate_attachment_service.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 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 clearMarks has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function clearMarks (tr, schema, type) {
                      const { doc, selection } = tr
                      if (!selection || !doc) {
                        return tr
                      }
                    Severity: Minor
                    Found in vue/src/shared/tiptap_extentions/utils/format_clear.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language