Skip to content

[Fix #14737] Fix crash in Layout/RedundantLineBreak when Layout/LineLength is disabled#14742

Merged
koic merged 1 commit intorubocop:masterfrom
ydakuka:14737/fix_crash_in_layout_redundant_line_break_when_layout_line_length_is_disabled
Dec 23, 2025
Merged

[Fix #14737] Fix crash in Layout/RedundantLineBreak when Layout/LineLength is disabled#14742
koic merged 1 commit intorubocop:masterfrom
ydakuka:14737/fix_crash_in_layout_redundant_line_break_when_layout_line_length_is_disabled

Conversation

@ydakuka
Copy link
Copy Markdown
Contributor

@ydakuka ydakuka commented Dec 23, 2025

Fixes #14737


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.


context 'when `Layout/LineLength` is disabled' do
let(:line_length_config) { { 'Enabled' => false } }
let(:inspect_blocks) { [false, true].sample }
Copy link
Copy Markdown
Member

@koic koic Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't introduce randomness into test code. Can you update lets as shown below?

diff --git a/spec/rubocop/cop/layout/redundant_line_break_spec.rb b/spec/rubocop/cop/layout/redundant_line_break_spec.rb
index d00d130df..49ed6ebce 100644
--- a/spec/rubocop/cop/layout/redundant_line_break_spec.rb
+++ b/spec/rubocop/cop/layout/redundant_line_break_spec.rb
@@ -2,14 +2,17 @@

 RSpec.describe RuboCop::Cop::Layout::RedundantLineBreak, :config do
   let(:config) do
-    RuboCop::Config.new('Layout/LineLength' => line_length_config,
+    RuboCop::Config.new('Layout/LineLength' => {
+                          'Enabled' => line_length_enabled, 'Max' => max_line_length
+                        },
                         'Layout/RedundantLineBreak' => { 'InspectBlocks' => inspect_blocks },
                         'Layout/SingleLineBlockChain' => {
                           'Enabled' => single_line_block_chain_enabled
                         })
   end
-  let(:line_length_config) { { 'Max' => max_line_length } }
+  let(:line_length_enabled) { true }
   let(:max_line_length) { 31 }
+  let(:inspect_blocks) { false }
   let(:single_line_block_chain_enabled) { true }

   shared_examples 'common behavior' do
@@ -777,8 +780,7 @@ RSpec.describe RuboCop::Cop::Layout::RedundantLineBreak, :config do
   end

   context 'when `Layout/LineLength` is disabled' do
-    let(:line_length_config) { { 'Enabled' => false } }
-    let(:inspect_blocks) { [false, true].sample }
+    let(:line_length_enabled) { false }

     it 'registers an offense for a method call on multiple lines' do
       expect_offense(<<~RUBY)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, changed.

@ydakuka ydakuka force-pushed the 14737/fix_crash_in_layout_redundant_line_break_when_layout_line_length_is_disabled branch from e4bb4ed to 1873836 Compare December 23, 2025 16:10
@koic koic merged commit a6e4adf into rubocop:master Dec 23, 2025
22 checks passed
@koic
Copy link
Copy Markdown
Member

koic commented Dec 23, 2025

Thanks!

@ydakuka ydakuka deleted the 14737/fix_crash_in_layout_redundant_line_break_when_layout_line_length_is_disabled branch December 23, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArgumentError in check_single_line_suitability

2 participants