Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
source "https://rubygems.org"
source 'https://rubygems.org'

Check notice on line 1 in Gemfile

View check run for this annotation

codefactor.io / CodeFactor

Gemfile#L1

Missing frozen string literal comment. (Style/FrozenStringLiteralComment)

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.1.2"
gem 'rails', '~> 8.1.2'
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
gem "propshaft"
gem 'propshaft'
# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"
gem 'pg', '~> 1.1'
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"
gem 'puma', '>= 5.0'
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
gem 'importmap-rails'
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
gem 'turbo-rails'
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
gem 'stimulus-rails'
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
gem 'jbuilder'
# Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]
gem "tailwindcss-rails"
gem 'tailwindcss-rails'

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]
gem 'tzinfo-data', platforms: %i[ windows jruby ]

Check notice on line 26 in Gemfile

View check run for this annotation

codefactor.io / CodeFactor

Gemfile#L26

Do not use spaces inside percent literal delimiters. (Layout/SpaceInsidePercentLiteralDelimiters)

Check notice on line 26 in Gemfile

View check run for this annotation

codefactor.io / CodeFactor

Gemfile#L26

Do not use spaces inside percent literal delimiters. (Layout/SpaceInsidePercentLiteralDelimiters)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use spaces inside percent literal delimiters.

Suggested change
gem 'tzinfo-data', platforms: %i[ windows jruby ]
gem 'tzinfo-data', platforms: %i[windows jruby]


# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
gem "solid_cache"
gem "solid_queue"
gem "solid_cable"
gem 'solid_cache'
gem 'solid_queue'
gem 'solid_cable'

Check notice on line 31 in Gemfile

View check run for this annotation

codefactor.io / CodeFactor

Gemfile#L31

Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem `solid_cable` should appear before `solid_queue`. (Bundler/OrderedGems)

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
gem 'bootsnap', require: false

# Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
gem "kamal", require: false
gem 'kamal', require: false

# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/]
gem "thruster", require: false
gem 'thruster', require: false

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
gem "image_processing", "~> 1.2"
gem 'image_processing', '~> 1.2'

# Pagination [https://github.com/kaminari/kaminari]
gem "kaminari"
gem 'kaminari'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
gem 'debug', platforms: %i[ mri windows ], require: 'debug/prelude'

Check notice on line 50 in Gemfile

View check run for this annotation

codefactor.io / CodeFactor

Gemfile#L50

Do not use spaces inside percent literal delimiters. (Layout/SpaceInsidePercentLiteralDelimiters)

Check notice on line 50 in Gemfile

View check run for this annotation

codefactor.io / CodeFactor

Gemfile#L50

Do not use spaces inside percent literal delimiters. (Layout/SpaceInsidePercentLiteralDelimiters)

# Audits gems for known security defects (use config/bundler-audit.yml to ignore issues)
gem "bundler-audit", require: false
gem 'bundler-audit', require: false

# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
gem "brakeman", require: false
gem 'brakeman', require: false

# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false
gem 'rubocop-rails-omakase', require: false

# Testing
gem "rspec-rails"
gem "factory_bot_rails"
gem "shoulda-matchers"
gem "simplecov", require: false
gem 'rspec-rails'
gem 'factory_bot_rails'

Check notice on line 63 in Gemfile

View check run for this annotation

codefactor.io / CodeFactor

Gemfile#L63

Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem `factory_bot_rails` should appear before `rspec-rails`. (Bundler/OrderedGems)
gem 'shoulda-matchers'
gem 'simplecov', require: false
end

group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
gem 'web-console'
end
6 changes: 3 additions & 3 deletions app/controllers/contents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def create
result = Contents::Create.new(@creator.id, content_params).call

if result.success?
redirect_to creator_path(@creator), notice: "Content was successfully created."
redirect_to creator_path(@creator), notice: 'Content was successfully created.'
else
@content = @creator.contents.build(content_params)
result.errors.each do |field, messages|
Expand All @@ -25,15 +25,15 @@ def edit

def update
if @content.update(content_params)
redirect_to creator_path(@creator), notice: "Content was successfully updated."
redirect_to creator_path(@creator), notice: 'Content was successfully updated.'
else
render :edit, status: :unprocessable_entity
end
end

def destroy
@content.destroy
redirect_to creator_path(@creator), notice: "Content was successfully deleted."
redirect_to creator_path(@creator), notice: 'Content was successfully deleted.'
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module ApplicationHelper
def sanitize_url(url)
uri = URI.parse(url.to_s)
uri.scheme&.match?(/\Ahttps?\z/i) ? url : "#"
uri.scheme&.match?(/\Ahttps?\z/i) ? url : '#'
rescue URI::InvalidURIError
"#"
'#'
end
end
4 changes: 2 additions & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout "mailer"
default from: 'from@example.com'
layout 'mailer'
end
2 changes: 1 addition & 1 deletion app/models/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Content < ApplicationRecord
validates :title, presence: true
validates :social_media_url, presence: true, format: {
with: /\Ahttps?:\/\/.+\z/i,
message: "must be a valid URL starting with http:// or https://"
message: 'must be a valid URL starting with http:// or https://'
}
validates :social_media_provider, presence: true
validates :social_media_provider, inclusion: { in: social_media_providers.keys }, allow_blank: true
Expand Down
6 changes: 3 additions & 3 deletions app/models/creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class Creator < ApplicationRecord
scope :ordered_by_name, -> { order(:name) }
scope :with_content_count, -> {
left_joins(:contents)
.select("creators.*, COUNT(contents.id) AS content_count")
.group("creators.id")
.select('creators.*, COUNT(contents.id) AS content_count')
.group('creators.id')
}
scope :search_by_name, ->(query) { where("name ILIKE ?", "%#{sanitize_sql_like(query)}%") if query.present? }
scope :search_by_name, ->(query) { where('name ILIKE ?', "%#{sanitize_sql_like(query)}%") if query.present? }
end
2 changes: 1 addition & 1 deletion app/services/contents/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def call
creator = Creator.find_by(id: @creator_id)
return BaseResult.failure({ creator: [ "not found" ] }) unless creator
return BaseResult.failure({ creator: [ 'not found' ] }) unless creator

Check notice on line 10 in app/services/contents/create.rb

View check run for this annotation

codefactor.io / CodeFactor

app/services/contents/create.rb#L10

Do not use space inside array brackets. (Layout/SpaceInsideArrayLiteralBrackets)

Check notice on line 10 in app/services/contents/create.rb

View check run for this annotation

codefactor.io / CodeFactor

app/services/contents/create.rb#L10

Do not use space inside array brackets. (Layout/SpaceInsideArrayLiteralBrackets)

content = creator.contents.build(@params)

Expand Down
24 changes: 12 additions & 12 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require_relative "boot"
require_relative 'boot'

Check notice on line 1 in config/application.rb

View check run for this annotation

codefactor.io / CodeFactor

config/application.rb#L1

Missing frozen string literal comment. (Style/FrozenStringLiteralComment)

require "rails"
require 'rails'
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
require 'active_storage/engine'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_mailbox/engine'
require 'action_text/engine'
require 'action_view/railtie'
require 'action_cable/engine'
# require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
Expand Down
6 changes: 3 additions & 3 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

Check notice on line 1 in config/boot.rb

View check run for this annotation

codefactor.io / CodeFactor

config/boot.rb#L1

Missing frozen string literal comment. (Style/FrozenStringLiteralComment)

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
10 changes: 5 additions & 5 deletions config/ci.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Run using bin/ci

CI.run do
step "Setup", "bin/setup --skip-server"
step 'Setup', 'bin/setup --skip-server'

step "Style: Ruby", "bin/rubocop"
step 'Style: Ruby', 'bin/rubocop'

step "Security: Gem audit", "bin/bundler-audit"
step "Security: Importmap vulnerability audit", "bin/importmap audit"
step "Security: Brakeman code analysis", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
step 'Security: Gem audit', 'bin/bundler-audit'
step 'Security: Importmap vulnerability audit', 'bin/importmap audit'
step 'Security: Brakeman code analysis', 'bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error'


# Optional: set a green GitHub commit status to unblock PR merge.
Expand Down
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the Rails application.
require_relative "application"
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!
8 changes: 4 additions & 4 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "active_support/core_ext/integer/time"
require 'active_support/core_ext/integer/time'

Check notice on line 1 in config/environments/development.rb

View check run for this annotation

codefactor.io / CodeFactor

config/environments/development.rb#L1

Missing frozen string literal comment. (Style/FrozenStringLiteralComment)

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
Expand All @@ -17,10 +17,10 @@

# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
# Run rails dev:cache to toggle Action Controller caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
config.public_file_server.headers = { 'cache-control' => "public, max-age=#{2.days.to_i}" }
else
config.action_controller.perform_caching = false
end
Expand All @@ -38,7 +38,7 @@
config.action_mailer.perform_caching = false

# Set localhost to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
Expand Down
10 changes: 5 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "active_support/core_ext/integer/time"
require 'active_support/core_ext/integer/time'

Check notice on line 1 in config/environments/production.rb

View check run for this annotation

codefactor.io / CodeFactor

config/environments/production.rb#L1

Missing frozen string literal comment. (Style/FrozenStringLiteralComment)

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
Expand All @@ -16,7 +16,7 @@
config.action_controller.perform_caching = true

# Cache assets for far-future expiry since they are all digest stamped.
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
config.public_file_server.headers = { 'cache-control' => "public, max-age=#{1.year.to_i}" }

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com"
Expand All @@ -38,10 +38,10 @@
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)

# Change to "debug" to log everything (including potentially personally-identifiable information!).
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')

# Prevent health checks from clogging up the logs.
config.silence_healthcheck_path = "/up"
config.silence_healthcheck_path = '/up'

# Don't log any deprecations.
config.active_support.report_deprecations = false
Expand All @@ -58,7 +58,7 @@
# config.action_mailer.raise_delivery_errors = false

# Set host to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: "example.com" }
config.action_mailer.default_url_options = { host: 'example.com' }

# Specify outgoing SMTP server. Remember to add smtp/* credentials via bin/rails credentials:edit.
# config.action_mailer.smtp_settings = {
Expand Down
6 changes: 3 additions & 3 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# this is usually not necessary, and can slow down your test suite. However, it's
# recommended that you enable it in continuous integration systems to ensure eager
# loading is working properly before deploying your code.
config.eager_load = ENV["CI"].present?
config.eager_load = ENV['CI'].present?

# Configure public file server for tests with cache-control for performance.
config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
config.public_file_server.headers = { 'cache-control' => 'public, max-age=3600' }

# Show full error reports.
config.consider_all_requests_local = true
Expand All @@ -37,7 +37,7 @@
config.action_mailer.delivery_method = :test

# Set host to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: "example.com" }
config.action_mailer.default_url_options = { host: 'example.com' }

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
Expand Down
10 changes: 5 additions & 5 deletions config/importmap.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Pin npm packages by running ./bin/importmap

pin "application"
pin "@hotwired/turbo-rails", to: "turbo.min.js"
pin "@hotwired/stimulus", to: "stimulus.min.js"
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin 'application'
pin '@hotwired/turbo-rails', to: 'turbo.min.js'
pin '@hotwired/stimulus', to: 'stimulus.min.js'
pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js'
pin_all_from 'app/javascript/controllers', under: 'controllers'
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
8 changes: 4 additions & 4 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
# Any libraries that use a connection pool or another resource pool should
# be configured to provide at least as many connections as the number of
# threads. This includes Active Record's `pool` parameter in `database.yml`.
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
threads_count = ENV.fetch('RAILS_MAX_THREADS', 3)
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)

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart

# Run the Solid Queue supervisor inside of Puma for single-server deployments.
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
plugin :solid_queue if ENV['SOLID_QUEUE_IN_PUMA']

# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
pidfile ENV['PIDFILE'] if ENV['PIDFILE']
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Rails.application.routes.draw do
root "creators#index"
root 'creators#index'

resources :creators, only: [ :index, :show ] do
resources :contents, except: [ :index, :show ]
end

get "up" => "rails/health#show", as: :rails_health_check
get 'up' => 'rails/health#show', as: :rails_health_check
end
Loading
Loading