Skip to content

Commit bc5a837

Browse files
committed
Fix regexp indentation.
1 parent 37aec5d commit bc5a837

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/rubocop/socketry/layout/consistent_blank_line_indentation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def build_indentation_deltas
8989
deltas
9090
end
9191

92-
STRUCTURAL_NODES = [:array, :hash, :class, :module, :sclass, :def, :defs, :if, :if, :while, :until, :for, :case, :kwbegin]
92+
STRUCTURAL_NODES = [:array, :hash, :class, :module, :sclass, :def, :defs, :if, :if, :while, :until, :for, :case, :kwbegin, :regexp]
9393

9494
# Recursively walk the AST to build indentation deltas for block structures.
9595
# This method identifies nodes that should affect indentation and records the deltas.

test/rubocop/socketry/layout/consistent_blank_line_indentation.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,4 +743,26 @@ def foo
743743
end
744744
end
745745
end
746+
747+
with "a regex with inconsistent indentation in blank lines" do
748+
let(:source) {<<~RUBY}
749+
REDACT = /
750+
phone
751+
| email
752+
753+
| device_name
754+
/xi
755+
RUBY
756+
757+
it "registers offenses when blank lines in regex literal are not properly indented" do
758+
processed_source = RuboCop::ProcessedSource.new(source, RUBY_VERSION.to_f)
759+
investigator = RuboCop::Cop::Commissioner.new([cop], [], raise_error: true)
760+
report = investigator.investigate(processed_source)
761+
offenses = report.offenses
762+
expect(offenses.size).to be > 0
763+
offenses.each do |offense|
764+
expect(offense.message).to be(:include?, message)
765+
end
766+
end
767+
end
746768
end

0 commit comments

Comments
 (0)