loomio/loomio

View on GitHub

Showing 469 of 469 total issues

Function insertImage has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export 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/components/lmo_textarea/extension_image.js - About 2 hrs 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 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  actions(user, vm) {
    return {
      change_password: {
        icon: 'mdi-lock-reset',
        name: 'profile_page.change_password_link',
Severity: Major
Found in vue/src/shared/services/user_service.js - About 2 hrs to fix

    Method index has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def index
        if group_or_org_id.to_i == 0
          rel = PgSearch.multisearch(params[:query]).where("group_id is null and discussion_id IN (:discussion_ids)", discussion_ids: current_user.guest_discussion_ids)
        end
    
    
    Severity: Major
    Found in app/controllers/api/v1/search_controller.rb - About 2 hrs to fix

      Class RecordCloner has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class RecordCloner
        def initialize(recorded_at:)
          @recorded_at = recorded_at
          @cache = {}
        end
      Severity: Minor
      Found in app/services/record_cloner.rb - About 2 hrs to fix

        File poll_service.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import Session       from '@/shared/services/session';
        import Records       from '@/shared/services/records';
        import Flash         from '@/shared/services/flash';
        import EventBus       from '@/shared/services/event_bus';
        import AbilityService from '@/shared/services/ability_service';
        Severity: Minor
        Found in vue/src/shared/services/poll_service.js - About 2 hrs to fix

          Function actions has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            actions(outcome) {
              const poll = outcome.poll();
              const user = Session.user();
          
              return {
          Severity: Major
          Found in vue/src/shared/services/outcome_service.js - About 2 hrs to fix

            File record_cache.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class RecordCache
              attr_accessor :scope
              attr_accessor :exclude_types
              attr_accessor :user_ids
              attr_accessor :current_user_id
            Severity: Minor
            Found in app/services/record_cache.rb - About 2 hrs to fix

              Method initialize has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                def initialize(user)
                  super(user)
              
                  can [:show,
                       :print,
              Severity: Minor
              Found in app/models/ability/discussion.rb - About 2 hrs 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 relations has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.relations(model:, actor:)
                  rels = []
                  if model.is_a?(Group) and model.members.exists?(actor.id)
                    rels.push User.joins('LEFT OUTER JOIN memberships m ON m.user_id = users.id').
                                   where('m.group_id IN (:group_ids) AND m.revoked_at IS NULL', {group_ids: model.group.id})
              Severity: Minor
              Found in app/queries/user_query.rb - About 2 hrs 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

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

                static membershipRequest(mr, params, options) {
                  if (params == null) { params = {}; }
                  if (options == null) { options = {}; }
                  return this.route({model: mr.group(), action: 'membership_requests', params});
                }
              Severity: Major
              Found in vue/src/shared/services/lmo_url_service.js and 1 other location - About 2 hrs to fix
              vue/src/shared/services/lmo_url_service.js on lines 89..93

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

              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

                static membership(m, params, options) {
                  if (params == null) { params = {}; }
                  if (options == null) { options = {}; }
                  return this.route({model: m.group(), action: 'memberships', params});
                }
              Severity: Major
              Found in vue/src/shared/services/lmo_url_service.js and 1 other location - About 2 hrs to fix
              vue/src/shared/services/lmo_url_service.js on lines 95..99

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

              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

                    translate_poll: {
                      icon: 'mdi-translate',
                      name: 'common.action.translate',
                      dock: 2,
                      canPerform() { return AbilityService.canTranslate(poll); },
              Severity: Major
              Found in vue/src/shared/services/poll_service.js and 1 other location - About 2 hrs to fix
              vue/src/shared/services/thread_service.js on lines 21..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 81.

              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

                    translate_thread: {
                      icon: 'mdi-translate',
                      name: 'common.action.translate',
                      dock: 2,
                      canPerform() { return AbilityService.canTranslate(discussion); },
              Severity: Major
              Found in vue/src/shared/services/thread_service.js and 1 other location - About 2 hrs to fix
              vue/src/shared/services/poll_service.js on lines 47..53

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

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

                def self.import(filename, group_id)
                  user_ids = {}
                  discussion_ids = {}
                  comment_ids = {}
              
              
              Severity: Major
              Found in app/services/mybb_service.rb - About 2 hrs to fix

                Method import has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.import(filename, group_id)
                    user_ids = {}
                    discussion_ids = {}
                    comment_ids = {}
                
                
                Severity: Minor
                Found in app/services/mybb_service.rb - About 2 hrs 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 initialize has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def initialize(user)
                    super(user)
                
                    can [:show,
                         :print,
                Severity: Major
                Found in app/models/ability/discussion.rb - About 2 hrs to fix

                  Function default has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function(callback) {
                    const client = new RestfulClient('boot');
                    client.get('site').then(function(appConfig) {
                      appConfig.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
                      forEach(appConfig, (v, k) => Vue.set(AppConfig, k, v));
                  Severity: Major
                  Found in vue/src/shared/helpers/boot.js - About 2 hrs to fix

                    Method new_clone_poll has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def new_clone_poll(poll)
                        copy_fields = %w[
                          author_id
                          closing_at
                          closed_at
                    Severity: Major
                    Found in app/services/record_cloner.rb - About 2 hrs to fix

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

                            webhooks: {
                              name: 'webhook.api_keys',
                              icon: 'mdi-key-variant',
                              menu: true,
                              canPerform() {
                      Severity: Major
                      Found in vue/src/shared/services/group_service.js and 1 other location - About 2 hrs to fix
                      vue/src/shared/services/group_service.js on lines 111..126

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

                      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

                            uncast_stance: {
                              name: (stance.poll().config().has_options && 'poll_common.remove_your_vote') || 'poll_common.remove_your_response',
                              icon: 'mdi-cancel',
                              dock: 1,
                              canPerform: () => this.canUpdateStance(stance),
                      Severity: Major
                      Found in vue/src/shared/services/stance_service.js and 1 other location - About 2 hrs to fix
                      vue/src/shared/services/stance_service.js on lines 62..68

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language