loomio/loomio

View on GitHub

Showing 182 of 182 total issues

Function setAlignment has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function setAlignment (type, attrs = {}) {
  return (state, dispatch) => {
    const {
      doc,
      selection,
Severity: Major
Found in vue/src/shared/tiptap_extentions/utils/alignment.js - About 3 hrs to fix

    Class RecordCache has 29 methods (exceeds 20 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 3 hrs to fix

      File ninties_movies_helper.rb has 311 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Dev::NintiesMoviesHelper
        include Dev::FakeDataHelper
      
        private
      
      
      Severity: Minor
      Found in app/helpers/dev/ninties_movies_helper.rb - About 3 hrs to fix

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

          def initialize(user)
            super(user)
        
            can [:show], ::Group do |group|
              !group.archived_at &&
        Severity: Minor
        Found in app/models/ability/group.rb - About 3 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 28 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Base
            attr_accessor :name, :installed, :enabled # GK: TODO: enabled is to prevent existing plugins from blowing up, but we should fix all the plugins
            attr_reader :assets, :static_assets, :actions, :events, :outlets, :routes, :translations, :extensions, :enabled, :config
            alias :read_attribute_for_serialization :send
        
        
        Severity: Minor
        Found in lib/plugins/base.rb - About 3 hrs to fix

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

          var CZECH_MAP = {
              'č':'c', 'ď':'d', 'ě':'e', 'ň': 'n', 'ř':'r', 'š':'s', 'ť':'t', 'ů':'u',
              'ž':'z', 'Č':'C', 'Ď':'D', 'Ě':'E', 'Ň': 'N', 'Ř':'R', 'Š':'S', 'Ť':'T',
              'Ů':'U', 'Ž':'Z'
          }
          Severity: Major
          Found in vue/src/shared/helpers/parameterize.js and 1 other location - About 3 hrs to fix
          vue/src/shared/helpers/parameterize.js on lines 53..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 98.

          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

          var POLISH_MAP = {
              'ą':'a', 'ć':'c', 'ę':'e', 'ł':'l', 'ń':'n', 'ó':'o', 'ś':'s', 'ź':'z',
              'ż':'z', 'Ą':'A', 'Ć':'C', 'Ę':'e', 'Ł':'L', 'Ń':'N', 'Ó':'o', 'Ś':'S',
              'Ź':'Z', 'Ż':'Z'
          }
          Severity: Major
          Found in vue/src/shared/helpers/parameterize.js and 1 other location - About 3 hrs to fix
          vue/src/shared/helpers/parameterize.js on lines 47..51

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

          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 accessible_records has a Cognitive Complexity of 22 (exceeds 5 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 3 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 printHtml has a Cognitive Complexity of 22 (exceeds 5 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 3 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 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def initialize(user)
              super(user)
          
              can [:show], ::Group do |group|
                !group.archived_at &&
          Severity: Major
          Found in app/models/ability/group.rb - About 2 hrs to fix

            Method initialize has a Cognitive Complexity of 21 (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

            File group.rb has 287 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class Group < ApplicationRecord
              include HasTimeframe
              include HasRichText
              include CustomCounterCache::Model
              include ReadableUnguessableUrls
            Severity: Minor
            Found in app/models/group.rb - About 2 hrs to fix

              File record_cache.rb has 286 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

                Class DiscussionsController has 25 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class API::V1::DiscussionsController < API::V1::RestfulController
                  def create
                    instantiate_resource
                    if resource_params[:forked_event_ids] && resource_params[:forked_event_ids].any?
                      EventService.move_comments(discussion: create_action.discussion, params: resource_params, actor: current_user)
                Severity: Minor
                Found in app/controllers/api/v1/discussions_controller.rb - About 2 hrs to fix

                  Class ProfileController has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class API::V1::ProfileController < API::V1::RestfulController
                    def show
                      load_and_authorize :user
                      respond_with_resource serializer: UserSerializer
                    end
                  Severity: Minor
                  Found in app/controllers/api/v1/profile_controller.rb - About 2 hrs to fix

                    Class Discussion has 24 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Discussion < ApplicationRecord
                      include CustomCounterCache::Model
                      include ReadableUnguessableUrls
                      include Forkable
                      include Translatable
                    Severity: Minor
                    Found in app/models/discussion.rb - About 2 hrs to fix

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

                        def initialize(user)
                          super(user)
                      
                          can :add_options, ::Poll do |poll|
                            user_is_author_of?(poll) || (user.can?(:vote_in, poll) && poll.voter_can_add_options)
                      Severity: Major
                      Found in app/models/ability/poll.rb - About 2 hrs to fix

                        Method initialize has 64 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

                          File polls_scenario_helper.rb has 267 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          module Dev::PollsScenarioHelper
                            private
                          
                            def poll_created_scenario(params)
                              group = create_group_with_members
                          Severity: Minor
                          Found in app/helpers/dev/polls_scenario_helper.rb - About 2 hrs to fix

                            File user.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            class User < ApplicationRecord
                              include CustomCounterCache::Model
                              include ReadableUnguessableUrls
                              include MessageChannel
                              include HasExperiences
                            Severity: Minor
                            Found in app/models/user.rb - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language