Showing 106 of 4,066 total issues

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

    def self.create_type(model, fields, created_types)

      created_types[model] = GraphQL::ObjectType.define do

        name        model.graphql_type_name
Severity: Minor
Found in lib/graph_ql/api_types_creator.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 included has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.included(base)
    base.extend(ClassMethods)
    class_eval do

      def hide
Severity: Minor
Found in lib/acts_as_paranoid_aliases.rb - About 1 hr to fix

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

        def initialize(user)
          can [:read, :map], Debate
          can [:read, :map, :summary, :share], Proposal
          can :read, Comment
          can :read, Poll
    Severity: Minor
    Found in app/models/abilities/everyone.rb - About 1 hr to fix

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

        def initialize(attributes = {})
          attributes.each do |name, value|
            send("#{name}=", value)
          end
      
      
      Severity: Minor
      Found in app/models/direct_upload.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

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

        def initialize(user)
          # If someone can hide something, he can also hide it
          # from the moderation screen
          alias_action :hide_in_moderation_screen, to: :hide
      
      
      Severity: Minor
      Found in app/models/custom/ability.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

      Method reason_for_not_being_ballotable_by has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def reason_for_not_being_ballotable_by(user, ballot)
            return permission_problem(user)         if permission_problem?(user)
            return :not_selected                    unless selected?
            return :no_ballots_allowed              unless budget.balloting?
            return :different_heading_assigned_html unless ballot.valid_heading?(heading)
      Severity: Minor
      Found in app/models/budget/investment.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

      Method build_results has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_results
            @results = []
      
            params[:questions].each_pair do |question_id, results|
              question = @poll.questions.find(question_id)
      Severity: Minor
      Found in app/controllers/officing/results_controller.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

      Method expect_page_to_have_translatable_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def expect_page_to_have_translatable_field(field, locale, with:)
        if input_fields.include?(field)
          if translatable_class.name == "I18nContent" && with.blank?
            expect(page).to have_field field_for(field, locale)
          else
      Severity: Minor
      Found in spec/shared/features/translatable.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

      Method fill_from_omniauth has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def fill_from_omniauth(auth)
          oauth_email           = auth['info']['email']
          oauth_email_confirmed = oauth_email.present? && (auth['info']['verified'] || auth['info']['verified_email'])
      
          self.identities << Identity.new(provider: auth['provider'], uid: auth['uid'])
      Severity: Minor
      Found in app/models/custom/user.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

      Method csv_values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def csv_values(investment)
          [
            investment.id.to_s,
            investment.title,
            investment.total_votes.to_s,
      Severity: Minor
      Found in app/models/budget/investment/exporter.rb - About 45 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 show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          # In the default implementation, this already confirms the resource:
          # self.resource = self.resource = resource_class.confirm_by_token(params[:confirmation_token])
          self.resource = resource_class.find_by(confirmation_token: params[:confirmation_token])
      
      
      Severity: Minor
      Found in app/controllers/users/confirmations_controller.rb - About 45 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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(user)
          # If someone can hide something, he can also hide it
          # from the moderation screen
          alias_action :hide_in_moderation_screen, to: :hide
      
      
      Severity: Minor
      Found in app/models/ability.rb - About 45 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 user_roles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def user_roles(user)
          roles = []
          roles << translated_role(:admin) if user.administrator?
          roles << translated_role(:moderator) if user.moderator?
          roles << translated_role(:valuator) if user.valuator?
      Severity: Minor
      Found in app/helpers/custom/admin_helper.rb - About 45 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 destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def destroy
          respond_to do |format|
            format.html do
              if @image.destroy
                flash[:notice] = t "images.actions.destroy.notice"
      Severity: Minor
      Found in app/controllers/images_controller.rb - About 45 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 next_step_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def next_step_path(user = current_user)
            if user.organization?
              { path: account_path }
            elsif user.level_three_verified?
              { path: account_path, notice: t('verification.redirect_notices.already_verified') }
      Severity: Minor
      Found in app/controllers/verification_controller.rb - About 45 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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          @resources = resource_model.all
      
          @resources = @current_order == "recommendations" && current_user.present? ? @resources.recommendations(current_user) : @resources.for_render
          @resources = @resources.search(@search_terms) if @search_terms.present?
      Severity: Minor
      Found in app/controllers/concerns/commentable_actions.rb - About 45 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 destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def destroy
          respond_to do |format|
            format.html do
              if @document.destroy
                flash[:notice] = t "documents.actions.destroy.notice"
      Severity: Minor
      Found in app/controllers/documents_controller.rb - About 45 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 embedded_video_code has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def embedded_video_code
          link = @proposal.video_url
          title = t('proposals.show.embed_video_title', proposal: @proposal.title)
          if link =~ /vimeo.*/
            server = "Vimeo"
      Severity: Minor
      Found in app/helpers/embed_videos_helper.rb - About 45 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 build has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def self.build(commentable, user, body, p_id = nil, valuation = false)
      Severity: Minor
      Found in app/models/comment.rb - About 35 mins to fix

        Method email_verification has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def email_verification(user, recipient, token, document_type, document_number)
        Severity: Minor
        Found in app/mailers/mailer.rb - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language