AyuntamientoMadrid/participacion

View on GitHub

Showing 143 of 1,085 total issues

Method basic_translations has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.basic_translations
    %w[
      debates.index.section_footer.title
      debates.index.section_footer.description
      debates.index.section_footer.help_text_1
Severity: Minor
Found in app/models/i18n_content.rb - About 1 hr to fix

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

      def create
        if !@process.allegations_phase.open? || @draft_version.final_version?
          render(json: {}, status: :not_found) && return
        end
    
    
    Severity: Minor
    Found in app/controllers/legislation/annotations_controller.rb - About 1 hr to fix

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

          def import_ml_proposals_tags
            ids = {}
            json_file = data_folder.join(MachineLearning.proposals_tags_filename)
            json_data = JSON.parse(File.read(json_file)).each(&:deep_symbolize_keys!)
            json_data.each do |attributes|
      Severity: Minor
      Found in app/models/machine_learning.rb - About 1 hr to fix

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

          def settings
            %w[
              feature.featured_proposals
              feature.facebook_login
              feature.google_login
        Severity: Minor
        Found in app/components/admin/settings/features_tab_component.rb - About 1 hr to fix

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

              def data_output_files
                files = { tags: [], related_content: [], comments_summary: [] }
          
                if File.exist?(data_folder.join(proposals_tags_filename))
                  files[:tags] << proposals_tags_filename
          Severity: Minor
          Found in app/models/machine_learning.rb - About 1 hr to fix

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

                def import_ml_investments_tags
                  ids = {}
                  json_file = data_folder.join(MachineLearning.investments_tags_filename)
                  json_data = JSON.parse(File.read(json_file)).each(&:deep_symbolize_keys!)
                  json_data.each do |attributes|
            Severity: Minor
            Found in app/models/machine_learning.rb - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  unless namespace == "officing"
                    user&.administrator? || user&.moderator? || user&.valuator? ||
                      (user&.manager? && namespace != "management") || user&.poll_officer? || user&.sdg_manager?
                  end
              Severity: Major
              Found in app/helpers/users_helper.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 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 reason_for_not_being_ballotable_by has a Cognitive Complexity of 8 (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 unless ballot.valid_heading?(heading)
                Severity: Minor
                Found in app/models/budget/investment.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 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 data_output_files has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def data_output_files
                      files = { tags: [], related_content: [], comments_summary: [] }
                
                      if File.exist?(data_folder.join(proposals_tags_filename))
                        files[:tags] << proposals_tags_filename
                Severity: Minor
                Found in app/models/machine_learning.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 import_proposals_related_content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def import_proposals_related_content
                      json_file = data_folder.join(MachineLearning.proposals_related_filename)
                      json_data = JSON.parse(File.read(json_file)).each(&:deep_symbolize_keys!)
                      json_data.each do |related|
                        id = related.delete(:id)
                Severity: Minor
                Found in app/models/machine_learning.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 proposals has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def proposals
                    set_process
                    @phase = :proposals_phase
                
                    @proposals = ::Legislation::Proposal.where(process: @process).filter_by(params[:advanced_search])
                Severity: Minor
                Found in app/controllers/legislation/processes_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 order_filter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.order_filter(params)
                      sorting_key = params[:sort_by]&.downcase&.to_sym
                      allowed_sort_option = SORTING_OPTIONS[sorting_key]
                      direction = params[:direction] == "desc" ? "desc" : "asc"
                
                
                Severity: Minor
                Found in app/models/budget/investment.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 update_heading_content_block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def update_heading_content_block
                    heading_content_block = Budget::ContentBlock.find(params[:id])
                    if is_heading_content_block?(params[:name])
                      heading_content_block.locale = params[:locale]
                      heading_content_block.body = params[:body]
                Severity: Minor
                Found in app/controllers/admin/site_customization/content_blocks_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 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 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 import_budget_investments_related_content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def import_budget_investments_related_content
                      json_file = data_folder.join(MachineLearning.investments_related_filename)
                      json_data = JSON.parse(File.read(json_file)).each(&:deep_symbolize_keys!)
                      json_data.each do |related|
                        id = related.delete(:id)
                Severity: Minor
                Found in app/models/machine_learning.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

                Severity
                Category
                Status
                Source
                Language