loomio/loomio

View on GitHub

Showing 469 of 469 total issues

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

  actorName() {
    if (this.actor()) {
      return this.actor().nameWithTitle(this.discussion().group());
    } else {
      return i18n.t('common.anonymous');
Severity: Major
Found in vue/src/shared/models/event_model.js and 1 other location - About 1 hr to fix
vue/src/shared/models/stance_model.js on lines 51..57

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

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

  participantName() {
    if (this.participant()) {
      return this.participant().nameWithTitle(this.poll().group());
    } else {
      return i18n.t('common.anonymous');
Severity: Major
Found in vue/src/shared/models/stance_model.js and 1 other location - About 1 hr to fix
vue/src/shared/models/event_model.js on lines 55..61

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

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

Method poll_template_attributes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def poll_template_attributes
    [
      :key,
      :group_id,
      :position,
Severity: Minor
Found in app/models/permitted_params.rb - About 1 hr to fix

    Function addAttributes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      addAttributes() {
        return {
          uid: {
            default: Math.floor(Math.random() * 90000000),
            parseHTML: element => ( parseInt(element.getAttribute('data-uid')) || Math.floor(Math.random() * 90000000) ),
    Severity: Minor
    Found in vue/src/components/lmo_textarea/extension_custom_task_item.js - About 1 hr to fix

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

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

        Method invite has 42 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])
            else
              Array(group.id)
        Severity: Minor
        Found in app/services/group_service.rb - About 1 hr to fix

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

                show_history: {
                  icon: 'mdi-history',
                  name: 'action_dock.show_edits',
                  dock: 1,
                  canPerform() { return discussion.edited(); },
          Severity: Major
          Found in vue/src/shared/services/thread_service.js and 1 other location - About 1 hr to fix
          vue/src/shared/services/outcome_service.js on lines 44..57

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

          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

                show_history: {
                  icon: 'mdi-history',
                  name: 'action_dock.show_edits',
                  dock: 1,
                  canPerform() { return outcome.edited(); },
          Severity: Major
          Found in vue/src/shared/services/outcome_service.js and 1 other location - About 1 hr to fix
          vue/src/shared/services/thread_service.js on lines 125..138

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

          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

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

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

            Method is_rich_text has 40 lines of code (exceeds 25 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

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

                defaultValues() {
                  return {
                    anonymous: false,
                    groupId: null,
                    title: '',
              Severity: Minor
              Found in vue/src/shared/models/poll_template_model.js - About 1 hr to fix

                Method publish_event! has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.publish_event!(event_id)
                    event = Event.find(event_id)
                    event.reload
                    return if event.eventable.nil?
                    
                Severity: Minor
                Found in app/services/chatbot_service.rb - About 1 hr to fix

                  Method route has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.route(email)
                      return nil unless email.route_address
                      return nil if email.released
                      return nil if email.sender_hostname.downcase == ENV['REPLY_HOSTNAME'].downcase
                      return nil if email.sender_hostname.downcase == ENV['SMTP_DOMAIN'].downcase
                  Severity: Minor
                  Found in app/services/received_email_service.rb - About 1 hr to fix

                    Function audiencesFor has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      audiencesFor(model) {
                        const audiences = [];
                    
                        if (model.discussion && model.discussion().id && model.discussion().membersCount) {
                          model.adminsInclude(user()) ||
                    Severity: Minor
                    Found in vue/src/shared/services/announcement_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 locate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def locate
                        return nil unless defined?(resource_class)
                    
                        if model.to_sym == :user
                          resource_class.verified.find_by(username: params[:id] || params[:username]) || resource_class.friendly.find(params[:id] || params[:user_id])
                    Severity: Minor
                    Found in app/extras/model_locator.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 filter has a Cognitive Complexity of 13 (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 history has a Cognitive Complexity of 13 (exceeds 5 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

                    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 actor_from_email_and_group has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.actor_from_email_and_group(email, group)
                        if actor = (email.dkim_valid || email.spf_valid) && User.find_by(email: email.sender_email)
                          return actor if group.members.exists?(actor.id)
                        end
                    
                    
                    Severity: Minor
                    Found in app/services/received_email_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 constructor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      constructor() {
                        this.makeAdmin = {
                          name: 'membership_dropdown.make_coordinator',
                          canPerform(dr) {
                            return !dr.discussion().group().adminsInclude(dr.user()) &&
                    Severity: Minor
                    Found in vue/src/shared/services/discussion_reader_service.js - About 1 hr to fix

                      Function render has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            render: () => {
                              return {
                                onStart: props => {
                                  this.query = props.query.toLowerCase();
                                  this.suggestionRange = props.range;
                      Severity: Minor
                      Found in vue/src/components/lmo_textarea/mentioning.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language