rubocop-discourse 3.9.2 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b3535299ced6e96016ee33586fe7e9b8e0b910c6cc2a441972acb9e3c6b9207
4
- data.tar.gz: 99f0a0dd461aebbc1267dba788730ade31af6a02f0709ae51c8afba65b109d98
3
+ metadata.gz: 5bc9ad5c366f3eee3d8924d4570a420e7ca4bcca8bbcf735c8187a07273868c2
4
+ data.tar.gz: 1579af93f1fa21a1bdc50f192e39344ad9eef86d999af292ca477aa8fcf14e1a
5
5
  SHA512:
6
- metadata.gz: 48c1e9c95219737c00fd847c9f030f4e3704147b64dd16cc5a79449cec341535d870f498430afc7b47115ad6edb31adddcc54e145e60d100292fef7576e3b689
7
- data.tar.gz: 2b19583ee4c90bb79e1dfcfe5919bf1fe9c13786ecd8a8d6b4cfe0bfaa0fc8952ae280a721631d4968b736ac13c34857290698b989bbcf8ce30dafa57bf6c0d7
6
+ metadata.gz: 405df3366dae911d28df1895f09479a04115d974a10c81a604337f201234b71dfa20aee185bf13238c9e632ec8e167daf1f700d8e9088e55373689031e68177d
7
+ data.tar.gz: c8bcf09528c1f785f4476aa3f2f20a9db72be7bccd9a0fe45cbf9a40a0290cbadd9cf3e487c2cb435ddf036f801348ee6569ab951a98573c47dbc10a3db29b34
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
 
13
13
  steps:
14
- - uses: actions/checkout@v3
14
+ - uses: actions/checkout@v4
15
15
 
16
16
  - name: Setup ruby
17
17
  uses: ruby/setup-ruby@v1
@@ -31,7 +31,7 @@ jobs:
31
31
  runs-on: ubuntu-latest
32
32
 
33
33
  steps:
34
- - uses: actions/checkout@v3
34
+ - uses: actions/checkout@v4
35
35
 
36
36
  - name: Release Gem
37
37
  uses: discourse/publish-rubygems-action@v3
data/.streerc ADDED
@@ -0,0 +1,2 @@
1
+ --print-width=100
2
+ --plugins=plugin/trailing_comma,plugin/disable_auto_ternary
data/Gemfile CHANGED
@@ -6,5 +6,6 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  group :development, :test do
9
- gem 'byebug'
9
+ gem "syntax_tree"
10
+ gem "byebug"
10
11
  end
@@ -53,7 +53,7 @@ module RuboCop
53
53
  def on_block(node)
54
54
  return unless service?
55
55
  return unless top_level_block?(node)
56
- return if node.single_line?
56
+ return if node.single_line? || single_block?(node)
57
57
 
58
58
  if missing_empty_lines?(node)
59
59
  add_offense(node, message: MSG) do |corrector|
@@ -78,6 +78,10 @@ module RuboCop
78
78
 
79
79
  private
80
80
 
81
+ def single_block?(node)
82
+ !node.ancestors.first.begin_type?
83
+ end
84
+
81
85
  def service?
82
86
  @service
83
87
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Discourse
5
+ class Plugin < LintRoller::Plugin
6
+ def about
7
+ LintRoller::About.new(
8
+ name: "rubocop-discourse",
9
+ version: RuboCop::Discourse::VERSION,
10
+ homepage: "https://github.com/discourse/rubocop-discourse",
11
+ description: "Custom rubocop cops used by Discourse",
12
+ )
13
+ end
14
+
15
+ def supported?(context)
16
+ context.engine == :rubocop
17
+ end
18
+
19
+ def rules(_context)
20
+ LintRoller::Rules.new(
21
+ type: :path,
22
+ config_format: :rubocop,
23
+ value: Pathname.new(__dir__).join("../../../config/default.yml"),
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Discourse
5
+ VERSION = "3.10.0"
6
+ end
7
+ end
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rubocop"
4
+ require "lint_roller"
4
5
  require "active_support"
5
6
  require "active_support/core_ext/string/inflections"
6
7
  require "active_support/core_ext/object/blank"
7
8
  require "active_support/core_ext/enumerable"
8
- require_relative "rubocop/discourse"
9
- require_relative "rubocop/discourse/inject"
10
-
11
- RuboCop::Discourse::Inject.defaults!
12
-
13
9
  require_relative "rubocop/cop/discourse_cops"
10
+ require_relative "rubocop/discourse/version"
11
+ require_relative "rubocop/discourse/plugin"
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib)
5
+ require "rubocop/discourse/version"
6
+
3
7
  Gem::Specification.new do |s|
4
8
  s.name = "rubocop-discourse"
5
- s.version = "3.9.2"
9
+ s.version = RuboCop::Discourse::VERSION
6
10
  s.summary = "Custom rubocop cops used by Discourse"
7
11
  s.authors = ["Discourse Team"]
8
12
  s.license = "MIT"
@@ -10,14 +14,16 @@ Gem::Specification.new do |s|
10
14
 
11
15
  s.files = `git ls-files`.split($/)
12
16
  s.require_paths = ["lib"]
17
+ s.metadata["default_lint_roller_plugin"] = "RuboCop::Discourse::Plugin"
13
18
 
14
19
  s.add_runtime_dependency "activesupport", ">= 6.1"
15
- s.add_runtime_dependency "rubocop", ">= 1.59.0"
20
+ s.add_runtime_dependency "rubocop", ">= 1.72.0"
16
21
  s.add_runtime_dependency "rubocop-rspec", ">= 3.0.1"
17
22
  s.add_runtime_dependency "rubocop-factory_bot", ">= 2.0.0"
18
23
  s.add_runtime_dependency "rubocop-capybara", ">= 2.0.0"
19
24
  s.add_runtime_dependency "rubocop-rails", ">= 2.25.0"
20
25
  s.add_runtime_dependency "rubocop-rspec_rails", ">= 2.30.0"
26
+ s.add_runtime_dependency "lint_roller", ">= 1.1.0"
21
27
 
22
28
  s.add_development_dependency "rake", "~> 13.1.0"
23
29
  s.add_development_dependency "rspec", "~> 3.12.0"
data/rubocop-rails.yml CHANGED
@@ -1,4 +1,4 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-rails
3
3
 
4
4
  Rails:
data/rubocop-rspec.yml CHANGED
@@ -1,5 +1,7 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-rspec
3
+
4
+ require:
3
5
  - rubocop-rspec_rails
4
6
 
5
7
  RSpec/AnyInstance:
@@ -128,6 +128,23 @@ RSpec.describe RuboCop::Cop::Discourse::Services::EmptyLinesAroundBlocks,
128
128
  end
129
129
 
130
130
  context "when blocks are nested" do
131
+ context "when there is just one nested block" do
132
+ it "does not register an offense" do
133
+ expect_no_offenses(<<~RUBY)
134
+ class MyService
135
+ include Service::Base
136
+
137
+ transaction do
138
+ try do
139
+ step :first_step
140
+ step :second_step
141
+ end
142
+ end
143
+ end
144
+ RUBY
145
+ end
146
+ end
147
+
131
148
  context "when the nested block is in the first position" do
132
149
  context "when there is no empty line before" do
133
150
  it "does not register an offense" do
data/stree-compat.yml CHANGED
@@ -1,4 +1,4 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-discourse
3
3
 
4
4
  inherit_from:
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-discourse
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.2
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Discourse Team
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-06 00:00:00.000000000 Z
10
+ date: 2025-02-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.59.0
32
+ version: 1.72.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 1.59.0
39
+ version: 1.72.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rubocop-rspec
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +107,20 @@ dependencies:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: 2.30.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: lint_roller
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 1.1.0
117
+ type: :runtime
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 1.1.0
110
124
  - !ruby/object:Gem::Dependency
111
125
  name: rake
112
126
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +157,7 @@ files:
143
157
  - ".gitignore"
144
158
  - ".rspec"
145
159
  - ".rubocop.yml"
160
+ - ".streerc"
146
161
  - Gemfile
147
162
  - LICENSE
148
163
  - README.md
@@ -172,8 +187,8 @@ files:
172
187
  - lib/rubocop/cop/discourse/services/group_keywords.rb
173
188
  - lib/rubocop/cop/discourse/time_eq_matcher.rb
174
189
  - lib/rubocop/cop/discourse_cops.rb
175
- - lib/rubocop/discourse.rb
176
- - lib/rubocop/discourse/inject.rb
190
+ - lib/rubocop/discourse/plugin.rb
191
+ - lib/rubocop/discourse/version.rb
177
192
  - rubocop-capybara.yml
178
193
  - rubocop-core.yml
179
194
  - rubocop-discourse.gemspec
@@ -208,7 +223,8 @@ files:
208
223
  homepage: https://github.com/discourse/rubocop-discourse
209
224
  licenses:
210
225
  - MIT
211
- metadata: {}
226
+ metadata:
227
+ default_lint_roller_plugin: RuboCop::Discourse::Plugin
212
228
  rdoc_options: []
213
229
  require_paths:
214
230
  - lib
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Discourse
5
- # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
6
- # bit of our configuration.
7
- module Inject
8
- def self.defaults!
9
- path = CONFIG_DEFAULT.to_s
10
- hash = ConfigLoader.send(:load_yaml_configuration, path)
11
- config = Config.new(hash, path)
12
- puts "configuration from #{path}" if ConfigLoader.debug?
13
- config = ConfigLoader.merge_with_default(config, path)
14
- ConfigLoader.instance_variable_set(:@default_configuration, config)
15
- end
16
- end
17
- end
18
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- # RuboCop Discourse project namespace
5
- module Discourse
6
- PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
7
- CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze
8
- CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
9
-
10
- private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
11
- end
12
- end