Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Feb 2, 2024
1 parent ac47a80 commit aff13d4
Show file tree
Hide file tree
Showing 173 changed files with 1,309 additions and 1,260 deletions.
100 changes: 50 additions & 50 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'rails', '~> 6.1.1'
gem 'rails-i18n', '~> 7.0'
gem "activeadmin", "~> 2.14"
gem "active_storage_validations", "~> 1.1.3"
gem "aws-sdk-s3", "~> 1.94", require: false
gem "bootsnap", "~> 1.12.0", require: false
gem "devise", "~> 4.9.1"
gem "devise-i18n", "~> 1.11.0"
gem "has_scope", "~> 0.7.2"
gem "http_accept_language", "~> 2.1.1"
gem "image_processing", "~> 1.12"
gem "json_translate", "~> 4.0.0"
gem "kaminari", "~> 1.2.1"
gem "pg", "~> 1.4"
gem "pg_search", "~> 2.3.5"
gem "prawn", "~> 2.4.0"
gem "prawn-table", "~> 0.2.2"
gem "puma", ">= 5.0.0"
gem 'rdiscount', '~> 2.2.7'
gem 'rubyzip', '~> 2.3.0'
gem 'activeadmin', '~> 2.14'
gem 'bootsnap', '~> 1.12.0', require: false
gem 'has_scope', '~> 0.7.2'
gem 'pundit', '~> 2.1.0'
gem 'pg', '~> 1.4'
gem 'json_translate', '~> 4.0.0'
gem 'devise', '~> 4.9.1'
gem 'devise-i18n', '~> 1.11.0'
gem 'http_accept_language', '~> 2.1.1'
gem 'kaminari', '~> 1.2.1'
gem 'simple_form', '~> 5.0.2'
gem 'rollbar', '~> 2.22.1'
gem 'prawn', '~> 2.4.0'
gem 'prawn-table', '~> 0.2.2'
gem 'pg_search', '~> 2.3.5'
gem 'skylight', '~> 5.0'
gem 'sidekiq', '~> 6.5'
gem 'sidekiq-cron', '~> 1.9.1'
gem 'aws-sdk-s3', '~> 1.94', require: false
gem 'image_processing', '~> 1.12'
gem 'active_storage_validations', '~> 1.1.3'
gem "pundit", "~> 2.1.0"
gem "rails", "~> 6.1.1"
gem "rails-i18n", "~> 7.0"
gem "rdiscount", "~> 2.2.7"
gem "rollbar", "~> 2.22.1"
gem "rubyzip", "~> 2.3.0"
gem "sidekiq", "~> 6.5"
gem "sidekiq-cron", "~> 1.9.1"
gem "simple_form", "~> 5.0.2"
gem "skylight", "~> 5.0"

# Assets
gem 'jquery-rails', '~> 4.4.0'
gem 'bootstrap-sass', '~> 3.4'
gem 'sassc-rails', '~> 2.1.2'
gem 'select2-rails', '~> 4.0.13'
gem "bootstrap-sass", "~> 3.4"
gem "jquery-rails", "~> 4.4.0"
gem "sassc-rails", "~> 2.1.2"
gem "select2-rails", "~> 4.0.13"

group :production do
# we are using an ExecJS runtime only on the precompilation phase
gem 'uglifier', '~> 4.2.0', require: false
gem "uglifier", "~> 4.2.0", require: false
end

group :development do
gem 'listen', '~> 3.2.0'
gem 'localeapp', '~> 3.3', require: false
gem 'letter_opener', '~> 1.7.0'
gem 'web-console', '~> 4.1.0'
gem 'uglifier', '~> 4.2.0'
gem "letter_opener", "~> 1.7.0"
gem "listen", "~> 3.2.0"
gem "localeapp", "~> 3.3", require: false
gem "uglifier", "~> 4.2.0"
gem "web-console", "~> 4.1.0"
end

group :development, :test do
gem 'byebug', '~> 11.0'
gem 'rubocop', '~> 1.6', require: false
gem 'rubocop-rails', '~> 2.9', require: false
gem 'dotenv-rails', '~> 2.7.1'
gem "byebug", "~> 11.0"
gem "dotenv-rails", "~> 2.7.1"
gem "rubocop", "~> 1.6", require: false
gem "rubocop-rails", "~> 2.9", require: false
end

group :test do
gem 'rspec-rails', '~> 4.0.0'
gem 'rails-controller-testing'
gem 'database_cleaner', '~> 1.8.5'
gem 'shoulda-matchers', '~> 4.4'
gem 'fabrication', '~> 2.20'
gem 'faker', '~> 2.15'
gem 'capybara', '~> 3.29'
gem 'selenium-webdriver', '~> 4.1.0'
gem 'webdrivers', '~> 5.3'
gem 'simplecov', '~> 0.22', require: false
gem "capybara", "~> 3.29"
gem "database_cleaner", "~> 1.8.5"
gem "fabrication", "~> 2.20"
gem "faker", "~> 2.15"
gem "rails-controller-testing"
gem "rspec-rails", "~> 4.0.0"
gem "selenium-webdriver", "~> 4.1.0"
gem "shoulda-matchers", "~> 4.4"
gem "simplecov", "~> 0.22", require: false
gem "webdrivers", "~> 5.3"
end
2 changes: 1 addition & 1 deletion Rakefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path("config/application", __dir__)

Rails.application.load_tasks
3 changes: 2 additions & 1 deletion app/admin/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
form do |f|
f.inputs do
f.input :name
f.input :icon_name, hint: "See all available <a href='https://getbootstrap.com/docs/3.3/components/#glyphicons' target='_blank'>icons here</a>".html_safe
f.input :icon_name,
hint: "See all available <a href='https://getbootstrap.com/docs/3.3/components/#glyphicons' target='_blank'>icons here</a>".html_safe
end
f.actions
end
Expand Down
2 changes: 1 addition & 1 deletion app/admin/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ def destroy
filter :updated_at

permit_params :name, :email, :web, :phone, :city, :neighborhood,
:address, :description, :public_opening_times, :logo
:address, :description, :public_opening_times, :logo
end
2 changes: 1 addition & 1 deletion app/admin/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
end

permit_params :type, :tag_list, :title, :category_id, :user_id,
:description, :organization_id, :active, :is_group
:description, :organization_id, :active, :is_group

filter :type, as: :select, collection: -> { Post.subclasses }
filter :id
Expand Down
2 changes: 1 addition & 1 deletion app/admin/transfer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ActiveAdmin.register Transfer do
includes :post, movements: { account: [:accountable, :organization] }
includes :post, movements: { account: %i[accountable organization] }

actions :index, :destroy

Expand Down
2 changes: 1 addition & 1 deletion app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@
end

permit_params :username, :email, :phone, :postcode, :gender, :locale,
members_attributes: [:id, :organization_id, :active, :manager, :_destroy]
members_attributes: %i[id organization_id active manager _destroy]
end
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ def set_locale

def user_not_authorized
flash[:error] = "You are not authorized to perform this action."
redirect_to(request.referrer || root_path)
redirect_to(request.referer || root_path)
end

def resource_not_found
render 'errors/not_found', status: 404
render "errors/not_found", status: :not_found
end

def member_should_exist_and_be_active
if !current_member
redirect_to organizations_path
elsif !current_member.active
flash[:error] = I18n.t('users.index.account_deactivated')
flash[:error] = I18n.t("users.index.account_deactivated")
redirect_to select_organization_path
end
end
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/concerns/with_transfer_params.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module WithTransferParams
def transfer_params
permitted_transfer_params = [
:destination,
:amount,
:reason,
:post_id,
permitted_transfer_params = %i[
destination
amount
reason
post_id
]

permitted_transfer_params.push(:source) if admin?
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class ErrorsController < ApplicationController
def not_found
render status: 404
render status: :not_found
end

def internal_server_error
render status: 500
render status: :internal_server_error
end
end
15 changes: 7 additions & 8 deletions app/controllers/multi_transfers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class MultiTransfersController < ApplicationController
include WithTransferParams

STEPS = [
'select_type',
'select_source',
'select_target',
'set_params',
'confirm'
STEPS = %w[
select_type
select_source
select_target
set_params
confirm
]

def step
Expand Down Expand Up @@ -60,11 +60,10 @@ def prepare_template_vars
@target_accountable = Account.find(@to.first).accountable
end

@should_render_offer_selector = (
@should_render_offer_selector =
@type_of_transfer.to_sym == :many_to_one &&
@target_accountable &&
@target_accountable.offers.length > 0
)

@from_names = Account.find(@from).map(&:accountable).map(&:to_s)
@to_names = Account.find(@to).map(&:accountable).map(&:to_s)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class OrganizationsController < ApplicationController
before_action :load_resource, only: [:show, :edit, :update, :set_current]
before_action :load_resource, only: %i[show edit update set_current]
before_action :user_should_be_confirmed

def index
Expand Down
8 changes: 3 additions & 5 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
class PagesController < ApplicationController
def show
begin
render template: "pages/#{params[:page]}"
rescue ActionView::MissingTemplate
render "errors/not_found", status: 404
end
render template: "pages/#{params[:page]}"
rescue ActionView::MissingTemplate
render "errors/not_found", status: :not_found
end
end
15 changes: 8 additions & 7 deletions app/controllers/petitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def create
OrganizationNotifier.new_petition(petition).deliver_now
OrganizationNotifier.petition_sent(petition).deliver_now

flash[:notice] = t('petitions.application_status', status: t("petitions.status.sent"))
flash[:notice] = t("petitions.application_status", status: t("petitions.status.sent"))
else
flash[:error] = t('errors.internal_server_error.description')
flash[:error] = t("errors.internal_server_error.description")
end

redirect_back fallback_location: organization_path(petition.organization)
Expand All @@ -22,18 +22,19 @@ def update
status = params[:status]

if petition.update(status: status)
petition.user.add_to_organization(petition.organization) if status == 'accepted'
flash[:notice] = t('petitions.application_status', status: t("petitions.status.#{status}"))
petition.user.add_to_organization(petition.organization) if status == "accepted"
flash[:notice] = t("petitions.application_status", status: t("petitions.status.#{status}"))
else
flash[:error] = t('errors.internal_server_error.description')
flash[:error] = t("errors.internal_server_error.description")
end

redirect_to manage_petitions_path
end

def manage
@status = params[:status] || 'pending'
@users = User.joins(:petitions).where(petitions: { organization_id: current_organization.id, status: @status }).page(params[:page]).per(20)
@status = params[:status] || "pending"
@users = User.joins(:petitions).where(petitions: { organization_id: current_organization.id,
status: @status }).page(params[:page]).per(20)
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class PostsController < ApplicationController
class PostsController < ApplicationController
has_scope :by_category, as: :cat
has_scope :tagged_with, as: :tag
has_scope :by_organization, as: :org
Expand Down Expand Up @@ -94,7 +94,7 @@ def set_user_id(p)

def post_params
permitted_fields = [:description, :end_on, :start_on, :title, :category_id,
:user_id, :is_group, :active, tag_list: []]
:user_id, :is_group, :active, { tag_list: [] }]

params.fetch(resource, {}).permit(*permitted_fields).tap do |p|
set_user_id(p)
Expand Down
28 changes: 14 additions & 14 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'zip'
require "zip"

class ReportsController < ApplicationController
before_action :authenticate_user!
Expand All @@ -8,20 +8,20 @@ class ReportsController < ApplicationController
def user_list
@members = report_collection("Member")

report_responder('Member', current_organization, @members)
report_responder("Member", current_organization, @members)
end

def post_list
@post_type = (params[:type] || "offer").capitalize.constantize
@posts = report_collection(@post_type)

report_responder('Post', current_organization, @posts, @post_type)
report_responder("Post", current_organization, @posts, @post_type)
end

def transfer_list
@transfers = report_collection('Transfer')
@transfers = report_collection("Transfer")

report_responder('Transfer', current_organization, @transfers)
report_responder("Transfer", current_organization, @transfers)
end

def download_all
Expand All @@ -35,7 +35,7 @@ def download_all
end
end
zip_data = File.read(temp_file.path)
send_data(zip_data, type: 'application/zip', disposition: 'attachment', filename: filename)
send_data(zip_data, type: "application/zip", disposition: "attachment", filename: filename)
rescue Errno::ENOENT
redirect_to download_all_report_path
ensure
Expand Down Expand Up @@ -65,11 +65,11 @@ def get_report(report_class, *args)

def report_collection(report_class)
case report_class.to_s
when 'Member'
current_organization.members.active.includes(:user).order('members.member_uid')
when 'Transfer'
when "Member"
current_organization.members.active.includes(:user).order("members.member_uid")
when "Transfer"
current_organization.all_transfers_with_accounts
when 'Inquiry', 'Offer'
when "Inquiry", "Offer"
report_class = report_class.constantize if report_class.is_a?(String)

current_organization.posts.of_active_members.active.
Expand All @@ -84,10 +84,10 @@ def add_csv_to_zip(report_class, zip)
collection = report_collection(report_class)

report = if report_class.in? %w(Inquiry Offer)
get_report("Csv::Post", current_organization, collection, report_class.constantize)
else
get_report("Csv::#{report_class}", current_organization, collection)
end
get_report("Csv::Post", current_organization, collection, report_class.constantize)
else
get_report("Csv::#{report_class}", current_organization, collection)
end

file = Tempfile.new
file.write(report.run)
Expand Down
Loading

0 comments on commit aff13d4

Please sign in to comment.