Skip to content

Commit

Permalink
Fix rubocop offenses
Browse files Browse the repository at this point in the history
Fixes a bunch of rubocop offenses. Sets up rubocop
  • Loading branch information
jsperezg committed Mar 11, 2024
1 parent 410d0df commit 425bf25
Show file tree
Hide file tree
Showing 42 changed files with 216 additions and 252 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml

require: rubocop-rspec

AllCops:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM ruby:2.4.4
FROM ruby:2.6.10

# Required packages
RUN apt-get update -qq && \
apt-get upgrade -y && \
apt-get install -y build-essential mysql-client default-libmysqlclient-dev imagemagick nodejs libmagickwand-dev sudo unzip vim apt-utils && \
apt-get install -y build-essential default-mysql-client default-libmysqlclient-dev imagemagick nodejs libmagickwand-dev sudo unzip vim apt-utils && \
apt-get clean

# Test requirements
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ ruby '2.6.10'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.5.4'
gem 'mysql2', '~> 0.5.5'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 5.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
gem 'mini_racer', '~> 0.6.4'

# Reduces boot times through caching; configured in config/boot.rb
gem 'bootsnap', '~> 1.4.8', platforms: [:mri]
Expand Down Expand Up @@ -80,7 +80,7 @@ group :development do
gem 'capistrano-passenger'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rbenv', '~> 2.0'

gem 'listen'
gem 'rubocop'
gem 'rubocop-rspec'

Expand Down
20 changes: 11 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ GEM
actionpack (>= 4)
less (~> 2.6.0)
sprockets (>= 2)
libv8 (3.16.14.19)
libv8-node (16.19.0.1)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.7.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -204,12 +207,14 @@ GEM
rake
mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.6.4)
libv8-node (~> 16.19.0.0)
minitest (5.14.2)
msgpack (1.3.3)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
mysql2 (0.5.4)
mysql2 (0.5.5)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
Expand Down Expand Up @@ -299,7 +304,6 @@ GEM
virtus (~> 1.0.5)
wisper (>= 1.6.1)
redis (4.2.1)
ref (2.0.0)
regexp_parser (1.7.1)
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
Expand Down Expand Up @@ -386,9 +390,6 @@ GEM
net-ssh (>= 2.8.0)
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
Expand Down Expand Up @@ -466,8 +467,10 @@ DEPENDENCIES
jquery-turbolinks
jquery-ui-rails
knockoutjs-rails
listen
mimemagic (~> 0.3.10)
mysql2 (~> 0.5.4)
mini_racer (~> 0.6.4)
mysql2 (~> 0.5.5)
nprogress-rails
omniauth-google-oauth2
paperclip (~> 6.1.0)
Expand All @@ -490,7 +493,6 @@ DEPENDENCIES
simplecov
smarter_csv
spring
therubyracer
turbolinks (~> 5.0.0)
twitter-bootstrap-rails
uglifier (>= 1.3.0)
Expand All @@ -502,4 +504,4 @@ RUBY VERSION
ruby 2.6.10p210

BUNDLED WITH
1.17.3
2.4.6
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def extract_locale_from_headers

def configure_permitted_parameters
devise_parameter_sanitizer.permit(
:account_update,
:account_update,
keys: %i[password password_confirmation current_password
tax_id name address city country state postal_code
phone_number locale currency logo]
tax_id name address city country state postal_code
phone_number locale currency logo]
)

devise_parameter_sanitizer.permit(
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/delivery_notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def invoice
invoice.save!

redirect_to edit_user_invoice_path(current_user, invoice)
rescue StandardError => error
flash[:alert] = t(error.message, default: error.message)
rescue StandardError => e
flash[:alert] = t(e.message, default: e.message)
redirect_to user_delivery_notes_path(current_user)
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/estimates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def invoice
invoice.save!

redirect_to edit_user_invoice_path(current_user, invoice)
rescue StandardError => error
flash[:alert] = t(error.message)
rescue StandardError => e
flash[:alert] = t(e.message)
redirect_to user_estimates_path(current_user)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
end
7 changes: 6 additions & 1 deletion app/pdfs/delivery_note_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ def footer_totals

totals << [
header_cell("#{DeliveryNote.human_attribute_name :total}:", default_borders, default_padding, :right),
data_cell("#{number_with_precision @delivery_note.total, precision: 2} #{currency_symbol(@current_user)}", default_borders, default_padding, :right)
data_cell(
"#{number_with_precision @delivery_note.total, precision: 2} #{currency_symbol(@current_user)}",
default_borders,
default_padding,
:right
)
]

font DEFAULT_FONT, style: :normal
Expand Down
2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path('config/environment', __dir__)
run Rails.application
1 change: 0 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local


# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
Expand Down
9 changes: 4 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]


# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
config.force_ssl = ENV['INSITU_FORCE_SSL'].present?

# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :warn

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand Down Expand Up @@ -87,9 +86,9 @@
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
if ENV['RAILS_LOG_TO_STDOUT'].present?
config.action_mailer.perform_deliveries = true
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# Paypal integration
config.x.paypal_validate_ipn_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate'
config.x.paypal_validate_ipn_verify_mode = OpenSSL::SSL::VERIFY_NONE
config.x.paypal_validate_ipn_user_agent = ENV['PAYPAL_USER_AGENT']
config.x.paypal_validate_ipn_user_agent = ENV['PAYPAL_USER_AGENT']
config.x.paypal_receiver_email = ENV['PAYPAL_RECEIVER_EMAIL']
config.x.paypal_billing_account = ENV['PAYPAL_BILLING_ACCOUNT']
end
2 changes: 2 additions & 0 deletions config/initializers/cookies_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Specify a serializer for the signed and encrypted cookie jars.
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Configure sensitive parameters which will be filtered from the log file.
Expand Down
8 changes: 5 additions & 3 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# frozen_string_literal: true

# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# 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 }.to_i
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
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
Expand Down
4 changes: 2 additions & 2 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
:concurrency: 8
:pidfile: /opt/insitu/current/tmp/pids/sidekiq.pid
:logfile: /opt/insitu/current/log/sidekiq.log
:pidfile: /insitu/tmp/pids/sidekiq.pid
:logfile: /insitu/log/sidekiq.log
:queues:
- default
- mailers
Expand Down
6 changes: 4 additions & 2 deletions config/spring.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
%w(
# frozen_string_literal: true

%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }
].each { |path| Spring.watch(path) }
17 changes: 8 additions & 9 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
Role.find_or_create_by(description: role)
end

admin = User.find_by(email: '[email protected]')
admin ||= User.create(
email: '[email protected]',
password: 'change_me',
password_confirmation: 'change_me',
confirmed_at: Time.now,
terms_of_service: '1',
role: Role.admin
)
User.find_or_create_by(email: '[email protected]') do |admin|
admin.email = '[email protected]'
admin.password = 'change_me'
admin.password_confirmation = 'change_me'
admin.confirmed_at = Time.now
admin.terms_of_service = '1'
admin.role = Role.admin
end
else
init_default_settings

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/api/v1/projects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
describe 'GET #show' do
it 'assigns the requested project as @project' do
project = Project.create! valid_attributes
get :show, params: {id: project.to_param }, format: :json
get :show, params: { id: project.to_param }, format: :json
expect(assigns(:project)).to eq(project)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
description { 'User' }
end

factory :admin_role, class: Role do
factory :admin_role, class: 'Role' do
description { 'Administrator' }
end
end
2 changes: 1 addition & 1 deletion spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

FactoryBot.define do
factory :user, class: User do
factory :user, class: 'User' do
name { "#{Faker::Name.first_name} #{Faker::Name.last_name}" }
tax_id { Faker::Company.swedish_organisation_number }
address { Faker::Address.street_address }
Expand Down
17 changes: 0 additions & 17 deletions spec/helpers/customers_helper_spec.rb

This file was deleted.

17 changes: 0 additions & 17 deletions spec/helpers/ipn_listener_helper_spec.rb

This file was deleted.

17 changes: 0 additions & 17 deletions spec/helpers/services_helper_spec.rb

This file was deleted.

Loading

0 comments on commit 425bf25

Please sign in to comment.