Skip to content

Commit 1e76df1

Browse files
committed
Configure rubocop
1 parent 35e3f6a commit 1e76df1

31 files changed

+242
-60
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
- name: Run security checks
1919
run: |
2020
bin/bundler-audit --update
21-
2221
tests:
2322
name: Tests
2423
runs-on: ubuntu-latest

.rubocop.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
require: rubocop-rails
2+
3+
AllCops:
4+
NewCops: enable
5+
6+
Gemspec/DateAssignment: # (new in 1.10)
7+
Enabled: true
8+
Layout/SpaceBeforeBrackets: # (new in 1.7)
9+
Enabled: true
10+
Lint/AmbiguousAssignment: # (new in 1.7)
11+
Enabled: true
12+
Lint/DeprecatedConstants: # (new in 1.8)
13+
Enabled: true
14+
Lint/DuplicateBranch: # (new in 1.3)
15+
Enabled: true
16+
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
17+
Enabled: true
18+
Lint/EmptyBlock: # (new in 1.1)
19+
Enabled: true
20+
Lint/EmptyClass: # (new in 1.3)
21+
Enabled: true
22+
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
23+
Enabled: true
24+
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
25+
Enabled: true
26+
Lint/NumberedParameterAssignment: # (new in 1.9)
27+
Enabled: true
28+
Lint/OrAssignmentToConstant: # (new in 1.9)
29+
Enabled: true
30+
Lint/RedundantDirGlobSort: # (new in 1.8)
31+
Enabled: true
32+
Lint/SymbolConversion: # (new in 1.9)
33+
Enabled: true
34+
Lint/ToEnumArguments: # (new in 1.1)
35+
Enabled: true
36+
Lint/TripleQuotes: # (new in 1.9)
37+
Enabled: true
38+
Lint/UnexpectedBlockArity: # (new in 1.5)
39+
Enabled: true
40+
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
41+
Enabled: true
42+
Style/ArgumentsForwarding: # (new in 1.1)
43+
Enabled: true
44+
Style/CollectionCompact: # (new in 1.2)
45+
Enabled: true
46+
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
47+
Enabled: true
48+
Style/EndlessMethod: # (new in 1.8)
49+
Enabled: true
50+
Style/HashConversion: # (new in 1.10)
51+
Enabled: true
52+
Style/HashExcept: # (new in 1.7)
53+
Enabled: true
54+
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
55+
Enabled: true
56+
Style/NegatedIfElseCondition: # (new in 1.2)
57+
Enabled: true
58+
Style/NilLambda: # (new in 1.3)
59+
Enabled: true
60+
Style/RedundantArgument: # (new in 1.4)
61+
Enabled: true
62+
Style/StringChars: # (new in 1.12)
63+
Enabled: true
64+
Style/SwapValues: # (new in 1.1)
65+
Enabled: true
66+
Rails/ActiveRecordCallbacksOrder: # (new in 2.7)
67+
Enabled: true
68+
Rails/AfterCommitOverride: # (new in 2.8)
69+
Enabled: true
70+
Rails/AttributeDefaultBlockValue: # (new in 2.9)
71+
Enabled: true
72+
Rails/FindById: # (new in 2.7)
73+
Enabled: true
74+
Rails/Inquiry: # (new in 2.7)
75+
Enabled: true
76+
Rails/MailerName: # (new in 2.7)
77+
Enabled: true
78+
Rails/MatchRoute: # (new in 2.7)
79+
Enabled: true
80+
Rails/NegateInclude: # (new in 2.7)
81+
Enabled: true
82+
Rails/Pluck: # (new in 2.7)
83+
Enabled: true
84+
Rails/PluckInWhere: # (new in 2.7)
85+
Enabled: true
86+
Rails/RenderInline: # (new in 2.7)
87+
Enabled: true
88+
Rails/RenderPlainText: # (new in 2.7)
89+
Enabled: true
90+
Rails/ShortI18n: # (new in 2.7)
91+
Enabled: true
92+
Rails/SquishedSQLHeredocs: # (new in 2.8)
93+
Enabled: true
94+
Rails/WhereEquals: # (new in 2.9)
95+
Enabled: true
96+
Rails/WhereExists: # (new in 2.7)
97+
Enabled: true
98+
Rails/WhereNot: # (new in 2.8)
99+
Enabled: true

Gemfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
35

@@ -21,13 +23,15 @@ gem 'puma', '~> 5.0'
2123

2224
# Reduces boot times through caching; required in config/boot.rb
2325
gem 'bootsnap', '>= 1.4.4', require: false
26+
gem 'rubocop', '~> 1.13', require: false
27+
gem 'rubocop-rails', require: false
2428

2529
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
2630
# gem 'rack-cors'
2731

2832
group :development, :test do
2933
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
30-
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
34+
gem 'byebug', platforms: %i[mri mingw x64_mingw]
3135
end
3236

3337
group :development do
@@ -37,4 +41,4 @@ group :development do
3741
end
3842

3943
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
40-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
44+
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

Gemfile.lock

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ GEM
6060
minitest (>= 5.1)
6161
tzinfo (~> 2.0)
6262
zeitwerk (~> 2.3)
63+
ast (2.4.2)
6364
bootsnap (1.7.4)
6465
msgpack (~> 1.0)
6566
builder (3.2.4)
@@ -90,6 +91,9 @@ GEM
9091
racc (~> 1.4)
9192
nokogiri (1.11.3-x86_64-linux)
9293
racc (~> 1.4)
94+
parallel (1.20.1)
95+
parser (3.0.1.0)
96+
ast (~> 2.4.1)
9397
puma (5.2.2)
9498
nio4r (~> 2.0)
9599
racc (1.5.2)
@@ -122,10 +126,29 @@ GEM
122126
method_source
123127
rake (>= 0.8.7)
124128
thor (~> 1.0)
129+
rainbow (3.0.0)
125130
rake (13.0.3)
126131
rb-fsevent (0.10.4)
127132
rb-inotify (0.10.1)
128133
ffi (~> 1.0)
134+
regexp_parser (2.1.1)
135+
rexml (3.2.5)
136+
rubocop (1.13.0)
137+
parallel (~> 1.10)
138+
parser (>= 3.0.0.0)
139+
rainbow (>= 2.2.2, < 4.0)
140+
regexp_parser (>= 1.8, < 3.0)
141+
rexml
142+
rubocop-ast (>= 1.2.0, < 2.0)
143+
ruby-progressbar (~> 1.7)
144+
unicode-display_width (>= 1.4.0, < 3.0)
145+
rubocop-ast (1.4.1)
146+
parser (>= 2.7.1.5)
147+
rubocop-rails (2.9.1)
148+
activesupport (>= 4.2.0)
149+
rack (>= 1.1)
150+
rubocop (>= 0.90.0, < 2.0)
151+
ruby-progressbar (1.11.0)
129152
spring (2.1.1)
130153
sprockets (4.0.2)
131154
concurrent-ruby (~> 1.0)
@@ -138,6 +161,7 @@ GEM
138161
thor (1.1.0)
139162
tzinfo (2.0.4)
140163
concurrent-ruby (~> 1.0)
164+
unicode-display_width (2.0.0)
141165
websocket-driver (0.7.3)
142166
websocket-extensions (>= 0.1.0)
143167
websocket-extensions (0.1.5)
@@ -153,6 +177,8 @@ DEPENDENCIES
153177
listen (~> 3.3)
154178
puma (~> 5.0)
155179
rails (~> 6.1.3, >= 6.1.3.1)
180+
rubocop (~> 1.13)
181+
rubocop-rails
156182
spring
157183
sqlite3 (~> 1.4)
158184
tzinfo-data

Rakefile

Lines changed: 3 additions & 1 deletion
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/channels/application_cable/channel.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationCable
24
class Channel < ActionCable::Channel::Base
35
end

app/channels/application_cable/connection.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module ApplicationCable
24
class Connection < ActionCable::Connection::Base
35
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationController < ActionController::API
24
end

app/jobs/application_job.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationJob < ActiveJob::Base
24
# Automatically retry jobs that encountered a deadlock
35
# retry_on ActiveRecord::Deadlocked

app/mailers/application_mailer.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ApplicationMailer < ActionMailer::Base
24
default from: '[email protected]'
35
layout 'mailer'

app/models/application_record.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
# Record Base Class
14
class ApplicationRecord < ActiveRecord::Base
25
self.abstract_class = true
36
end

config.ru

Lines changed: 3 additions & 1 deletion
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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
require_relative "boot"
1+
# frozen_string_literal: true
22

3-
require "rails"
3+
require_relative 'boot'
4+
5+
require 'rails'
46
# Pick the frameworks you want:
5-
require "active_model/railtie"
6-
require "active_job/railtie"
7-
require "active_record/railtie"
8-
require "active_storage/engine"
9-
require "action_controller/railtie"
10-
require "action_mailer/railtie"
11-
require "action_mailbox/engine"
12-
require "action_text/engine"
13-
require "action_view/railtie"
14-
require "action_cable/engine"
7+
require 'active_model/railtie'
8+
require 'active_job/railtie'
9+
require 'active_record/railtie'
10+
require 'active_storage/engine'
11+
require 'action_controller/railtie'
12+
require 'action_mailer/railtie'
13+
require 'action_mailbox/engine'
14+
require 'action_text/engine'
15+
require 'action_view/railtie'
16+
require 'action_cable/engine'
1517
# require "sprockets/railtie"
16-
require "rails/test_unit/railtie"
18+
require 'rails/test_unit/railtie'
1719

1820
# Require the gems listed in Gemfile, including any gems
1921
# you've limited to :test, :development, or :production.
2022
Bundler.require(*Rails.groups)
2123

2224
module NsfsApi
25+
# Application Base Class
2326
class Application < Rails::Application
2427
# Initialize configuration defaults for originally generated Rails version.
2528
config.load_defaults 6.1

config/boot.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
# frozen_string_literal: true
2+
13
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
24

3-
require "bundler/setup" # Set up gems listed in the Gemfile.
4-
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 4 additions & 3 deletions
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.
@@ -16,7 +18,7 @@
1618

1719
# Enable/disable caching. By default caching is disabled.
1820
# Run rails dev:cache to toggle caching.
19-
if Rails.root.join('tmp', 'caching-dev.txt').exist?
21+
if Rails.root.join('tmp/caching-dev.txt').exist?
2022
config.cache_store = :memory_store
2123
config.public_file_server.headers = {
2224
'Cache-Control' => "public, max-age=#{2.days.to_i}"
@@ -50,7 +52,6 @@
5052
# Highlight code that triggered database queries in logs.
5153
config.active_record.verbose_query_logs = true
5254

53-
5455
# Raises error for missing translations.
5556
# config.i18n.raise_on_missing_translations = true
5657

config/environments/production.rb

Lines changed: 7 additions & 5 deletions
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
@@ -81,8 +83,8 @@
8183
# require "syslog/logger"
8284
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
8385

84-
if ENV["RAILS_LOG_TO_STDOUT"].present?
85-
logger = ActiveSupport::Logger.new(STDOUT)
86+
if ENV['RAILS_LOG_TO_STDOUT'].present?
87+
logger = ActiveSupport::Logger.new($stdout)
8688
logger.formatter = config.log_formatter
8789
config.logger = ActiveSupport::TaggedLogging.new(logger)
8890
end

config/environments/test.rb

Lines changed: 3 additions & 1 deletion
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

config/initializers/application_controller_renderer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# Be sure to restart your server when you modify this file.
23

34
# ActiveSupport::Reloader.to_prepare do

0 commit comments

Comments
 (0)