-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6756 from Drenmi/bugfix/retry-node
[Fix #6751] Prevent Style/OneLineConditional from breaking on retry and break keywords
- Loading branch information
Showing
11 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module AST | ||
# A node extension for `break` nodes. This will be used in place of a | ||
# plain node when the builder constructs the AST, making its methods | ||
# available to all `break` nodes within RuboCop. | ||
class BreakNode < Node | ||
include MethodDispatchNode | ||
include ParameterizedNode | ||
|
||
def arguments | ||
[] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module AST | ||
# A node extension for `retry` nodes. This will be used in place of a | ||
# plain node when the builder constructs the AST, making its methods | ||
# available to all `retry` nodes within RuboCop. | ||
class RetryNode < Node | ||
include MethodDispatchNode | ||
include ParameterizedNode | ||
|
||
def arguments | ||
[] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RuboCop::AST::BreakNode do | ||
let(:break_node) { parse_source(source).ast } | ||
|
||
describe '.new' do | ||
context 'with a break node' do | ||
let(:source) { 'break' } | ||
|
||
it { expect(break_node.is_a?(described_class)).to be(true) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RuboCop::AST::DefinedNode do | ||
let(:defined_node) { parse_source(source).ast } | ||
|
||
describe '.new' do | ||
context 'with a defined? node' do | ||
let(:source) { 'defined? :foo' } | ||
|
||
it { expect(defined_node.is_a?(described_class)).to be(true) } | ||
end | ||
end | ||
|
||
describe '#receiver' do | ||
let(:source) { 'defined? :foo' } | ||
|
||
it { expect(defined_node.receiver).to eq(nil) } | ||
end | ||
|
||
describe '#method_name' do | ||
let(:source) { 'defined? :foo' } | ||
|
||
it { expect(defined_node.method_name).to eq(:defined?) } | ||
end | ||
|
||
describe '#arguments' do | ||
let(:source) { 'defined? :foo' } | ||
|
||
it { expect(defined_node.arguments.size).to eq(1) } | ||
it { expect(defined_node.arguments).to all(be_sym_type) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RuboCop::AST::RetryNode do | ||
let(:retry_node) { parse_source(source).ast } | ||
|
||
describe '.new' do | ||
context 'with a retry node' do | ||
let(:source) { 'retry' } | ||
|
||
it { expect(retry_node.is_a?(described_class)).to be(true) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters