Showing 106 of 4,066 total issues

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

  def render_map(map_location, parent_class, editable, remove_marker_label, investments_coordinates=nil)
Severity: Minor
Found in app/helpers/map_locations_helper.rb - About 35 mins to fix

    Method user_roles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def user_roles(user)
        roles = []
        roles << :admin if user.administrator?
        roles << :moderator if user.moderator?
        roles << :valuator if user.valuator?
    Severity: Minor
    Found in app/helpers/admin_helper.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        if params[:template].index('.') # CVE-2014-0130
          render action: "index"
        elsif lookup_context.exists?("sandbox/#{params[:template]}")
          if params[:template] == "index"
    Severity: Minor
    Found in app/controllers/sandbox_controller.rb - About 35 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 proposals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def proposals
        set_process
        @phase = :proposals_phase
    
        @proposals = ::Legislation::Proposal.where(process: @process)
    Severity: Minor
    Found in app/controllers/legislation/processes_controller.rb - About 35 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 sign_in_with has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def sign_in_with(feature, provider)
          raise ActionController::RoutingError.new('Not Found') unless Setting["feature.#{feature}"]
    
          auth = env["omniauth.auth"]
    
    
    Severity: Minor
    Found in app/controllers/users/omniauth_callbacks_controller.rb - About 35 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 complete_with_csv_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.complete_with_csv_info
        ::CSV.foreach("doc/custom/CDJ_completion_utilisateurs.csv" ,{headers: :true}) do |row|
          user = User.where(email: row['Email']).first
          if user.present? && user.lastname.blank?
            p "update user #{row['Email']}"
    Severity: Minor
    Found in lib/custom/post_db_import.rb - About 35 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 validate_image_dimensions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_image_dimensions
          if attachment_of_valid_content_type?
            return true if imageable_class == Widget::Card
    
            dimensions = Paperclip::Geometry.from_file(attachment.queued_for_write[:original].path)
    Severity: Minor
    Found in app/models/image.rb - About 35 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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def check
        @document_verification = Verification::Management::Document.new(document_verification_params)
    
        if @document_verification.valid?
          if @document_verification.verified?
    Severity: Minor
    Found in app/controllers/management/document_verifications_controller.rb - About 35 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 voter_age has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def voter_age(dob)
            if dob.blank?
              nil
            else
              now = Date.current
    Severity: Minor
    Found in app/models/poll/voter.rb - About 35 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_votable_by has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def reason_for_not_being_votable_by(user)
        return :not_voting_allowed if Setting["feature.spending_proposal_features.voting_allowed"].blank?
        return :not_logged_in unless user
        return :not_verified  unless user.can?(:vote, SpendingProposal)
        return :unfeasible    if unfeasible?
    Severity: Minor
    Found in app/models/spending_proposal.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        unless params[:events].present? ||
               params[:visits].present? ||
               params[:spending_proposals].present? ||
               params[:budget_investments].present?
    Severity: Minor
    Found in app/controllers/admin/api/stats_controller.rb - About 35 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

    Avoid too many return statements within this method.
    Open

          return :not_enough_money_html           if ballot.present? && !enough_money?(ballot)
    Severity: Major
    Found in app/models/budget/investment.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return :organization  if user.organization?
      Severity: Major
      Found in app/models/spending_proposal.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return budget_investment_url(commentable.budget_id, commentable) if commentable.is_a?(Budget::Investment)
        Severity: Major
        Found in app/helpers/mailer_helper.rb - About 30 mins to fix

          Method first_or_initialize_for_oauth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.first_or_initialize_for_oauth(auth)
              oauth_email           = auth.info.email
              oauth_email_confirmed = oauth_email.present? && (auth.info.verified || auth.info.verified_email)
              oauth_user            = User.find_by(email: oauth_email) if oauth_email_confirmed
          
          
          Severity: Minor
          Found in app/models/user.rb - About 25 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 render_destroy_document_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def render_destroy_document_link(builder, document)
              if !document.persisted? && document.cached_attachment.present?
                link_to t('documents.form.delete_button'),
                            direct_upload_destroy_url("direct_upload[resource_type]": document.documentable_type,
                                                      "direct_upload[resource_id]": document.documentable_id,
          Severity: Minor
          Found in app/helpers/documents_helper.rb - About 25 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 summary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def summary
              @spending_proposals = SpendingProposal.group(:geozone).sum(:price).sort_by{|geozone, count| geozone.present? ? geozone.name : "z"}
              @spending_proposals_with_supports = SpendingProposal.with_supports.group(:geozone).sum(:price)
                                                                  .sort_by{|geozone, count| geozone.present? ? geozone.name : "z"}
            end
          Severity: Minor
          Found in app/controllers/admin/spending_proposals_controller.rb - About 25 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 current_equal_password_validation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def current_equal_password_validation
                  if !self.new_record? && !self.encrypted_password_change.nil? && !self.erased?
                    dummy = self.class.new
                    dummy.encrypted_password = self.encrypted_password_change.first
                    dummy.password_salt = self.password_salt_change.first if self.respond_to? :password_salt_change and not self.password_salt_change.nil?
          Severity: Minor
          Found in config/initializers/devise_security_extension.rb - About 25 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 comment_button_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def comment_button_text(parent_id, commentable)
              if commentable.class == Legislation::Question
                parent_id.present? ? t("comments_helper.reply_button") : t("legislation.questions.comments.comment_button")
              else
                parent_id.present? ? t("comments_helper.reply_button") : t("comments_helper.comment_button")
          Severity: Minor
          Found in app/helpers/comments_helper.rb - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              @sms = Verification::Sms.new(sms_params.merge(user: current_user))
              if @sms.verified?
                current_user.update(confirmed_phone: current_user.unconfirmed_phone)
                ahoy.track(:level_2_user, user_id: current_user.id) rescue nil
          Severity: Minor
          Found in app/controllers/verification/sms_controller.rb - About 25 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

          Severity
          Category
          Status
          Source
          Language