AyuntamientoMadrid/participacion

View on GitHub

Showing 143 of 2,535 total issues

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

  def show
    draft_version = @process.draft_versions.published.last
    allegations_phase = @process.allegations_phase

    if @process.homepage_enabled? && @process.homepage.present?
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 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 header has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def header(before: nil, skip_section_title: false, &block)
    provide(:title) do
      [
        (t("#{namespace}.header.title", default: "") unless skip_section_title),
        strip_tags(title),
Severity: Minor
Found in app/components/concerns/header.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 :casted_offline             if ballot.casted_offline?
Severity: Major
Found in app/models/budget/investment.rb - About 30 mins to fix

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

      def css_for_proposal_info_row(proposal)
        if proposal.image.present?
          if params[:selected].present?
            "small-12 medium-9 column"
          else
    Severity: Minor
    Found in app/helpers/proposals_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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def call(document_type, document_number, date_of_birth, postal_code)
        return Response.new if document_number.blank? || document_type.blank?
    
        if Setting["feature.remote_census"].present?
          response = RemoteCensusApi.new.call(document_type, document_number, date_of_birth, postal_code)
    Severity: Minor
    Found in app/lib/census_caller.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 investments_filters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def investments_filters
        [
          ("winners" if finished?),
          ("selected" if publishing_prices_or_later? && !finished?),
          ("unselected" if publishing_prices_or_later?),
    Severity: Minor
    Found in app/models/budget.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

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

      def create
        self.resource = resource_class.send_confirmation_instructions(resource_params)
        yield resource if block_given?
    
        if successfully_sent?(resource)
    Severity: Minor
    Found in app/controllers/users/confirmations_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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        if is_heading_content_block?(@content_block.name)
          heading_content_block = new_heading_content_block
          if heading_content_block.save
            notice = t("admin.site_customization.content_blocks.create.notice")
    Severity: Minor
    Found in app/controllers/admin/site_customization/content_blocks_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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def update
        if is_heading_content_block?(params[:site_customization_content_block][:name])
          heading_content_block = new_heading_content_block
          if heading_content_block.save
            @content_block.destroy!
    Severity: Minor
    Found in app/controllers/admin/site_customization/content_blocks_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 avatar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def avatar
          if comment.as_administrator?
            special_avatar("avatar_admin.png", class: "admin-avatar")
          elsif comment.as_moderator?
            special_avatar("avatar_moderator.png", class: "moderator-avatar")
    Severity: Minor
    Found in app/components/comments/avatar_component.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 conditional_validator? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def conditional_validator?(validator)
            return false unless validator.options[:unless]
    
            if validator.options[:unless].to_proc.arity.zero?
              instance_exec(&validator.options[:unless])
    Severity: Minor
    Found in app/models/concerns/globalizable.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 confirmation_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def confirmation_text
          if options[:confirm] == true
            if action == :destroy
              t("admin.actions.confirm_delete", name: record_name)
            else
    Severity: Minor
    Found in app/components/admin/action_component.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 !new_record? && !encrypted_password_change.nil? && !erased?
              dummy = self.class.new
              dummy.encrypted_password = encrypted_password_change.first
    
    
    Severity: Minor
    Found in config/initializers/devise-security.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 normalized_coordinates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def normalized_coordinates
          if geojson.present?
            if geojson.match(/"coordinates"\s*:\s*\[\s*\[\s*\[\s*\[/)
              coordinates.reduce([], :concat).reduce([], :concat)
            elsif geojson.match(/"coordinates"\s*:\s*\[\s*\[\s*\[/)
    Severity: Minor
    Found in app/models/geozone.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 validates_translation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def validates_translation(method, options = {})
          validates(method, options.merge(if: lambda { |resource| resource.translations.blank? }))
          if options.include?(:length)
            translation_class.instance_eval do
              validates method,
    Severity: Minor
    Found in app/models/concerns/globalizable.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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        if params[:event].blank? &&
           params[:visits].blank? &&
           params[:budget_investments].blank? &&
           params[:user_supported_budgets].blank?
    Severity: Minor
    Found in app/controllers/admin/api/stats_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 copy_error_to_current_translation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def copy_error_to_current_translation
            return unless errors.added?(:base, :translations_too_short)
    
            if locales_persisted_and_marked_for_destruction.include?(I18n.locale)
              locale = I18n.locale
    Severity: Minor
    Found in app/models/concerns/globalizable.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 valid_date_ranges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def valid_date_ranges
          if end_date && start_date && end_date < start_date
            errors.add(:end_date, :invalid_date_range)
          end
          if debate_end_date && debate_start_date && debate_end_date < debate_start_date
    Severity: Minor
    Found in app/models/legislation/process.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