Skip to content

Commit 5fb74b8

Browse files
authored
Merge pull request #307 from plural/fix-lint-errors-aug-2024
Update rubocop settings and fix all open rubocop errors.
2 parents 50b0ee5 + 2234c28 commit 5fb74b8

File tree

78 files changed

+314
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+314
-179
lines changed

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ require:
66

77
Metrics/AbcSize:
88
Enabled: false
9+
Metrics/BlockLength:
10+
Enabled: false
911
Metrics/CyclomaticComplexity:
1012
Enabled: false
1113
Metrics/MethodLength:

Gemfile

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
source "https://rubygems.org"
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
24
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
35

4-
ruby "~> 3.1"
6+
ruby '~> 3.1'
57

68
# Gems that have trouble with native packages on alpine.
79
gem 'google-protobuf', force_ruby_platform: true
810
gem 'nokogiri', force_ruby_platform: true
911

1012
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
11-
gem "rails", ">= 7.0.7.1"
13+
gem 'rails', '>= 7.0.7.1'
1214

1315
# Use postgresql as the database for Active Record
14-
gem "pg", "~> 1.1"
16+
gem 'pg', '~> 1.1'
1517

1618
# Use the Puma web server [https://github.com/puma/puma]
17-
gem "puma", "~> 5.6"
19+
gem 'puma', '~> 5.6'
1820

19-
gem "parslet"
21+
gem 'parslet'
2022

2123
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
2224
# gem "jbuilder"
@@ -31,54 +33,52 @@ gem "parslet"
3133
# gem "bcrypt", "~> 3.1.7"
3234

3335
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
34-
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
36+
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
3537

3638
# Reduces boot times through caching; required in config/boot.rb
37-
gem "bootsnap", require: false
39+
gem 'bootsnap', require: false
3840

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

4244
gem 'rack', '~> 2.2'
4345
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
44-
gem "rack-cors", '2.0.0'
46+
gem 'rack-cors', '2.0.0'
4547

4648
# Used for our import of the card data.
47-
gem "activerecord-import"
49+
gem 'activerecord-import'
4850

4951
# Base for our JSON API.
5052
gem 'graphiti', '~> 1.2'
5153
gem 'graphiti-rails', '~> 0.2'
5254
gem 'kaminari', '~> 1.0'
53-
gem 'responders'
5455
gem 'ostruct'
55-
group :development, :test do
56-
gem 'graphiti_spec_helpers'
57-
end
56+
gem 'responders'
5857

5958
# Views
6059
gem 'scenic'
6160

62-
gem "sprockets-rails"
63-
gem 'rspec_api_documentation'
64-
gem "apitome"
61+
gem 'apitome'
6562
gem 'jwt'
63+
gem 'rspec_api_documentation'
64+
gem 'sprockets-rails'
6665

6766
# Observability and monitoring via OpenTelemetry.
68-
gem 'opentelemetry-sdk'
6967
gem 'opentelemetry-exporter-otlp'
7068
gem 'opentelemetry-instrumentation-all'
69+
gem 'opentelemetry-sdk'
7170

7271
# for review imports from NRDBc
7372
gem 'reverse_markdown'
7473

7574
group :development, :test do
76-
gem "brakeman", "~> 5.2"
77-
gem "bundler-audit", "~> 0.9.0"
75+
gem 'brakeman', '~> 5.2'
76+
gem 'bundler-audit', '~> 0.9.0'
7877
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
79-
gem "debug", platforms: %i[ mri mingw x64_mingw ]
78+
gem 'debug', platforms: %i[mri mingw x64_mingw]
8079
gem 'factory_bot_rails'
8180
gem 'faker'
81+
gem 'graphiti_spec_helpers'
8282
gem 'rspec-rails'
8383
gem 'rubocop'
8484
gem 'rubocop-factory_bot'

Rakefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# frozen_string_literal: true
2+
13
# Add your own tasks in files placed in lib/tasks ending in .rake,
24
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
35

4-
require_relative "config/application"
6+
require_relative 'config/application'
57

68
Rails.application.load_tasks

app/models/card_pool.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def num_cards
1818
cards.size
1919
end
2020

21-
validates :name, uniqueness: true
21+
# TODO(plural): Add an index for this uniqueness constraint.
22+
validates :name, uniqueness: true # rubocop:disable Rails/UniqueValidationWithoutIndex
2223

2324
scope :by_printing_ids, lambda { |printing_ids|
2425
joins(:card_pool_cards).joins(:printings).where(unified_printings: { id: printing_ids }).distinct

app/models/deck.rb

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ def num_cards
3232
.reject { |c| c.card_id == identity_card_id }
3333
.map(&:quantity).sum
3434
end
35-
3635
end

app/models/decklist.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Decklist < ApplicationRecord
77
# TODO(plural): Add a relationship to a public user object.
88
belongs_to :side
99

10-
has_one :identity_card,
10+
has_one :identity_card, # rubocop:disable Rails/InverseOf
1111
class_name: 'Card',
1212
foreign_key: 'id',
1313
primary_key: 'identity_card_id'

app/models/format.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ def active_restriction_id
2525
s.restriction_id
2626
end
2727

28-
validates :name, uniqueness: true
28+
# TODO(plural): Add an index for this uniqueness constraint.
29+
validates :name, uniqueness: true # rubocop:disable Rails/UniqueValidationWithoutIndex
2930
end

app/models/raw_printing.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ class RawPrinting < ApplicationRecord
1919
has_many :illustrators, through: :illustrator_printings
2020

2121
has_many :unified_restrictions, inverse_of: :resriction, primary_key: :card_id, foreign_key: :card_id
22-
has_many :card_pool_cards, primary_key: :card_id, foreign_key: :card_id
22+
has_many :card_pool_cards, primary_key: :card_id, foreign_key: :card_id # rubocop:disable Rails/InverseOf
2323
has_many :card_pools, through: :card_pool_cards
2424
end

app/models/restriction.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class Restriction < ApplicationRecord
2424
has_one :restriction_card_subtype_banned
2525
has_many :banned_subtypes, through: :restriction_card_subtype_banned, source: :card_subtype
2626

27-
validates :name, uniqueness: true
27+
# TODO(plural): Add an index for this uniqueness constraint.
28+
validates :name, uniqueness: true # rubocop:disable Rails/UniqueValidationWithoutIndex
2829

2930
# TODO(plural): Make date_start a proper date type.
3031

app/models/review.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
# Model for reviews of cards.
14
class Review < ApplicationRecord
25
belongs_to :card
36
has_many :review_comments

app/models/review_comment.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
# Model for comments on reviews.
14
class ReviewComment < ApplicationRecord
25
belongs_to :review
36
end

app/models/review_vote.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
# Model for votes on reviews.
14
class ReviewVote < ApplicationRecord
25
belongs_to :review
36
end

config.ru

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# frozen_string_literal: true
2+
13
# This file is used by Rack-based servers to start the application.
24

3-
require_relative "config/environment"
5+
require_relative 'config/environment'
46

57
run Rails.application
68
Rails.application.load_server

config/application.rb

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
require_relative "boot"
1+
# frozen_string_literal: true
22

3-
require "rails/all"
3+
require_relative 'boot'
44

5-
require "sprockets/railtie"
5+
require 'rails/all'
6+
7+
require 'sprockets/railtie'
68

79
# TODO(plural): See if there is a different solution here.
810
# Requied by Graphiti but not included in their for top-level Gem for some reason.
@@ -13,7 +15,7 @@
1315
Bundler.require(*Rails.groups)
1416

1517
module NrdbApi
16-
class Application < Rails::Application
18+
class Application < Rails::Application # rubocop:disable Style/Documentation
1719
routes.default_url_options[:host] = ENV.fetch('HOST', 'http://localhost:3000')
1820

1921
# Initialize configuration defaults for originally generated Rails version.
@@ -25,7 +27,7 @@ class Application < Rails::Application
2527
# in config/environments, which are processed later.
2628
#
2729
# config.time_zone = "Central Time (US & Canada)"
28-
config.eager_load_paths << Rails.root.join("lib")
30+
config.eager_load_paths << Rails.root.join('lib')
2931

3032
# Only loads a smaller set of middleware suitable for API only apps.
3133
# Middleware like session, flash, cookies can be added back manually.

config/boot.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1+
# frozen_string_literal: true
22

3-
require "bundler/setup" # Set up gems listed in the Gemfile.
4-
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
3+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
4+
5+
require 'bundler/setup' # Set up gems listed in the Gemfile.
6+
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.

config/environment.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# frozen_string_literal: true
2+
13
# Load the Rails application.
2-
require_relative "application"
4+
require_relative 'application'
35

46
# Initialize the Rails application.
57
Rails.application.initialize!

config/environments/development.rb

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
require "active_support/core_ext/integer/time"
1+
# frozen_string_literal: true
2+
3+
require 'active_support/core_ext/integer/time'
24

35
Rails.application.configure do
46
# Settings specified here will take precedence over those in config/application.rb.
@@ -18,10 +20,10 @@
1820

1921
# Enable/disable caching. By default caching is disabled.
2022
# Run rails dev:cache to toggle caching.
21-
if Rails.root.join("tmp/caching-dev.txt").exist?
23+
if Rails.root.join('tmp/caching-dev.txt').exist?
2224
config.cache_store = :memory_store
2325
config.public_file_server.headers = {
24-
"Cache-Control" => "public, max-age=#{2.days.to_i}"
26+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
2527
}
2628
else
2729
config.action_controller.perform_caching = false
@@ -52,7 +54,6 @@
5254
# Highlight code that triggered database queries in logs.
5355
config.active_record.verbose_query_logs = true
5456

55-
5657
# Raises error for missing translations.
5758
# config.i18n.raise_on_missing_translations = true
5859

@@ -61,6 +62,6 @@
6162

6263
# Uncomment if you wish to allow Action Cable access from any origin.
6364
# config.action_cable.disable_request_forgery_protection = true
64-
config.hosts << "api-preview.netrunnerdb.com"
65-
config.hosts << "nrdb_api_server"
65+
config.hosts << 'api-preview.netrunnerdb.com'
66+
config.hosts << 'nrdb_api_server'
6667
end

config/environments/production.rb

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
require "active_support/core_ext/integer/time"
1+
# frozen_string_literal: true
2+
3+
require 'active_support/core_ext/integer/time'
24

35
Rails.application.configure do
46
# Settings specified here will take precedence over those in config/application.rb.
@@ -13,7 +15,7 @@
1315
config.eager_load = true
1416

1517
# Full error reports are disabled and caching is turned on.
16-
config.consider_all_requests_local = false
18+
config.consider_all_requests_local = false
1719

1820
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
1921
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
@@ -46,7 +48,7 @@
4648
config.log_level = :info
4749

4850
# Prepend all log lines with the following tags.
49-
config.log_tags = [ :request_id ]
51+
config.log_tags = [:request_id]
5052

5153
# Use a different cache store in production.
5254
# config.cache_store = :mem_cache_store
@@ -75,8 +77,8 @@
7577
# require "syslog/logger"
7678
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
7779

78-
if ENV["RAILS_LOG_TO_STDOUT"].present?
79-
logger = ActiveSupport::Logger.new(STDOUT)
80+
if ENV['RAILS_LOG_TO_STDOUT'].present?
81+
logger = ActiveSupport::Logger.new($stdout)
8082
logger.formatter = config.log_formatter
8183
config.logger = ActiveSupport::TaggedLogging.new(logger)
8284
end

config/environments/test.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
require "active_support/core_ext/integer/time"
1+
# frozen_string_literal: true
2+
3+
require 'active_support/core_ext/integer/time'
24

35
# The test environment is used exclusively to run your application's
46
# test suite. You never need to work with it otherwise. Remember that
@@ -19,7 +21,7 @@
1921
# Configure public file server for tests with Cache-Control for performance.
2022
config.public_file_server.enabled = true
2123
config.public_file_server.headers = {
22-
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
24+
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
2325
}
2426

2527
# Show full error reports and disable caching.

0 commit comments

Comments
 (0)