runger_style 4.4.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4428b1d4a31a45eb414ee1d9235df01cd4d9f6c8aef534ccaaff48d1302923e9
4
- data.tar.gz: 2250046cdd4cdff82ba1db8dfc4d89dace70fcf9ea58a2eb3b9eafc7851a2827
3
+ metadata.gz: '089e6bed54b363029e157336dac7eafac5a9401d50662662103b02373827c235'
4
+ data.tar.gz: 14e29ec24c33427d0330c3f8ed8b8a985b8dac4a5851098619fa072967b06cfc
5
5
  SHA512:
6
- metadata.gz: f1a0cc0f2444fd15b13838c9e89e4ca461c022b3f2519b160f1495cedc8f21a8e33314d8fa5bfe72adc400877aaea3c4db5d838f4c114e652f68fa6f2a464694
7
- data.tar.gz: 8a5d690cfc9ab98fbfdc24c853250e6409e4693c9997a293b824de373bd19d1492ac14f9de85b4d1bbb172ed6ef803d6e088899079a0443e5e5e9299c641e47e
6
+ metadata.gz: e942a2e414e7726ee7b9b0b8fcc47f20750833d05dbcca5f7659351d8ab28715e1d477917cde8ab73dc8a47bdd92b2aabc9b175b909d0dd561d1049a878d490e
7
+ data.tar.gz: '0762039ac0c0fad9fa0487e2c0cc974a81e237e7f5dbcf29c501b995b3aa4ba42c8d2644c3585b1d976f4e5a0e2f173529642f87e6301fdbc242da3a65814ba7'
data/.rubocop.yml CHANGED
@@ -7,3 +7,7 @@ inherit_from:
7
7
  - rulesets/rake.yml
8
8
  - rulesets/rspec_rails.yml
9
9
  - rulesets/rspec.yml
10
+
11
+ # Load the Rails cops to check that they work, but disable them because this isn't a Rails project.
12
+ Rails:
13
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v4.5.0 (2025-02-11)
2
+ - Add custom `RungerStyle/MultilineHashValueIndentation` cop.
3
+ - Add custom `RungerStyle/FirstArgumentIndentation` cop.
4
+
1
5
  ## v4.4.1 (2025-02-10)
2
6
  - Remove `RSpec/DescribeClass` custom config.
3
7
 
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- runger_style (4.4.1)
12
+ runger_style (4.5.0)
13
13
  prism (>= 0.24.0)
14
14
  rubocop (>= 1.68.0)
15
15
 
@@ -46,7 +46,7 @@ GEM
46
46
  pp (>= 0.6.0)
47
47
  rdoc (>= 4.0.0)
48
48
  reline (>= 0.4.2)
49
- json (2.9.1)
49
+ json (2.10.1)
50
50
  language_server-protocol (3.17.0.4)
51
51
  logger (1.6.5)
52
52
  memo_wise (1.10.0)
@@ -173,7 +173,7 @@ CHECKSUMS
173
173
  i18n (1.14.7) sha256=ceba573f8138ff2c0915427f1fc5bdf4aa3ab8ae88c8ce255eb3ecf0a11a5d0f
174
174
  io-console (0.8.0) sha256=cd6a9facbc69871d69b2cb8b926fc6ea7ef06f06e505e81a64f14a470fddefa2
175
175
  irb (1.15.1) sha256=d9bca745ac4207a8b728a52b98b766ca909b86ff1a504bcde3d6f8c84faae890
176
- json (2.9.1) sha256=d2bdef4644052fad91c1785d48263756fe32fcac08b96a20bb15840e96550d11
176
+ json (2.10.1) sha256=ddc88ad91a1baf3f0038c174f253af3b086d30dc74db17ca4259bbde982f94dc
177
177
  language_server-protocol (3.17.0.4) sha256=c484626478664fd13482d8180947c50a8590484b1258b99b7aedb3b69df89669
178
178
  logger (1.6.5) sha256=c3cfe56d01656490ddd103d38b8993d73d86296adebc5f58cefc9ec03741e56b
179
179
  memo_wise (1.10.0) sha256=ae40ff8e7799697ff5d59d739b8766f76be22eba69c7c8468edb42ab83c94c3f
@@ -211,7 +211,7 @@ CHECKSUMS
211
211
  ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
212
212
  runger_byebug (11.4.0) sha256=569e22ba2215f57e7f69e145fcb63be401e29fcd312f7936d813e12d0c7bbee6
213
213
  runger_release_assistant (2.0.0) sha256=f4f5708291eaeef1b881208f87a494877fe768739d6e96b7293fc335b28a3865
214
- runger_style (4.4.1)
214
+ runger_style (4.5.0)
215
215
  securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
216
216
  slop (4.10.1) sha256=844322b5ffcf17ed4815fdb173b04a20dd82b4fd93e3744c88c8fafea696d9c7
217
217
  stringio (3.1.2) sha256=204f1828f85cdb39d57cac4abc6dc44b04505a223f131587f2e20ae3729ba131
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RungerStyle # rubocop:disable Style/ClassAndModuleChildren
4
+ class FirstArgumentIndentation < ::RuboCop::Cop::Layout::FirstArgumentIndentation
5
+ def on_send(node)
6
+ return if memoizing?(node)
7
+
8
+ super
9
+ end
10
+
11
+ private
12
+
13
+ def memoizing?(node)
14
+ memoizing_method_names.include?(node.method_name)
15
+ end
16
+
17
+ def memoizing_method_names
18
+ @memoizing_method_names ||= cop_config['MemoizingMethods'].map(&:to_sym)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RungerStyle # rubocop:disable Style/ClassAndModuleChildren
4
+ class MultilineHashValueIndentation < ::RuboCop::Cop::Base
5
+ extend ::RuboCop::Cop::AutoCorrector
6
+
7
+ MSG = 'Hash value should be indented by two spaces relative to its key.'
8
+
9
+ def on_pair(node)
10
+ key_node = node.key
11
+ value_node = node.value
12
+
13
+ # Only check if the key and value appear on separate lines.
14
+ if key_node.source_range.line != value_node.source_range.line
15
+ key_column = key_node.source_range.column
16
+ expected_value_column = key_column + 2
17
+ actual_value_column = value_node.source_range.column
18
+
19
+ if actual_value_column != expected_value_column
20
+ add_offense(value_node, message: MSG) do |corrector|
21
+ buffer = value_node.source_range.source_buffer
22
+ # Get the entire line where the value starts.
23
+ line_range = buffer.line_range(value_node.source_range.line)
24
+ # Create a range covering just the indentation of that line.
25
+ indentation_range =
26
+ Parser::Source::Range.new(
27
+ buffer,
28
+ line_range.begin_pos,
29
+ value_node.source_range.begin_pos,
30
+ )
31
+ # Replace the existing indentation with the expected number of spaces.
32
+ corrector.replace(indentation_range, ' ' * expected_value_column)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module RungerStyle # rubocop:disable Style/ClassAndModuleChildren
4
4
  class MultilineMethodArgumentsLineBreaks < ::RuboCop::Cop::Base
5
- extend RuboCop::Cop::AutoCorrector
6
- include RuboCop::Cop::RangeHelp
5
+ extend ::RuboCop::Cop::AutoCorrector
6
+ include ::RuboCop::Cop::RangeHelp
7
7
 
8
8
  MSG = 'Each argument in a multi-line method call must start on a separate line.'
9
9
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RungerStyle
4
- VERSION = '4.4.1'
4
+ VERSION = '4.5.0'
5
5
  end
data/rulesets/default.yml CHANGED
@@ -13,8 +13,6 @@ Bundler/GemVersion:
13
13
  Layout:
14
14
  Exclude:
15
15
  - db/schema.rb
16
- Layout/ArgumentAlignment:
17
- EnforcedStyle: with_fixed_indentation
18
16
  Layout/BlockAlignment:
19
17
  EnforcedStyleAlignWith: start_of_block
20
18
  Layout/ClassStructure:
@@ -35,7 +33,7 @@ Layout/EmptyLineAfterMultilineCondition:
35
33
  Layout/EmptyLineBetweenDefs:
36
34
  AllowAdjacentOneLineDefs: true
37
35
  Layout/FirstArgumentIndentation:
38
- Enabled: false # this rule doesn't play nicely with the way that I like to use `memoize`
36
+ Enabled: false # Instead, we use RungerStyle/FirstArgumentIndentation.
39
37
  Layout/FirstArrayElementIndentation:
40
38
  EnforcedStyle: consistent
41
39
  Layout/FirstMethodArgumentLineBreak:
@@ -53,6 +51,15 @@ Layout/LineLength:
53
51
  # Ignore RSpec description strings:
54
52
  - !ruby/regexp /^ *(context|describe|it) ['"].*['"].* do$/
55
53
  Max: 100
54
+ Layout/MultilineAssignmentLayout:
55
+ SupportedTypes:
56
+ - block
57
+ - case
58
+ - class
59
+ - if
60
+ - kwbegin
61
+ - module
62
+ - send # This (method calls) is not in the default list.
56
63
  Layout/MultilineMethodCallIndentation:
57
64
  EnforcedStyle: indented
58
65
  Layout/MultilineOperationIndentation:
@@ -97,6 +104,13 @@ Naming/RescuedExceptionsVariableName:
97
104
  Enabled: false
98
105
  Naming/VariableNumber:
99
106
  Enabled: false
107
+ RungerStyle/FirstArgumentIndentation:
108
+ EnforcedStyle: consistent_relative_to_receiver
109
+ MemoizingMethods:
110
+ - memo_wise
111
+ - memoize
112
+ SupportedStyles:
113
+ - consistent_relative_to_receiver
100
114
  Style:
101
115
  Exclude:
102
116
  - db/schema.rb
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runger_style
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Runger
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-10 00:00:00.000000000 Z
10
+ date: 2025-02-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: prism
@@ -66,6 +66,8 @@ files:
66
66
  - bin/rspec
67
67
  - bin/rubocop
68
68
  - lib/runger_style.rb
69
+ - lib/runger_style/cops/first_argument_indentation.rb
70
+ - lib/runger_style/cops/multiline_hash_value_indentation.rb
69
71
  - lib/runger_style/cops/multiline_method_arguments_line_breaks.rb
70
72
  - lib/runger_style/cops/require_all_custom_cops.rb
71
73
  - lib/runger_style/version.rb