AyuntamientoMadrid/participacion

View on GitHub

Showing 143 of 2,535 total issues

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 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 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 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 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 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 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 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 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 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 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_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

        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 embedded_video_code has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def embedded_video_code(resource)
            link = resource.video_url
            title = t("proposals.show.embed_video_title", proposal: resource.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 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 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 sign_in_with has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def sign_in_with(feature, provider)
                raise ActionController::RoutingError, "Not Found" unless Setting["feature.#{feature}"]
          
                auth = request.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 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

          Severity
          Category
          Status
          Source
          Language