Skip to content

Commit 0cbed24

Browse files
authored
Merge pull request #173 from publify/update-rubocop-dependencies
Update RuboCop dependencies and configuration and fix new offenses
2 parents 11727f5 + 096e861 commit 0cbed24

File tree

11 files changed

+27
-33
lines changed

11 files changed

+27
-33
lines changed

.rubocop.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ inherit_mode:
44
merge:
55
- Exclude
66

7-
require:
7+
plugins:
88
- rubocop-capybara
99
- rubocop-factory_bot
1010
- rubocop-performance
1111
- rubocop-rails
1212
- rubocop-rspec
13+
- rubocop-rspec_rails
1314

1415
AllCops:
1516
Exclude:
@@ -114,12 +115,12 @@ Rails/SkipsModelValidations:
114115
Exclude:
115116
- 'db/migrate/*'
116117

117-
RSpec/Capybara/FeatureMethods:
118+
RSpec/Dialect:
118119
Exclude:
119120
- 'spec/features/**_spec.rb'
120121

121122
# Spec type inference is disabled, so this cop must be disabled too.
122-
RSpec/Rails/InferredSpecType:
123+
RSpecRails/InferredSpecType:
123124
Enabled: false
124125

125126
# Allow the use of 'and' 'or' in control structures.

app/controllers/admin/seo_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class Admin::SeoController < Admin::BaseController
44
before_action :set_setting
55
before_action :set_section
66

7+
VALID_SECTIONS = %w(general titles permalinks).freeze
8+
79
def show
810
if @setting.permalink_format != "/%year%/%month%/%day%/%title%" &&
911
@setting.permalink_format != "/%year%/%month%/%title%" &&
@@ -37,8 +39,6 @@ def settings_keys
3739
@setting.settings_keys + [:custom_permalink]
3840
end
3941

40-
VALID_SECTIONS = %w(general titles permalinks).freeze
41-
4242
def set_section
4343
section = params[:section]
4444
@section = VALID_SECTIONS.include?(section) ? section : "general"

app/controllers/admin/settings_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
class Admin::SettingsController < Admin::BaseController
4+
VALID_ACTIONS = %w(index write feedback display).freeze
5+
46
def index
57
this_blog.base_url = blog_base_url if this_blog.base_url.blank?
68
load_settings
@@ -33,8 +35,6 @@ def update
3335

3436
private
3537

36-
VALID_ACTIONS = %w(index write feedback display).freeze
37-
3838
def settings_params
3939
@settings_params ||= params.require(:setting).permit(@setting.settings_keys)
4040
end

app/models/article.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def self.last_draft(article_id)
101101

102102
def self.search_with(params)
103103
params ||= {}
104-
scoped = super(params)
104+
scoped = super
105105
if %w(no_draft drafts published withdrawn pending).include?(params[:state])
106106
scoped = scoped.send(params[:state])
107107
end
@@ -145,7 +145,7 @@ def next
145145
end
146146

147147
def previous
148-
Article.where("published_at < ?", published_at).order("published_at desc")
148+
Article.where(published_at: ...published_at).order("published_at desc")
149149
.limit(1).first
150150
end
151151

app/models/config_manager.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ def canonicalize(key, value)
6969
self.class.fields[key.to_s].canonicalize(value)
7070
end
7171

72-
def settings_keys
73-
self.class.settings_keys
74-
end
72+
delegate :settings_keys, to: :class
7573

7674
class Item
7775
VALID_TYPES = [:boolean, :integer, :string, :text].freeze

app/models/note.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Note < Content
2121
after_create :set_permalink, :shorten_url
2222

2323
scope :published, lambda {
24-
where(state: "published").where("published_at <= ?", Time.zone.now).order(default_order)
24+
where(state: "published").where(published_at: ..Time.zone.now).order(default_order)
2525
}
2626
default_scope { order("published_at DESC") }
2727

app/models/sidebar.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ def html_id
9797

9898
def parse_request(_contents, _params); end
9999

100-
def fields
101-
self.class.fields
102-
end
100+
delegate :fields, to: :class
103101

104102
def fieldmap(field = nil)
105103
if field
@@ -109,17 +107,11 @@ def fieldmap(field = nil)
109107
end
110108
end
111109

112-
def description
113-
self.class.description
114-
end
110+
delegate :description, to: :class
115111

116-
def short_name
117-
self.class.short_name
118-
end
112+
delegate :short_name, to: :class
119113

120-
def display_name
121-
self.class.display_name
122-
end
114+
delegate :display_name, to: :class
123115

124116
def content_partial
125117
"/#{self.class.path_name}/content"

app/models/trigger.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def post_action(due_at, item, method = "came_due")
1111
end
1212

1313
def fire
14-
where("due_at <= ?", Time.zone.now).destroy_all
14+
where(due_at: ..Time.zone.now).destroy_all
1515
true
1616
end
1717

publify_core.gemspec

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ Gem::Specification.new do |s|
5858
s.add_development_dependency "rails-controller-testing", "~> 1.0.1"
5959
s.add_development_dependency "rake-manifest", "~> 0.2.0"
6060
s.add_development_dependency "rspec-rails", "~> 6.0"
61-
s.add_development_dependency "rubocop", "~> 1.59.0"
62-
s.add_development_dependency "rubocop-capybara", "~> 2.21.0"
63-
s.add_development_dependency "rubocop-factory_bot", "~> 2.24.0"
64-
s.add_development_dependency "rubocop-performance", "~> 1.20.0"
65-
s.add_development_dependency "rubocop-rails", "~> 2.23.0"
66-
s.add_development_dependency "rubocop-rspec", "~> 2.25.0"
61+
s.add_development_dependency "rubocop", "~> 1.75.6"
62+
s.add_development_dependency "rubocop-capybara", "~> 2.22.1"
63+
s.add_development_dependency "rubocop-factory_bot", "~> 2.27.1"
64+
s.add_development_dependency "rubocop-performance", "~> 1.25.0"
65+
s.add_development_dependency "rubocop-rails", "~> 2.32.0"
66+
s.add_development_dependency "rubocop-rspec", "~> 3.6.0"
67+
s.add_development_dependency "rubocop-rspec_rails", "~> 2.31.0"
6768
s.add_development_dependency "shoulda-matchers", "~> 6.0"
6869
s.add_development_dependency "simplecov", "~> 0.22.0"
6970
s.add_development_dependency "sqlite3", "~> 1.6"

spec/controllers/articles_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
end
197197

198198
it "assigns @search the search string" do
199-
expect(assigns[:search]).to be_equal(controller.params[:q])
199+
expect(assigns[:search]).to equal(controller.params[:q])
200200
end
201201
end
202202
end

0 commit comments

Comments
 (0)