Skip to content

Commit

Permalink
Clean up the code
Browse files Browse the repository at this point in the history
Fixed new RuboCop violations.
  • Loading branch information
enkessler committed Jun 1, 2024
1 parent a3bdbfd commit 5904578
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 74 deletions.
2 changes: 1 addition & 1 deletion lib/cuke_modeler/adapters/gherkin_18_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Gherkin18Adapter < Gherkin9Adapter

# Adapts the AST sub-tree that is rooted at the given rule node.
def adapt_rule(rule_ast)
adapted_rule = super(rule_ast)
adapted_rule = super

clear_child_elements(adapted_rule, [[:rule, :tags]])

Expand Down
6 changes: 3 additions & 3 deletions lib/cuke_modeler/adapters/gherkin_19_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Gherkin19Adapter < Gherkin18Adapter

# Adapts the AST sub-tree that is rooted at the given step node.
def adapt_step(step_ast)
adapted_step = super(step_ast)
adapted_step = super

clear_child_elements(adapted_step, [[:dataTable],
[:docString]])
Expand All @@ -27,7 +27,7 @@ def adapt_step(step_ast)

# Adapts the AST sub-tree that is rooted at the given doc string node.
def adapt_doc_string(doc_string_ast)
adapted_doc_string = super(doc_string_ast)
adapted_doc_string = super

adapted_doc_string['content_type'] = doc_string_ast[:mediaType]

Expand All @@ -36,7 +36,7 @@ def adapt_doc_string(doc_string_ast)

# Adapts the AST sub-tree that is rooted at the given example node.
def adapt_example(example_ast)
adapted_example = super(example_ast)
adapted_example = super

clear_child_elements(adapted_example, [[:tableHeader],
[:tableBody]])
Expand Down
20 changes: 8 additions & 12 deletions lib/cuke_modeler/adapters/gherkin_20_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,19 +303,15 @@ def adapt_examples(element_ast)
end

def adapt_child_elements(element_ast)
adapted_children = []

element_ast.children.each do |child_element|
adapted_children << if child_element.background
adapt_background(child_element)
elsif child_element.respond_to?(:rule) && child_element.rule
adapt_rule(child_element)
else
adapt_test(child_element)
end
element_ast.children.map do |child_element|
if child_element.background
adapt_background(child_element)
elsif child_element.respond_to?(:rule) && child_element.rule
adapt_rule(child_element)
else
adapt_test(child_element)
end
end

adapted_children
end

def adapt_test(test_ast)
Expand Down
20 changes: 8 additions & 12 deletions lib/cuke_modeler/adapters/gherkin_9_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,15 @@ def adapt_examples(element_ast)
def adapt_child_elements(element_ast)
return [] unless element_ast[:children]

adapted_children = []

element_ast[:children].each do |child_element|
adapted_children << if child_element[:background]
adapt_background(child_element)
elsif child_element[:rule]
adapt_rule(child_element)
else
adapt_test(child_element)
end
element_ast[:children].map do |child_element|
if child_element[:background]
adapt_background(child_element)
elsif child_element[:rule]
adapt_rule(child_element)
else
adapt_test(child_element)
end
end

adapted_children
end

def adapt_test(test_ast)
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/background.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Background < Model
def initialize(source_text = nil)
@steps = []

super(source_text)
super
end

# TODO: Have (all) models be equivalent if they have the same #to_s output. Would
Expand Down Expand Up @@ -91,7 +91,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @name: #{name.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Cell < Model
# @raise [ArgumentError] If *source_text* is not a String
# @return [Cell] A new Cell instance
def initialize(source_text = nil)
super(source_text)
super
end

# Returns a string representation of this model. For a Cell model,
Expand Down Expand Up @@ -52,7 +52,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @value: #{value.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Comment < Model
# @raise [ArgumentError] If *source_text* is not a String
# @return [Comment] A new Comment instance
def initialize(source_text = nil)
super(source_text)
super
end

# Returns a string representation of this model. For a Comment model,
Expand All @@ -50,7 +50,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @text: #{text.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(directory_path = nil)
@feature_files = []
@directories = []

super(directory_path)
super
end

# Returns the name of the modeled directory.
Expand Down Expand Up @@ -81,7 +81,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @path: #{@path.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/doc_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DocString < Model
# @raise [ArgumentError] If *source_text* is not a String
# @return [DocString] A new DocString instance
def initialize(source_text = nil)
super(source_text)
super
end

# Returns a string representation of this model. For a DocString model,
Expand Down Expand Up @@ -56,7 +56,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @content: #{content.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def initialize(source_text = nil)
@tags = []
@rows = []

super(source_text)
super
end

# TODO: Deprecate using symbol keys in a Hash
Expand Down Expand Up @@ -183,7 +183,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @name: #{name.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialize(source_text = nil)
@rules = []
@tests = []

super(source_text)
super
end

# Returns *true* if the feature contains a background, *false* otherwise.
Expand Down Expand Up @@ -150,7 +150,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @name: #{name.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/feature_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(file_path = nil)
@path = file_path
@comments = []

super(file_path)
super
end

# Returns the name of the modeled feature file.
Expand Down Expand Up @@ -81,7 +81,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @path: #{@path.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/outline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def initialize(source_text = nil)
@tags = []
@examples = []

super(source_text)
super
end

# Compares this model with another object. Returns *true* if the two objects
Expand Down Expand Up @@ -102,7 +102,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @name: #{name.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Row < Model
def initialize(source_text = nil)
@cells = []

super(source_text)
super
end

# Returns the model objects that are children of this model. For a
Expand Down Expand Up @@ -65,7 +65,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

cell_output = @cells&.collect(&:value)

Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def initialize(source_text = nil)
@tags = []
@tests = []

super(source_text)
super
end

# Returns *true* if the rule contains a background, *false* otherwise.
Expand Down Expand Up @@ -118,7 +118,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @name: #{@name.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/scenario.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(source_text = nil)
@steps = []
@tags = []

super(source_text)
super
end

# Compares this model with another object. Returns *true* if the two objects
Expand Down Expand Up @@ -96,7 +96,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @name: #{name.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Step < Model
# @raise [ArgumentError] If *source_text* is not a String
# @return [Step] A new Step instance
def initialize(source_text = nil)
super(source_text)
super
end

# Compares this model with another object. Returns *true* if the two objects
Expand Down Expand Up @@ -87,7 +87,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @text: #{@text.inspect}>"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Table < Model
def initialize(source_text = nil)
@rows = []

super(source_text)
super
end

# Returns the model objects that are children of this model. For a
Expand Down Expand Up @@ -64,7 +64,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

row_output = @rows&.collect { |row| row.cells.collect(&:value) }

Expand Down
4 changes: 2 additions & 2 deletions lib/cuke_modeler/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Tag < Model
# @raise [ArgumentError] If *source_text* is not a String
# @return [Tag] A new Tag instance
def initialize(source_text = nil)
super(source_text)
super
end

# Returns a string representation of this model. For a Tag model,
Expand All @@ -47,7 +47,7 @@ def to_s
# the object. Defaults to false.
# @return [String] A string representation of this model
def inspect(verbose: false)
return super(verbose: verbose) if verbose
return super if verbose

"#{super.chop} @name: #{@name.inspect}>"
end
Expand Down
Loading

0 comments on commit 5904578

Please sign in to comment.