Skip to content

Commit

Permalink
Rubocopify
Browse files Browse the repository at this point in the history
  • Loading branch information
laurajaime committed Jul 17, 2024
1 parent 5e316e5 commit 5d04745
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Application < Rails::Application

# Make decorators available
config.to_prepare do
Dir.glob(Rails.root + "app/decorators/**/*_decorator*.rb").each do |c|
Dir.glob("#{Rails.root}app/decorators/**/*_decorator*.rb").each do |c|
require_dependency(c)
end
end
Expand Down
4 changes: 2 additions & 2 deletions config/environments/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand All @@ -111,7 +111,7 @@
# Participa: let's see SMTP data on server startup
mail_values = config.action_mailer.smtp_settings.dup
mail_values.delete(:password)
puts "=> Integration Mail Server: " + mail_values.to_s
puts "=> Integration Mail Server: #{mail_values}"

# Store files locally.
config.active_storage.service = :local
Expand Down
4 changes: 2 additions & 2 deletions config/environments/preprod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
config.log_formatter = ::Logger::Formatter.new

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down Expand Up @@ -111,7 +111,7 @@
# Participa: let's see SMTP data on server startup
mail_values = config.action_mailer.smtp_settings.dup
mail_values.delete(:password)
puts "=> Mail Server configuration: " + mail_values.to_s
puts "=> Mail Server configuration: #{mail_values}"

# Store files locally.
config.active_storage.service = :local
Expand Down
4 changes: 2 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
config.log_formatter = ::Logger::Formatter.new

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down Expand Up @@ -111,7 +111,7 @@
# Participa: let's see SMTP data on server startup
mail_values = config.action_mailer.smtp_settings.dup
mail_values.delete(:password)
puts "=> Mail Server configuration: " + mail_values.to_s
puts "=> Mail Server configuration: #{mail_values}"

# Store files locally.
config.active_storage.service = :local
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

Devise.setup do |config|
config.mailer_sender = ENV.fetch("SMTP_USERNAME") { "[email protected]" }
config.mailer_sender = ENV.fetch("SMTP_USERNAME", "[email protected]")
end
4 changes: 2 additions & 2 deletions config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def extract_ip(request)
x_forwarded_for= request.get_header("HTTP_X_FORWARDED_FOR")
Rails.logger.info { ">>>>>>>>>>>>>>>>>>>> X-Forwarded-For: #{x_forwarded_for}" }
if x_forwarded_for.present?
ip= x_forwarded_for.split(":").first
ip
x_forwarded_for.split(":").first

else
request.ip
end
Expand Down
8 changes: 4 additions & 4 deletions config/puma_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
port ENV.fetch("PORT", 3000)

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch("RAILS_ENV", "development")

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
workers ENV.fetch("WEB_CONCURRENCY", 2)

# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def add_default_image_hero(id)
# getting number of files (hero image folder)
number_of_files_hero = Dir.glob(File.join(default_images_path, "**", "*")).select { |file| File.file?(file) }.count

last_image = Decidim::ParticipatoryProcess.where("hero_image like ?", "%" + base_name +"%").last
last_image = Decidim::ParticipatoryProcess.where("hero_image like ?", "%#{base_name}%").last

if last_image.nil?
last_image = base_name + "01.png"
last_image = "#{base_name}01.png"
else
last_image = last_image[:hero_image]
image_number = last_image[(base_name.length)..(base_name.length + 1)]
Expand All @@ -60,10 +60,10 @@ def add_default_image_hero(id)
end

image_number = image_number.to_s.rjust(2, "0")
last_image = base_name + image_number + ".png"
last_image = "#{base_name}#{image_number}.png"
end

ActiveRecord::Base.connection.execute("update decidim_participatory_processes SET hero_image = '" + last_image + "' where id = " + id.to_s)
ActiveRecord::Base.connection.execute("update decidim_participatory_processes SET hero_image = '#{last_image}' where id = #{id}")

Decidim::ParticipatoryProcess.find(id).hero_image.attach(
io: File.open(File.join(default_images_path, last_image)),
Expand All @@ -80,11 +80,11 @@ def add_default_image_banner(id)
# getting number of files (banner image folder)
number_of_files_banner = Dir.glob(File.join(default_images_path_b, "**", "*")).select { |file| File.file?(file) }.count

last_image = Decidim::ParticipatoryProcess.where("banner_image like ?", "%" + base_name +"%").last
last_image = Decidim::ParticipatoryProcess.where("banner_image like ?", "%#{base_name}%").last

# if image is null (nil), we assign the first one to put in database
if last_image.nil?
last_image = base_name + "01_b.png"
last_image = "#{base_name}01_b.png"
else
# if not, we take the number of the image and we add 1 to it
last_image = last_image[:banner_image]
Expand All @@ -98,10 +98,10 @@ def add_default_image_banner(id)
end

image_number = image_number.to_s.rjust(2, "0")
last_image = base_name + image_number + "_b.png"
last_image = "#{base_name}#{image_number}_b.png"
end

ActiveRecord::Base.connection.execute("update decidim_participatory_processes SET banner_image = '" + last_image + "' where id = " + id.to_s)
ActiveRecord::Base.connection.execute("update decidim_participatory_processes SET banner_image = '#{last_image}' where id = #{id}")

Decidim::ParticipatoryProcess.find(id).banner_image.attach(
io: File.open(File.join(default_images_path_b, last_image)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ParticipatoryProcessSerializer < Decidim::Exporters::Serializer

# Public: Initializes the serializer with a ParticipatoryProcess.
def initialize(process)
super
@process = process
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Engine < ::Rails::Engine

# make decorators available to applications that use this Engine
config.to_prepare do
Dir.glob(Decidim::Process::Extended::Engine.root + "app/decorators/**/*_decorator*.rb").each do |c|
Dir.glob("#{Decidim::Process::Extended::Engine.root}app/decorators/**/*_decorator*.rb").each do |c|
load c
end
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-recaptcha/lib/decidim/recaptcha/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Engine < ::Rails::Engine

# make decorators available to applications that use this Engine
config.to_prepare do
Dir.glob(Decidim::Recaptcha::Engine.root + "app/decorators/**/*_decorator*.rb").each do |c|
Dir.glob("#{Decidim::Recaptcha::Engine.root}app/decorators/**/*_decorator*.rb").each do |c|
require_dependency(c)
end
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-regulations/lib/decidim/regulations/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Engine < ::Rails::Engine

# make decorators available to applications that use this Engine
config.to_prepare do
Dir.glob(Decidim::Regulations::Engine.root + "app/decorators/**/*_decorator*.rb").each do |c|
Dir.glob("#{Decidim::Regulations::Engine.root}app/decorators/**/*_decorator*.rb").each do |c|
require_dependency(c)
end
::Decidim::ParticipatoryProcesses::Admin::ParticipatoryProcessGroupsController.prepend(Decidim::Regulations::Admin::AvoidDeletionOfRegulationsGroup)
Expand Down
2 changes: 1 addition & 1 deletion decidim-top_comments/lib/decidim/top_comments/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Engine < ::Rails::Engine

# make decorators available to applications that use this Engine
config.to_prepare do
Dir.glob(Decidim::TopComments::Engine.root + "app/decorators/**/*_decorator*.rb").each do |c|
Dir.glob("#{Decidim::TopComments::Engine.root}app/decorators/**/*_decorator*.rb").each do |c|
load c
end
end
Expand Down
4 changes: 2 additions & 2 deletions decidim-top_comments/spec/system/most_voted_comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
end

context "when there are voted comments in Favor and Against" do
let!(:vote_1) { create(:comment_vote, :up_vote, author: author, comment: comment_for) }
let!(:vote_2) { create(:comment_vote, :up_vote, author: author, comment: comment_against) }
let!(:vote1) { create(:comment_vote, :up_vote, author: author, comment: comment_for) }
let!(:vote2) { create(:comment_vote, :up_vote, author: author, comment: comment_against) }

it "most voted comments should render both comments" do
visit resource_path
Expand Down
1 change: 1 addition & 0 deletions decidim-type/app/commands/decidim/admin/create_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CreateType < Decidim::Command
#
# form - A form object with the params.
def initialize(form)
super
@form = form
end

Expand Down
1 change: 1 addition & 0 deletions decidim-type/app/commands/decidim/admin/update_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class UpdateType < Decidim::Command
# scope - The Scope to update
# form - A form object with the params.
def initialize(type, form)
super
@type = type
@form = form
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-type/lib/decidim/type/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Engine < ::Rails::Engine

# make decorators available to applications that use this Engine
config.to_prepare do
Dir.glob(Decidim::Type::Engine.root + "app/decorators/**/*_decorator*.rb").each do |c|
Dir.glob("#{Decidim::Type::Engine.root}app/decorators/**/*_decorator*.rb").each do |c|
load c
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/tasks/move_custom_categorizations.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Next tasks are necessary to be executed when deployed
# because there are some custom categorizations to be removed
# and leave it as Decidim standards
# rubocop:disable Lint/ConstantDefinitionInBlock
namespace :move_custom_categorizations do
desc "Move Deparments to Areas"
task departments_to_areas: [:environment] do
Expand Down Expand Up @@ -85,14 +86,13 @@ namespace :move_custom_categorizations do
desc "Move all custom categorizations and assign the new relations"
task all: [:departments_to_areas, :themes_to_scopes, :assign_scopes_to_participatory_processes, :assign_areas_to_participatory_processes]

def localized(locales, key)
def localized(locales, key, &block)
locales.inject({}) do |result, locale|
I18n.locale = locale
text = I18n.t(key) do
yield
end
text = I18n.t(key, &block)

result.update(locale => text)
end.with_indifferent_access
end
end
# rubocop:enable Lint/ConstantDefinitionInBlock

0 comments on commit 5d04745

Please sign in to comment.