loomio/loomio

View on GitHub

Showing 257 of 469 total issues

Method send_single_mail has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def send_single_mail(locale: , to:, subject_key:, subject_params: {}, subject_prefix: '', subject_is_title: false, **options)
    return if NoSpam::SPAM_REGEX.match?(to)
    return if User::BOT_EMAILS.values.include?(to)
    return if (to.end_with?("@example.com")) && (Rails.env.production?)

Severity: Minor
Found in app/mailers/base_mailer.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 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 redeem has 35 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

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

          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

                    Method update has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Method payload has 30 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 default_templates has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.default_templates
                            AppConfig.poll_templates.map do |key, raw_attrs|
                              raw_attrs[:key] = key
                              attrs = {}
                        
                        
                        Severity: Minor
                        Found in app/services/poll_template_service.rb - About 1 hr to fix

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

                            def perform
                              Discussion.where(template: true).each do |discussion|
                                template = DiscussionTemplate.new(discussion.slice(
                                    :group_id,
                                    :author_id,
                          Severity: Minor
                          Found in app/workers/convert_discussion_templates_worker.rb - About 1 hr to fix

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

                              constructor() {
                                const defaults = {
                                  id: null,
                                  title: 'No thread',
                                  description: '',
                            Severity: Minor
                            Found in vue/src/shared/models/null_discussion_model.js - About 1 hr to fix

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

                                baseConstructor(recordStore) {
                                  this.views = [];
                                  this.missingIds = [];
                                  this.fetchedIds = [];
                              
                              
                              Severity: Minor
                              Found in vue/src/shared/record_store/base_records_interface.js - About 1 hr 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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language