From efa9d065e355a8d4f6402b2ab7c2cc438ae27f03 Mon Sep 17 00:00:00 2001 From: Neetpone <132411956+Neetpone@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:56:47 -0400 Subject: [PATCH] style: rubocop --- .rubocop.yml | 6 ++++- app/controllers/images_controller.rb | 3 +-- app/controllers/search_controller.rb | 4 +-- app/models/visit_count.rb | 1 + bin/bundle | 2 +- config/application.rb | 31 +++++++++++++---------- test/controllers/blogs_controller_test.rb | 2 +- test/models/blog_test.rb | 2 +- test/models/visit_count_test.rb | 3 ++- 9 files changed, 32 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f2b31bd..1262bf0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -48,7 +48,7 @@ Style/ClassVars: Style/ClassAndModuleChildren: EnforcedStyle: compact -# This does the oppposite of what I want to do. +# This does the opposite of what I want to do. Layout/HashAlignment: Enabled: false @@ -60,4 +60,8 @@ Style/NumericPredicate: # I've always been an "unnecessary this->" guy myself. Style/RedundantSelf: + Enabled: false + +# Story downloads rely on this. +Rails/RenderInline: Enabled: false \ No newline at end of file diff --git a/app/controllers/images_controller.rb b/app/controllers/images_controller.rb index 4a69ae7..927c7d1 100644 --- a/app/controllers/images_controller.rb +++ b/app/controllers/images_controller.rb @@ -15,8 +15,7 @@ class ImagesController < ApplicationController ext = File.extname(url) hash = Digest::SHA256.hexdigest(url) - path = Rails.root.join('public', 'cached-images', hash + ext) - our_url = "/cached-images/#{hash}#{ext}" + path = Rails.public_path.join('cached-images', hash + ext) content_type = nil if File.exist? path diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index f300595..e72dcf2 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -70,12 +70,12 @@ class SearchController < ApplicationController # returns: [included tags, excluded tags] def parse_tag_queries - tag_searches = "#{@search_params[:tags]},#{@search_params[:characters]}".split(',').reject(&:blank?) + tag_searches = "#{@search_params[:tags]},#{@search_params[:characters]}".split(',').compact_blank [ tag_searches.reject { |t| t[0] == '-' }, tag_searches.select { |t| t[0] == '-' } - .map { |t| t[1..] } + .pluck(1..) ] end diff --git a/app/models/visit_count.rb b/app/models/visit_count.rb index 2b74478..f8d2f3b 100644 --- a/app/models/visit_count.rb +++ b/app/models/visit_count.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: visit_counts diff --git a/bin/bundle b/bin/bundle index d359435..56a4bcf 100755 --- a/bin/bundle +++ b/bin/bundle @@ -41,7 +41,7 @@ m = Module.new do def gemfile gemfile = ENV['BUNDLE_GEMFILE'] - return gemfile if gemfile && !gemfile.empty? + return gemfile if gemfile.present? File.expand_path('../Gemfile', __dir__) end diff --git a/config/application.rb b/config/application.rb index c898f81..2e76147 100644 --- a/config/application.rb +++ b/config/application.rb @@ -26,17 +26,22 @@ Bundler.require(*Rails.groups) # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") -module Foalfetch - class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 +# Configuration for the application, engines, and railties goes here. +# +# These settings can be overridden in specific environments using the files +# in config/environments, which are processed later. +# +# config.time_zone = "Central Time (US & Canada)" +# config.eager_load_paths << Rails.root.join("extras") +class Foalfetch::Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.0 - # Configuration for the application, engines, and railties goes here. - # - # These settings can be overridden in specific environments using the files - # in config/environments, which are processed later. - # - # config.time_zone = "Central Time (US & Canada)" - # config.eager_load_paths << Rails.root.join("extras") - end -end \ No newline at end of file + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") +end diff --git a/test/controllers/blogs_controller_test.rb b/test/controllers/blogs_controller_test.rb index 8095481..be93148 100644 --- a/test/controllers/blogs_controller_test.rb +++ b/test/controllers/blogs_controller_test.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require "test_helper" +require 'test_helper' class BlogsControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/models/blog_test.rb b/test/models/blog_test.rb index a6f5903..01fd885 100644 --- a/test/models/blog_test.rb +++ b/test/models/blog_test.rb @@ -9,7 +9,7 @@ # created_at :datetime not null # updated_at :datetime not null # -require "test_helper" +require 'test_helper' class BlogTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/models/visit_count_test.rb b/test/models/visit_count_test.rb index 34b5888..cb50d13 100644 --- a/test/models/visit_count_test.rb +++ b/test/models/visit_count_test.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # == Schema Information # # Table name: visit_counts @@ -6,7 +7,7 @@ # count :integer default(0), not null # date :date not null # -require "test_helper" +require 'test_helper' class VisitCountTest < ActiveSupport::TestCase # test "the truth" do