Skip to content

Commit

Permalink
Fix: rubocop offences
Browse files Browse the repository at this point in the history
  • Loading branch information
dalpo committed Oct 25, 2018
1 parent de8634d commit 3e4c35e
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 34 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
# versions of RuboCop, may require this file to be generated again.

AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.4

Exclude:
- bin/*

# Offense count: 97
# Cop supports --auto-correct.
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ end
group :development, :test do
gem 'byebug'
gem 'pry'
gem 'rubocop', '~> 0.51.0', require: false
gem 'rubocop', '~> 0.51', require: false
gem 'test-unit', '~> 3.0'
end
27 changes: 14 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ GEM
fog-core
mime-types (>= 2.99)
unf
ast (2.3.0)
ast (2.4.0)
autoprefixer-rails (7.2.0)
execjs
better_errors (2.4.0)
Expand Down Expand Up @@ -125,6 +125,7 @@ GEM
i18n (1.1.1)
concurrent-ruby (~> 1.0)
ipaddress (0.8.3)
jaro_winkler (1.5.1)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand Down Expand Up @@ -210,11 +211,11 @@ GEM
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
parallel (1.12.0)
parser (2.4.0.2)
ast (~> 2.3)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
power_assert (1.1.1)
powerpack (0.1.1)
powerpack (0.1.2)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand Down Expand Up @@ -251,21 +252,21 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rainbow (3.0.0)
rake (12.3.1)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rdiscount (2.2.0.1)
rubocop (0.51.0)
rubocop (0.59.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 3.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
ruby-progressbar (1.10.0)
sass (3.5.3)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
Expand Down Expand Up @@ -321,7 +322,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)
unicode-display_width (1.3.0)
unicode-display_width (1.4.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
Expand Down Expand Up @@ -362,7 +363,7 @@ DEPENDENCIES
rails (~> 5.1.6)
rails_12factor
rdiscount
rubocop (~> 0.51.0)
rubocop (~> 0.51)
sass-rails (>= 3.2)
simplecov
sprockets (>= 3.7.2)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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__)
require 'rake'

TomatoesApp::Application.load_tasks
1 change: 1 addition & 0 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BaseController < ActionController::Base

def current_user
return unless auth_token

@current_user ||= User.find_by_token(auth_token)
end

Expand Down
5 changes: 4 additions & 1 deletion app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ def new_tomato
@tomato = current_user.tomatoes.build
end

# rubocop:disable Naming/MemoizedInstanceVariableName
def daily_tomatoes
@tomatoes ||= current_user.tomatoes.after(Time.zone.now.beginning_of_day).order_by([%i[created_at desc]])
@tomatoes ||= current_user.tomatoes.after(Time.zone.now.beginning_of_day)
.order_by([%i[created_at desc]])
end
# rubocop:enable Naming/MemoizedInstanceVariableName

def tomatoes_counters
@tomatoes_count = current_user.tomatoes_counters
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def humanize(secs)
[1000, :year]
].map do |divider, name|
next unless secs.positive?

secs, n = secs.divmod(divider)
if n.to_i.positive?
I18n.t("helpers.precise_distance_of_time_in_words.#{name}", count: n.to_i)
end

I18n.t("helpers.precise_distance_of_time_in_words.#{name}", count: n.to_i) if n.to_i.positive?
end.compact.reverse.join(', ')
end

Expand Down
1 change: 1 addition & 0 deletions app/models/tomato.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def projects
def must_not_overlap
last_tomato = user.tomatoes.after(Time.zone.now - DURATION.seconds).order_by([%i[created_at desc]]).first
return unless last_tomato

limit = (DURATION.seconds - (Time.zone.now - last_tomato.created_at)).seconds
errors.add(:base, I18n.t('errors.messages.must_not_overlap', limit: humanize(limit)))
end
Expand Down
6 changes: 3 additions & 3 deletions bin/yarn
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
begin
exec "yarnpkg", *ARGV
exec 'yarnpkg', *ARGV
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
warn 'Yarn executable was not detected in the system.'
warn 'Download Yarn at https://yarnpkg.com/en/docs/install'
exit 1
end
end
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path('../boot', __FILE__)
require File.expand_path('boot', __dir__)

require 'action_controller/railtie'
require 'action_mailer/railtie'
Expand Down
6 changes: 3 additions & 3 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# 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
Expand Down
4 changes: 2 additions & 2 deletions script/rails
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require File.expand_path('../config/boot', __dir__)
require 'rails/commands'
8 changes: 4 additions & 4 deletions test/functional/api/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ def rome_tz
ActiveSupport::TimeZone['Europe/Rome']
end

def morning_in(tz)
tz.now.change(hour: 10)
def morning_in(timezone)
timezone.now.change(hour: 10)
end

def night_in(tz)
tz.now.change(hour: 22)
def night_in(timezone)
timezone.now.change(hour: 22)
end

def setup_tz_test
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ENV['RAILS_ENV'] = 'test'

require 'simplecov'
require File.expand_path('../../config/environment', __FILE__)
require File.expand_path('../config/environment', __dir__)
require 'rails/test_help'
require 'mocha/mini_test'
require 'sucker_punch/testing/inline'
Expand Down

0 comments on commit 3e4c35e

Please sign in to comment.