Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed Jan 15, 2025
1 parent 8763000 commit baaada3
Show file tree
Hide file tree
Showing 52 changed files with 396 additions and 394 deletions.
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ end
group :development do
gem "letter_opener_web", "~> 2.0"
gem "listen", "~> 3.8"

# rubocop & rubocop-rspec are set to the following versions because of a change where FactoryBot/CreateList
# must be a boolean instead of contextual. These version locks can be removed when this problem is handled
# through decidim-dev.
gem "rubocop", "~>1.28"
gem "rubocop-faker"
gem "rubocop-rspec", "2.20"

gem "spring", "~> 4.1.3"
gem "spring-watcher-listen", "~> 2.1"
gem "web-console", "~> 4.2"
Expand Down
12 changes: 4 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,6 @@ GEM
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.26.0)
rubocop (~> 1.41)
rubocop-faker (1.2.0)
faker (>= 2.12.0)
rubocop (>= 1.13.0)
Expand All @@ -735,13 +733,9 @@ GEM
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.31.0)
rubocop (~> 1.40)
rubocop-rspec (2.20.0)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.29.0)
rubocop (~> 1.40)
ruby-progressbar (1.13.0)
ruby-vips (2.2.2)
ffi (~> 1.12)
Expand Down Expand Up @@ -870,7 +864,9 @@ DEPENDENCIES
letter_opener_web (~> 2.0)
listen (~> 3.8)
puma (>= 5.6.2)
rubocop (~> 1.28)
rubocop-faker
rubocop-rspec (= 2.20)
spring (~> 4.1.3)
spring-watcher-listen (~> 2.1)
web-console (~> 4.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def resource_path

def card_wrapper
cls = card_classes.is_a?(Array) ? card_classes.join(" ") : card_classes
wrapper_options = { class: "card #{cls}", aria: { label: t(".card_label", title: title) } }
wrapper_options = { class: "card #{cls}", aria: { label: t(".card_label", title:) } }
if has_link_to_resource? && !voting?
link_to resource_path, **wrapper_options do
yield
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def update_project
description: form.description,
budget_amount: form.budget_amount,
budget_amount_min: form.budget_amount_min,
selected_at: selected_at,
selected_at:,
address: form.address,
latitude: form.latitude,
longitude: form.longitude
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def result_attributes_from(original_project, weight: 0)
description: original_project.description,
progress: statuses.first&.progress || 0,
status: statuses.first,
weight: weight
weight:
}.merge(extra_result_attributes_from(original_project))
end

Expand Down
6 changes: 3 additions & 3 deletions app/commands/decidim/budgets/checkout_orders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ def create_vote
user,
{
component: orders.first.component,
user: user,
orders: orders
user:,
orders:
},
visibility: "private-only"
)
end

def has_existing_vote?
Decidim::Budgets::Vote.find_by(component: orders.first.component, user: user).present?
Decidim::Budgets::Vote.find_by(component: orders.first.component, user:).present?
end

def send_summary
Expand Down
4 changes: 2 additions & 2 deletions app/commands/decidim/budgets/start_voting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ def call
attr_reader :form, :user, :workflow, :orders

def destroy_previous_orders!
Decidim::Budgets::Order.where(budget: budgets, user: user).where.not(
Decidim::Budgets::Order.where(budget: budgets, user:).where.not(
budget: selected_budgets
).destroy_all
end

def create_orders!
@orders = selected_budgets.map do |budget|
Decidim::Budgets::Order.find_or_create_by!(user: user, budget: budget)
Decidim::Budgets::Order.find_or_create_by!(user:, budget:)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def new
enforce_permission_to :create, :project
@form = form(Decidim::Budgets::Admin::ProjectForm).from_params(
{ attachment: form(AttachmentForm).instance },
budget: budget
budget:
)
end

def edit
enforce_permission_to :update, :project, project: project
@form = form(Decidim::Budgets::Admin::ProjectForm).from_model(project, budget: budget)
enforce_permission_to(:update, :project, project:)
@form = form(Decidim::Budgets::Admin::ProjectForm).from_model(project, budget:)
@form.attachment = form(AttachmentForm).instance
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def authorization_required?
if handlers && handlers.any?
providers = Decidim::BudgetingPipeline.authorization_providers
providers = providers.call(current_organization) if providers.respond_to?(:call)
(handlers & providers).any?
handlers.intersect?(providers)
else
false
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module LineItemsControllerExtensions
helper Decidim::Budgets::VotesHelper

def create
enforce_permission_to :vote, :project, project: project, budget: budget, workflow: current_workflow
enforce_permission_to :vote, :project, project:, budget:, workflow: current_workflow

@added = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module OrdersControllerExtensions
before_action :set_breadcrumbs, only: [:index]
end

def index; end

private

def ensure_checked_out_orders!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ module ProjectsControllerExtensions
include Decidim::BudgetingPipeline::Orderable

included do
# rubocop:disable Rails/LexicallyScopedActionFilter
before_action :set_breadcrumbs, only: [:index, :show]
# rubocop:enable Rails/LexicallyScopedActionFilter

helper_method :authorization_required?, :user_authorized?, :help_sections, :geocoded_projects, :budgets, :maximum_project_budget, :vote_success?

helper Decidim::BudgetingPipeline::AuthorizationHelper

def index; end

def show
raise ActionController::RoutingError, "Not Found" unless project
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ def new
@form = form(HelpSectionForm).instance
end

def edit
enforce_permission_to :update, :help_section, help_section: section
@form = form(HelpSectionForm).from_model(section)
end

def create
enforce_permission_to :create, :help_section
@form = form(HelpSectionForm).from_params(params, current_component: current_component)
@form = form(HelpSectionForm).from_params(params, current_component:)

CreateHelpSection.call(@form, container) do
on(:ok) do
Expand All @@ -35,14 +40,9 @@ def create
end
end

def edit
enforce_permission_to :update, :help_section, help_section: section
@form = form(HelpSectionForm).from_model(section)
end

def update
enforce_permission_to :update, :help_section, help_section: section
@form = form(HelpSectionForm).from_params(params, current_component: current_component)
@form = form(HelpSectionForm).from_params(params, current_component:)

UpdateHelpSection.call(@form, section) do
on(:ok) do
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/decidim/budgets/results_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def projects_with_votes(budget)
@projects_with_votes ||= {}
return @projects_with_votes[budget.id] if @projects_with_votes[budget.id].present?

@projects_with_votes[budget.id] = Decidim::Budgets::Project.where(budget: budget).order_by_most_voted(only_voted: true).select(
@projects_with_votes[budget.id] = Decidim::Budgets::Project.where(budget:).order_by_most_voted(only_voted: true).select(
"decidim_budgets_projects.*",
"decidim_budgets_projects_with_votes.votes_count"
)
Expand All @@ -78,14 +78,14 @@ def minimum_project_budget(budget)
@minimum_project_budget ||= {}
return @minimum_project_budget[budget.id] if @minimum_project_budget[budget.id].present?

@minimum_project_budget[budget.id] = Decidim::Budgets::Project.where(budget: budget).minimum(:budget_amount)
@minimum_project_budget[budget.id] = Decidim::Budgets::Project.where(budget:).minimum(:budget_amount)
end

def maximum_project_budget(budget)
@maximum_project_budget ||= {}
return @maximum_project_budget[budget.id] if @maximum_project_budget[budget.id].present?

@maximum_project_budget[budget.id] = Decidim::Budgets::Project.where(budget: budget).maximum(:budget_amount)
@maximum_project_budget[budget.id] = Decidim::Budgets::Project.where(budget:).maximum(:budget_amount)
end

def vote_success?
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/decidim/budgets/votes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def show
redirect_to routes_proxy.budgets_vote_path
end

def preview; end

def budgets
@form = form(BudgetSelectForm).from_model(current_workflow)
end
Expand Down Expand Up @@ -256,7 +258,7 @@ def voting_steps
false
end

OpenStruct.new(key: key, done: done, available: available, link: step_link)
OpenStruct.new(key:, done:, available:, link: step_link)
end

steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def projects_data_for_map(geocoded_projects_data)
{
id: data[0],
title: data[1],
body: body,
body:,
address: data[4],
latitude: data[5],
longitude: data[6],
Expand Down Expand Up @@ -125,7 +125,7 @@ def project_map_link(resource, options = {})
map_utility_static.link(
latitude: resource.latitude,
longitude: resource.longitude,
options: options
options:
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/decidim/budgets/results_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def display_amounts_for?(budget)
end

def selected_projects(budget)
Decidim::Budgets::Project.where(budget: budget).where.not(selected_at: nil)
Decidim::Budgets::Project.where(budget:).where.not(selected_at: nil)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/decidim/budgets/order_summaries_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def order_summaries(orders, user)
scope: "decidim.budgets.order_summaries_mailer",
budget_names: @budget_names.join(", ")
)
mail(to: user.email, subject: subject)
mail(to: user.email, subject:)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/decidim/budgets/project_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def project
def title(links: false, extras: true, html_escape: false, all_locales: false)
return unless project

super project.title, links, html_escape, all_locales, extras: extras
super project.title, links, html_escape, all_locales, extras:
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20210820123351_create_budgeting_votes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def change
:decidim_budgets_votes,
decidim_user_id: user_id,
decidim_component_id: component_id,
created_at: created_at,
created_at:,
updated_at: created_at
)

Expand Down Expand Up @@ -116,7 +116,7 @@ def change
manifest_name: space_manifest
}
},
created_at: created_at,
created_at:,
updated_at: created_at,
visibility: "private-only",
decidim_scope_id: scope_id,
Expand Down
12 changes: 6 additions & 6 deletions lib/decidim/api/budget_mutation_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def create_project(attributes:)
end

def update_project(id:, attributes:)
project = object.projects.find_by(id: id)
project = object.projects.find_by(id:)
return unless project

enforce_permission_to :update, :project, project: project
enforce_permission_to(:update, :project, project:)

form = project_form_from(attributes, project)
Decidim::Budgets::Admin::UpdateProject.call(form, project) do
Expand All @@ -76,10 +76,10 @@ def update_project(id:, attributes:)
end

def delete_project(id:)
project = object.projects.find_by(id: id)
project = object.projects.find_by(id:)
return unless project

enforce_permission_to :destroy, :project, project: project
enforce_permission_to(:destroy, :project, project:)

Decidim::Budgets::Admin::DestroyProject.call(project, current_user) do
on(:ok) do
Expand All @@ -98,9 +98,9 @@ def project_form_from(attributes, project = nil)
Decidim::Budgets::Admin::ProjectForm.from_params(
"project" => project_params(attributes, project)
).with_context(
current_organization: current_organization,
current_organization:,
current_component: object.component,
current_user: current_user,
current_user:,
budget: object
)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/decidim/budgeting_pipeline/api/permissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def enforce_permission_to(action, subject, extra_context = {})

def allowed_to?(action, subject, extra_context = {}, user = current_user)
scope ||= :admin
permission_action = Decidim::PermissionAction.new(scope: scope, action: action, subject: subject)
permission_action = Decidim::PermissionAction.new(scope:, action:, subject:)

permission_class_chain.inject(permission_action) do |current_permission_action, permission_class|
permission_class.new(
Expand Down
2 changes: 1 addition & 1 deletion lib/decidim/budgeting_pipeline/help_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.find(key)

def self.all
@all ||= [:index, :pipeline].map do |key|
new(key: key)
new(key:)
end
end
end
Expand Down
Loading

0 comments on commit baaada3

Please sign in to comment.