loomio/loomio

View on GitHub

Showing 182 of 182 total issues

Method relations has a Cognitive Complexity of 17 (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))', {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

Class Base has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class Clients::Base
  attr_reader :key

  def self.instance
    new(
Severity: Minor
Found in app/extras/clients/base.rb - About 2 hrs to fix

    Method relations has 53 lines of code (exceeds 25 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))', {group_ids: model.group.id})
    Severity: Major
    Found in app/queries/user_query.rb - About 2 hrs to fix

      Function init has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        init() {
          this.editor.on('init', ({ state }) => {
            this.options.me.cursor = state.selection.anchor
            this.options.me.focused = state.selection.focused
            this.options.socket.emit('cursorchange', this.options.me)
      Severity: Minor
      Found in vue/src/shared/tiptap_extentions/collaboration.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

      Method create_all_notifications has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create_all_notifications
          #'reaction_created'
          comment = Comment.new(discussion: create_discussion, body: 'I\'m rather likeable')
          reaction = Reaction.new(reactable: comment, reaction: ":heart:")
          new_comment_event = CommentService.create(comment: comment, actor: patrick)
      Severity: Major
      Found in app/helpers/dev/ninties_movies_helper.rb - About 2 hrs to fix

        Function init has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          init() {
            this.editor.on('init', ({ state }) => {
              this.options.me.cursor = state.selection.anchor
              this.options.me.focused = state.selection.focused
              this.options.socket.emit('cursorchange', this.options.me)
        Severity: Major
        Found in vue/src/shared/tiptap_extentions/collaboration.js - About 2 hrs to fix

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

          function finduploadPlaceholder(state, id) {
            let decos = uploadPlaceholderPlugin.getState(state)
            let found = decos.find(null, null, spec => spec.id == id)
            return found.length ? found[0].from : null
          }
          Severity: Major
          Found in vue/src/shared/tiptap_extentions/image.js and 1 other location - About 2 hrs to fix
          vue/src/shared/tiptap_extentions/placeholder_plugin.js on lines 5..9

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

          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

          export function findPlaceholder(state, id) {
            let decos = placeholderPlugin.getState(state)
            let found = decos.find(null, null, spec => spec.id == id)
            return found.length ? found[0].from : null
          }
          Severity: Major
          Found in vue/src/shared/tiptap_extentions/placeholder_plugin.js and 1 other location - About 2 hrs to fix
          vue/src/shared/tiptap_extentions/image.js on lines 35..39

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

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

            get defaultOptions() {
              let clientID = Math.floor(Math.random() * 0xFFFFFFFF)
              return {
                version: 0,
                me: {},
          Severity: Minor
          Found in vue/src/shared/tiptap_extentions/collaboration.js - About 1 hr to fix

            Method for_collection has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.for_collection(collection, user_id, exclude_types = [])
                obj = self.new
                obj.exclude_types = exclude_types
                obj.current_user_id = user_id
                return obj unless item = collection.to_a.first
            Severity: Minor
            Found in app/services/record_cache.rb - About 1 hr to fix

              Method perform has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                def perform
                  # email users who have day = 7 and hour = 6
                  # and email users with day = today and hour = 6
                  User.pluck('DISTINCT time_zone').each do |zone|
                    if Time.find_zone(zone)
              Severity: Minor
              Found in app/workers/send_daily_catch_up_email_worker.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 applyMark has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              function applyMark (tr, markType, attrs) {
                if (!tr.selection || !tr.doc || !markType) {
                  return tr
                }
              
              
              Severity: Minor
              Found in vue/src/shared/tiptap_extentions/utils/mark.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 exports has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = env => {
                return {
                  chainWebpack: config => {
                    config.module.rule('vue').use('vue-loader').tap(args => { args.compilerOptions.whitespace = 'preserve' })
                    config.module.rule('yml').test(/\.yml$/).use('js-yaml-loader').loader('js-yaml-loader').end()
              Severity: Minor
              Found in vue/vue.config.js - About 1 hr to fix

                Function printHtml has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function printHtml (dom) {
                  let style = Array.from(document.querySelectorAll('style, link'))
                    .reduce((str, style) => str + style.outerHTML, '')
                  style = style.replace(new RegExp('<link href=".*.js" .*[ht]">', 'g'), '')
                  style = style.replace(new RegExp('href="', 'g'), 'href="/')
                Severity: Minor
                Found in vue/src/shared/tiptap_extentions/utils/print.js - About 1 hr to fix

                  Function defaultOptions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    get defaultOptions() {
                      let clientID = Math.floor(Math.random() * 0xFFFFFFFF)
                      return {
                        version: 0,
                        me: {},
                  Severity: Minor
                  Found in vue/src/shared/tiptap_extentions/collaboration.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

                  Consider simplifying this complex logical expression.
                  Open

                    if (empty) {
                      const storedMarks = tr.storedMarks ||
                        state.storedMarks ||
                        (
                          selection instanceof TextSelection &&
                  Severity: Critical
                  Found in vue/src/shared/tiptap_extentions/utils/mark.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                      if (empty) {
                        const storedMarks = tr.storedMarks ||
                          state.storedMarks ||
                          (
                            selection instanceof TextSelection &&
                    Severity: Critical
                    Found in vue/src/shared/tiptap_extentions/utils/mark.js - About 1 hr to fix

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

                        def setup_discussion_mailer_comment_replied_to_email
                          @group = Group.create!(name: 'Dirty Dancing Shoes')
                          @group.add_admin!(patrick)
                          @group.add_member! jennifer
                      
                      
                      Severity: Major
                      Found in app/controllers/dev/scenarios/legacy.rb and 1 other location - About 1 hr to fix
                      app/controllers/dev/scenarios/discussion.rb on lines 160..174

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

                      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

                        def setup_discussion_mailer_comment_replied_to_email
                          @group = Group.create!(name: 'Dirty Dancing Shoes')
                          @group.add_admin!(patrick)
                          @group.add_member! jennifer
                      
                      
                      Severity: Major
                      Found in app/controllers/dev/scenarios/discussion.rb and 1 other location - About 1 hr to fix
                      app/controllers/dev/scenarios/legacy.rb on lines 54..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 67.

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

                        def self.pull_paperclips(filename, base_url = 'https://loomio-uploads.s3.amazonaws.com')
                          tables = {'users' => ['uploaded_avatar'], 'groups' => ['cover_photo', 'logo'], 'documents' => ['file']}
                          File.open(filename, 'r').each do |line|
                            data = JSON.parse(line)
                            record = data['record']
                      Severity: Minor
                      Found in app/services/group_export_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

                      Severity
                      Category
                      Status
                      Source
                      Language