loomio/loomio

View on GitHub

Showing 267 of 502 total issues

Method is_rich_text has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def is_rich_text(on: [])
      define_singleton_method :rich_text_fields, -> { Array on }
      rich_text_fields.each do |field|
        define_method "sanitize_#{field}!" do
          # return if self.send("#{field}_format") == 'md'
Severity: Minor
Found in app/models/concerns/has_rich_text.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 reactions_per_country has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def reactions_per_country
    queries = []
    data = {}

    queries.push <<~SQL
Severity: Minor
Found in app/services/report_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

Method migrate_paperclip has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def self.migrate_paperclip
    models = [Group, User, Discussion, Comment, Poll, Stance, Outcome, Document]

    models.each do |model|
      attachments = model.column_names.map do |c|
Severity: Minor
Found in app/services/migrate_events_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

Method reactions_per_user has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def reactions_per_user
    queries = []
    data = {}

    queries.push <<~SQL
Severity: Minor
Found in app/services/report_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

Method to_csv has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def to_csv(opts={})
    CSV.generate do |csv|
      csv << ['poll']
      csv << meta_table.keys
      csv << meta_table.values
Severity: Minor
Found in app/extras/poll_exporter.rb - About 1 hr to fix

    Function clonePoll has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      clonePoll() {
        const clone = this.clone();
        clone.id = null;
        clone.key = null;
        clone.sourceTemplateId = this.id;
    Severity: Minor
    Found in vue/src/shared/models/poll_model.js - About 1 hr to fix

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

        constructor(recordsInterface, attributes) {
          this.inCollection = this.inCollection.bind(this);
          this.remove = this.remove.bind(this);
          this.destroy = this.destroy.bind(this);
          this.beforeDestroy = this.beforeDestroy.bind(this);
      Severity: Minor
      Found in vue/src/shared/record_store/base_model.js - About 1 hr to fix

        Method create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create
            current_emails = User.active.where(id: group.memberships.pluck(:user_id)).pluck(:email)
        
            params_emails = params.fetch(:emails, [])
            add_emails = params_emails - current_emails
        Severity: Minor
        Found in app/controllers/api/b2/memberships_controller.rb - About 1 hr to fix

          Method translate_group_content! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.translate_group_content!(group, locale, cache_only = false)
              return if locale == 'en'
          
              translate_group_record(group, group, locale, cache_only)
          
          
          Severity: Minor
          Found in app/services/translation_service.rb - About 1 hr to fix

            Method browse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def browse
                if DiscussionTemplate.where(public: true).count == 0
                  DiscussionTemplateService.create_public_templates
                end
            
            
            Severity: Minor
            Found in app/controllers/api/v1/discussion_templates_controller.rb - About 1 hr to fix

              Method accessible_records has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def accessible_records
                  load_and_authorize(:discussion)
                  records = Event.where(discussion_id: @discussion.id)
              
                  if %w[position_key sequence_id].include?(params[:order_by])
              Severity: Minor
              Found in app/controllers/api/v1/events_controller.rb - About 1 hr to fix

                Function exact has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export var exact = function(date, zone, dateTimePref) {
                  if (zone == null) { zone = AppConfig.timeZone; }
                  if (dateTimePref == null) { ({
                    dateTimePref
                  } = Session.user()); }
                Severity: Minor
                Found in vue/src/shared/helpers/format_time.js - About 1 hr to fix

                  Function groupPrivacy has 26 lines of code (exceeds 25 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 1 hr to fix

                    Function addMetaData has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      addMetaData(collection) {
                        const positions = collection.map(e => e.event.position);
                        const ranges = RangeSet.arrayToRanges(positions);
                        const parentExists = collection[0] && collection[0].event && collection[0].event.parent();
                        const lastPosition = (parentExists && (collection[0].event.parent().childCount)) || 0;
                    Severity: Minor
                    Found in vue/src/shared/loaders/thread_loader.js - About 1 hr to fix

                      Method poll_created_scenario has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def poll_created_scenario(params)
                          group = create_group_with_members
                      
                          discussion = fake_discussion(group: group, title: "Some discussion")
                          DiscussionService.create(discussion: discussion, actor: group.members.first)
                      Severity: Minor
                      Found in app/helpers/dev/scenarios_helper.rb - About 1 hr to fix

                        Method history has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def history
                            notifications = {}
                        
                            events = Event.where(kind: notification_kinds, id: target_event_ids).order('id desc').limit(1000)
                        
                        
                        Severity: Minor
                        Found in app/controllers/api/v1/announcements_controller.rb - About 1 hr to fix

                          Function MentionPluginConfig has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 group_privacy= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def group_privacy=(term)
                              case term
                              when 'open'
                                self.is_visible_to_public = true
                                self.discussion_privacy_options = 'public_only'
                          Severity: Minor
                          Found in app/models/concerns/group_privacy.rb - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            actions(stance, vm, event) {
                              return {
                                react: {
                                  dock: 1,
                                  canPerform() {
                          Severity: Minor
                          Found in vue/src/shared/services/stance_service.js - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            actions(group) {
                              const membership = group.membershipFor(Session.user());
                              
                              return {
                                email_group: {
                          Severity: Minor
                          Found in vue/src/shared/services/group_service.js - About 55 mins 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