From 98db9147e7607a70fe70a6010bbabd5f44fd4cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Maniaci?= Date: Sat, 16 Jan 2021 12:50:51 +0000 Subject: [PATCH] fix: linting --- Gemfile | 4 ++-- Guardfile | 2 +- app/controllers/themes_controller.rb | 4 +--- config/environments/production.rb | 2 +- config/environments/staging.rb | 2 +- config/puma.rb | 6 +++--- lib/logging.rb | 8 +++----- lib/tasks/themes.rake | 4 ++-- spec/models/theme_spec.rb | 2 +- 9 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index 1bd3e69..b177490 100644 --- a/Gemfile +++ b/Gemfile @@ -24,12 +24,12 @@ gem 'jbuilder', '~> 2.5' # gem 'bcrypt', '~> 3.1.7' gem 'aws-sdk-s3', require: false +gem 'concurrent-ruby' gem 'faker' gem 'haml-rails' gem 'image_processing' gem 'sentry-raven' gem 'therubyracer' -gem 'concurrent-ruby' group :production do gem 'bcrypt_pbkdf' @@ -64,4 +64,4 @@ group :development do gem 'web-console' end -gem "tailwindcss-rails", "~> 0.1.0" +gem 'tailwindcss-rails', '~> 0.1.0' diff --git a/Guardfile b/Guardfile index 386167c..5b30714 100644 --- a/Guardfile +++ b/Guardfile @@ -17,7 +17,7 @@ # # and, you'll have to watch "config/Guardfile" instead of "Guardfile" -# Note: The cmd option is now required due to the increasing number of ways +# NOTE: The cmd option is now required due to the increasing number of ways # rspec may be run, below are examples of the most common uses. # * bundler: 'bundle exec rspec' # * bundler binstubs: 'bin/rspec' diff --git a/app/controllers/themes_controller.rb b/app/controllers/themes_controller.rb index fb74fc3..278eca7 100644 --- a/app/controllers/themes_controller.rb +++ b/app/controllers/themes_controller.rb @@ -31,9 +31,7 @@ def index end end - if offset + PAGE_SIZE < @count - @next = themes_path(page: @page + 1) - end + @next = themes_path(page: @page + 1) unless offset + PAGE_SIZE >= @count @themes = Theme .perfect diff --git a/config/environments/production.rb b/config/environments/production.rb index 2289af1..3d557f1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -85,7 +85,7 @@ ) 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 diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 24f021d..fb73ecb 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -85,7 +85,7 @@ ) 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 diff --git a/config/puma.rb b/config/puma.rb index 940c8ba..d9a94f3 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -6,16 +6,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 diff --git a/lib/logging.rb b/lib/logging.rb index cc6a223..679cb9a 100644 --- a/lib/logging.rb +++ b/lib/logging.rb @@ -4,16 +4,14 @@ module PeachMelpa module Log - @logger = ::Logger.new(STDOUT) + @logger = ::Logger.new($stdout) - def self.info(name = '') + def self.info(name = '', &block) return if ENV['RAILS_ENV'] == 'test' raise 'cannot call logger without block' unless block_given? - @logger.info(name) do - yield - end + @logger.info(name, &block) end end end diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake index f7dbd6f..9995f57 100644 --- a/lib/tasks/themes.rake +++ b/lib/tasks/themes.rake @@ -7,9 +7,9 @@ require "#{Rails.root}/lib/critic" require "#{Rails.root}/lib/retrieval" require "#{Rails.root}/lib/parsing" -namespace :themes do - SCREENSHOT_FOLDER = "#{Rails.root}/tmp/screenshots/" +SCREENSHOT_FOLDER = "#{Rails.root}/tmp/screenshots/" +namespace :themes do desc 'grabs MELPA archives.json and put it in tmp' task refresh: :environment do PeachMelpa::Retrieval.refresh_melpa_archive diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb index 009ff67..2395c55 100644 --- a/spec/models/theme_spec.rb +++ b/spec/models/theme_spec.rb @@ -165,7 +165,7 @@ end describe '.capture_artifacts!' do - let(:folder_path) { PeachMelpa::Parsing::SCREENSHOT_FOLDER + 'foo-theme' } + let(:folder_path) { "#{PeachMelpa::Parsing::SCREENSHOT_FOLDER}foo-theme" } before do allow(variant).to receive(:parse!)