Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.60.2
1.85.0
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Style/MultilineMemoization:
Style/StderrPuts:
Enabled: false

Naming/PredicateName:
Naming/PredicatePrefix:
Enabled: false

# Lots of false positive because of our class_eval-like blocks like e.g.
Expand All @@ -54,7 +54,7 @@ Metrics/ModuleLength:
- '**/test/**/*_test.rb'

Metrics/BlockLength:
ExcludedMethods:
AllowedMethods:
- describe
- it

Expand Down
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ Naming/MethodParameterName:
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Naming/PredicatePrefix:
Exclude:
- 'spec/**/*'
- 'lib/roby/actions/action.rb'
Expand Down
4 changes: 2 additions & 2 deletions benchmark/ruby/set_intersect_vs_hash_merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def intersect_with_merge(other)
left = Set.new
right = Set.new
count.times do
left << (elements[rand(count * 2)])
right << (elements[rand(count * 2)])
left << elements[rand(count * 2)]
right << elements[rand(count * 2)]
end
sets << [left, right]
end
Expand Down
4 changes: 2 additions & 2 deletions benchmark/ruby/yield_vs_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def call_block(enum, &block)
call_block(enum) { |v| }
end
x.report(format("yield - %<calls>.0e calls", calls: cost_of_call)) do
cost_of_call.times { call_yield((1..1)) { |v| } }
cost_of_call.times { call_yield(1..1) { |v| } }
end
x.report(format("block - %<calls>.0e calls", calls: cost_of_call)) do
cost_of_call.times { call_block((1..1)) { |v| } }
cost_of_call.times { call_block(1..1) { |v| } }
end
x.report(format("yield - %<calls>.0e calls and %<elements>.0e elements",
calls: call_count, elements: call_enum.size)) do
Expand Down
2 changes: 0 additions & 2 deletions lib/roby/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2690,8 +2690,6 @@ def find_dirs(*dir_path)
raise ArgumentError, "expected either :specific_first or :specific_last for the :order argument, but got #{options[:order]}"
end

relative_paths = []

base_dir_path = dir_path.dup
base_dir_path.delete_if { |p| p =~ /ROBOT/ }
relative_paths = [base_dir_path]
Expand Down
1 change: 0 additions & 1 deletion lib/roby/app/scripts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def run(
*args, banner: "",
option_parser: default_option_parser(banner: banner)
)

app.guess_app_dir
app.shell
app.single
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/droby/plan_rebuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def process_one_event(m, sec, usec, args)
case obj
when NilClass then "nil"
when Time then obj.to_hms
else (obj.to_s rescue "failed_to_s")
else obj.to_s rescue "failed_to_s"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/roby/event_constraints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def explain_static(task)
def has_atomic_predicate?(pred)
pred = pred.to_unbound_task_predicate
each_atomic_predicate do |p|
return(true) if p == pred
return true if p == pred
end
false
end
Expand Down
3 changes: 1 addition & 2 deletions lib/roby/execution_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ def process_waiting_work

unhandled_errors = finished.find_all do |work|
work.rejected? &&
(work.respond_to?(:handled_error?) && !work.handled_error?)
work.respond_to?(:handled_error?) && !work.handled_error?
end

unhandled_errors.each do |work|
Expand Down Expand Up @@ -1574,7 +1574,6 @@ def initialize(called_generators = Set.new,
handled_errors = [],
inhibited_errors = [],
framework_errors = [])

self.called_generators = called_generators.to_set
self.emitted_events = emitted_events.to_set
self.kill_tasks = kill_tasks.to_set
Expand Down
4 changes: 2 additions & 2 deletions lib/roby/gui/chronicle_widget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,9 @@ def update_current_tasks(force: false)

start_time, end_time = displayed_time_range

if start_time && (show_mode == :running || show_mode == :current)
if start_time && %i[running current].include?(show_mode)
current_tasks = current_tasks.find_all do |t|
(t.start_time && t.start_time < end_time) &&
t.start_time && t.start_time < end_time &&
(!t.end_time || t.end_time > start_time)
end

Expand Down
3 changes: 1 addition & 2 deletions lib/roby/gui/model_views/action_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def render(model, options = {})

def self.find_definition_place(model)
location = model.definition_location.find do |location|
break if location.label == "require" ||
location.label == "using_task_library"
break if %w[require using_task_library].include?(location.label)

Roby.app.app_file?(location.absolute_path)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/gui/plan_dot_layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def self.parse_dot_layout(dot_layout, options = {})
dot_layout.each do |line|
line.chomp!
full_line << line.strip
if line[-1] == "\\" || line[-1] == ","
if ["\\", ","].include?(line[-1])
full_line.chomp!
next
end
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/gui/plan_rebuilder_widget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def self.analyze(plan_rebuilder, logfile, until_cycle: nil)

start = Time.now
puts "log file is #{(end_time - start_time).ceil}s long"
dialog = Qt::ProgressDialog.new("Analyzing log file", "Quit", 0, (end_time - start_time))
dialog = Qt::ProgressDialog.new("Analyzing log file", "Quit", 0, end_time - start_time)
dialog.setWindowModality(Qt::WindowModal)
dialog.show

Expand Down
1 change: 0 additions & 1 deletion lib/roby/interface/rest/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def initialize(app,
roby_execute: true,
middlewares: VERBOSE_MIDDLEWARES,
**thin_options)

@app = app
@host = host
@main_route = main_route
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/interface/v1/shell_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def method_missing(m, *args)
nil
else
begin
call Hash[], [], m, *args
call({}, [], m, *args)
rescue NoMethodError => e
if e.message =~ /undefined method .#{m}./
puts "invalid command name #{m}, call 'help' for more information"
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/interface/v2/shell_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def method_missing(m, *args)
nil
else
begin
call Hash[], [], m, *args
call({}, [], m, *args)
rescue NoMethodError => e
if e.message =~ /undefined method .#{m}./
puts "invalid command name #{m}, call 'help' for more information"
Expand Down
4 changes: 2 additions & 2 deletions lib/roby/plan_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def merged_relations(enumerator, intrusive, &block)

# If this object is executable
def executable?
@executable || (@executable.nil? && !garbage? && plan && plan.executable?)
@executable || (@executable.nil? && !garbage? && plan&.executable?)
end

# @!method garbage?
Expand Down Expand Up @@ -619,7 +619,7 @@ def finalized!(timestamp = nil)
def when_finalized(options = {}, &block)
options = InstanceHandler.validate_options options
check_arity(block, 1)
finalization_handlers << InstanceHandler.new(block, (options[:on_replace] == :copy))
finalization_handlers << InstanceHandler.new(block, options[:on_replace] == :copy)
end

# True if this plan object has been finalized (i.e. removed from plan),
Expand Down
1 change: 0 additions & 1 deletion lib/roby/relations/graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def initialize(
noinfo: !self.class.embeds_info?,
subsets: Set.new
)

@observer = observer
@distribute = distribute
@dag = dag
Expand Down
3 changes: 1 addition & 2 deletions lib/roby/relations/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.new_relation_graph_mapping
if k
if k.kind_of?(Class)
known_relations = h.each_key.find_all { |rel| rel.kind_of?(Class) }
.map { |o| o.name.to_s }.join(", ")
.map { |o| o.name.to_s }.join(", ")
raise ArgumentError,
"#{k} is not a known relation (known relations "\
"are #{known_relations})"
Expand Down Expand Up @@ -213,7 +213,6 @@ def relation(relation_name,
noinfo: false,
subsets: Set.new,
**submodel_options)

if block_given?
raise ArgumentError, "calling relation with a block is not supported anymore. Reopen #{const_name}::Extension after the relation call to add helper methods"
elsif strong && weak
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/standard_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def initialize(failure_point)
@failed_task = failure_point
end

if !@failed_task && @failed_generator && @failed_generator.respond_to?(:task)
if !@failed_task && @failed_generator.respond_to?(:task)
@failed_task = failed_generator.task
end
if !@failed_task && !@failed_generator
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def self.error_deprecated(msg, caller_depth = 1)
#
# which('ruby') #=> /usr/bin/ruby
def self.find_in_path(cmd)
return cmd if cmd =~ (/#{File::SEPARATOR}/) && File.file?(cmd)
return cmd if cmd =~ /#{File::SEPARATOR}/ && File.file?(cmd)

exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
Expand Down
4 changes: 2 additions & 2 deletions lib/roby/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ def execute(options = {}, &block)

check_arity(block, 1)
@execute_handlers <<
InstanceHandler.new(block, (options[:on_replace] == :copy))
InstanceHandler.new(block, options[:on_replace] == :copy)
ensure_poll_handler_called
end

Expand All @@ -1194,7 +1194,7 @@ def poll(options = {}, &block)
)

check_arity(block, 1)
handler = InstanceHandler.new(block, (options[:on_replace] == :copy))
handler = InstanceHandler.new(block, options[:on_replace] == :copy)
@poll_handlers << handler
ensure_poll_handler_called
Roby.disposable { @poll_handlers.delete(handler) }
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/test/teardown_plans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def teardown_registered_plans(
unless success
Roby.warn "clean teardown failed, trying to force-kill all tasks"
teardown_forced_killall(
teardown_warn, (teardown_fail - teardown_force), teardown_poll
teardown_warn, teardown_fail - teardown_force, teardown_poll
)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/roby/test/testcase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def self.apply_robot_setup

name, kind, block = app_setup
# Ignore the test suites which use a different robot
if name || kind && (app.robot_name &&
(app.robot_name != name || app.robot_type != kind))
if name || kind && app.robot_name &&
(app.robot_name != name || app.robot_type != kind)
Test.info "ignoring #{self} as it is for robot #{name} and we are running for #{app.robot_name}:#{app.robot_type}"
return
end
Expand Down
4 changes: 2 additions & 2 deletions lib/roby/test/tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def stats(samples, spec)
fields.each do |name|
next unless value = sample[name]

unless spec[name] == :absolute || spec[name] == :absolute_rate
unless %i[absolute absolute_rate].include?(spec[name])
if last_sample && last_sample[name]
sample[name] -= last_sample[name]
else
Expand All @@ -118,7 +118,7 @@ def stats(samples, spec)
fields.each do |name|
next unless value = sample[name]

if spec[name] == :rate || spec[name] == :absolute_rate
if %i[rate absolute_rate].include?(spec[name])
if sample.dt
sample[name] = value / sample.dt
else
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/test/validate_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def assert_transitions_to_state(state_name, timeout: 5)
@state_machines.each do |m|
m.on_transition do |_, new_state|
done ||= matchers.any? do
(_1 === new_state.name)
_1 === new_state.name
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/roby/yard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def process
controlable = false
if statement.parameters[1]
statement.parameters[1].jump(:assoc).to_a.each_slice(2) do |key, value|
if key.source == "controlable:" || key.source == "command:"
if ["controlable:", "command:"].include?(key.source)
controlable = true
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/app/cucumber/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module App
describe "unit validation" do
it "raises UnexpectedArgument if strict is set and the argument does not have a quantity" do
assert_raises(CucumberHelpers::UnexpectedArgument) do
CucumberHelpers.parse_arguments("x=20m", Hash[], strict: true)
CucumberHelpers.parse_arguments("x=20m", {}, strict: true)
end
end
it "validates that the unit and the quantity match" do
Expand Down
2 changes: 1 addition & 1 deletion test/interface/test_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def an_action; end
end
it "should not return job tasks that have no job ID" do
plan.add(job_task_m.new)
assert_equal Hash[], interface.jobs
assert_equal({}, interface.jobs)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/interface/v2/test_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ module V2
end

it "returns ranges as-is" do
assert_equal (0..20), @channel.marshal_filter_object((0..20))
assert_equal (0..20), @channel.marshal_filter_object(0..20)
end

it "returns any objects whose class was set up with "\
Expand Down
2 changes: 1 addition & 1 deletion test/relations/test_directed_relation_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Relations

before do
@graph_m = graph_m = Graph.new_submodel
@graph = graph = graph_m.new
@graph = graph = graph_m.new
@vertex_m = Class.new(Object) do
include DirectedRelationSupport
define_method(:relation_graphs) { Hash[graph_m => graph] }
Expand Down
8 changes: 4 additions & 4 deletions test/relations/test_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,31 @@ module Relations
end

it "moves the in-edges of the old vertex to the new vertex" do
graph.add_edge(parent, old, (info = Object.new))
graph.add_edge(parent, old, info = Object.new)
graph.replace_vertex(old, new)
assert graph.has_edge?(parent, new)
assert_same info, graph.edge_info(parent, new)
assert !graph.has_edge?(parent, old)
end

it "does not touch the existing in-edges of the new vertex" do
graph.add_edge(parent, new, (info = Object.new))
graph.add_edge(parent, new, info = Object.new)
graph.replace_vertex(old, new)
assert graph.has_edge?(parent, new)
assert_same info, graph.edge_info(parent, new)
assert !graph.has_edge?(parent, old)
end

it "moves the out-edges of the old vertex to the new vertex" do
graph.add_edge(old, child, (info = Object.new))
graph.add_edge(old, child, info = Object.new)
graph.replace_vertex(old, new)
assert graph.has_edge?(new, child)
assert_same info, graph.edge_info(new, child)
assert !graph.has_edge?(old, child)
end

it "does not touch the existing out-edges of the new vertex" do
graph.add_edge(new, child, (info = Object.new))
graph.add_edge(new, child, info = Object.new)
graph.replace_vertex(old, new)
assert graph.has_edge?(new, child)
assert_same info, graph.edge_info(new, child)
Expand Down
Loading