Skip to content

Commit ea5744a

Browse files
committed
RuboCop: trivial autocorrections
1 parent 7202fa8 commit ea5744a

File tree

9 files changed

+26
-97
lines changed

9 files changed

+26
-97
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,6 @@ Gemspec/RequireMFA:
3030
Exclude:
3131
- 'ruby-dbus.gemspec'
3232

33-
# Offense count: 1
34-
# This cop supports safe autocorrection (--autocorrect).
35-
# Configuration parameters: EnforcedStyle.
36-
# SupportedStyles: leading, trailing
37-
Layout/LineContinuationLeadingSpace:
38-
Exclude:
39-
- 'lib/dbus/object.rb'
40-
41-
# Offense count: 4
42-
# This cop supports safe autocorrection (--autocorrect).
43-
# Configuration parameters: EnforcedStyle.
44-
# SupportedStyles: space, no_space
45-
Layout/LineContinuationSpacing:
46-
Exclude:
47-
- 'lib/dbus/proxy_object.rb'
48-
- 'spec/property_spec.rb'
49-
50-
# Offense count: 1
51-
# This cop supports safe autocorrection (--autocorrect).
52-
# Configuration parameters: EnforcedStyle, IndentationWidth.
53-
# SupportedStyles: aligned, indented
54-
Layout/LineEndStringConcatenationIndentation:
55-
Exclude:
56-
- 'lib/dbus/message.rb'
57-
58-
# Offense count: 9
59-
# This cop supports safe autocorrection (--autocorrect).
60-
Lint/AmbiguousOperatorPrecedence:
61-
Exclude:
62-
- 'lib/dbus/marshall.rb'
63-
- 'lib/dbus/proxy_object.rb'
64-
- 'spec/data_spec.rb'
65-
6633
# Offense count: 3
6734
# Configuration parameters: AllowComments, AllowEmptyLambdas.
6835
Lint/EmptyBlock:
@@ -77,29 +44,6 @@ Lint/IncompatibleIoSelectWithFiberScheduler:
7744
Exclude:
7845
- 'lib/dbus/message_queue.rb'
7946

80-
# Offense count: 2
81-
# This cop supports safe autocorrection (--autocorrect).
82-
Lint/RedundantCopDisableDirective:
83-
Exclude:
84-
- 'lib/dbus/object.rb'
85-
- 'lib/dbus/proxy_object.rb'
86-
87-
# Offense count: 2
88-
# This cop supports safe autocorrection (--autocorrect).
89-
# Configuration parameters: EnforcedStyle.
90-
# SupportedStyles: strict, consistent
91-
Lint/SymbolConversion:
92-
Exclude:
93-
- 'lib/dbus/object.rb'
94-
95-
# Offense count: 1
96-
# This cop supports safe autocorrection (--autocorrect).
97-
# Configuration parameters: Keywords, RequireColon.
98-
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE
99-
Style/CommentAnnotation:
100-
Exclude:
101-
- 'spec/node_spec.rb'
102-
10347
# Offense count: 3
10448
# This cop supports unsafe autocorrection (--autocorrect-all).
10549
Style/EnvHome:
@@ -175,13 +119,6 @@ Style/RedundantEach:
175119
Exclude:
176120
- 'spec/type_spec.rb'
177121

178-
# Offense count: 4
179-
# This cop supports safe autocorrection (--autocorrect).
180-
Style/RedundantLineContinuation:
181-
Exclude:
182-
- 'lib/dbus/type.rb'
183-
- 'spec/property_spec.rb'
184-
185122
# Offense count: 3
186123
# This cop supports safe autocorrection (--autocorrect).
187124
Style/RedundantRegexpArgument:

lib/dbus/marshall.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def num_align(num, alignment)
180180
case alignment
181181
when 1, 2, 4, 8
182182
bits = alignment - 1
183-
num + bits & ~bits
183+
(num + bits) & ~bits
184184
else
185185
raise ArgumentError, "Unsupported alignment #{alignment}"
186186
end

lib/dbus/message.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def initialize(mtype = INVALID)
103103

104104
def to_s
105105
"#{message_type} sender=#{sender} -> dest=#{destination} " \
106-
"serial=#{serial} reply_serial=#{reply_serial} " \
107-
"path=#{path}; interface=#{interface}; member=#{member} " \
108-
"error_name=#{error_name}"
106+
"serial=#{serial} reply_serial=#{reply_serial} " \
107+
"path=#{path}; interface=#{interface}; member=#{member} " \
108+
"error_name=#{error_name}"
109109
end
110110

111111
# @return [String] name of message type, as used in match rules:

lib/dbus/object.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def self.dbus_interface(name)
116116

117117
# Forgetting to declare the interface for a method/signal/property
118118
# is a ScriptError.
119-
class UndefinedInterface < ScriptError # rubocop:disable Lint/InheritException
119+
class UndefinedInterface < ScriptError
120120
def initialize(sym)
121121
super "No interface specified for #{sym}. Enclose it in dbus_interface."
122122
end
@@ -253,7 +253,7 @@ def self.dbus_reader(ruby_name, type, dbus_name: nil, emits_changed_signal: nil)
253253
property = Property.new(dbus_name, type, :read, ruby_name: ruby_name)
254254
@@cur_intf.define(property)
255255

256-
ruby_name_eq = "#{ruby_name}=".to_sym
256+
ruby_name_eq = :"#{ruby_name}="
257257
return unless method_defined?(ruby_name_eq)
258258

259259
dbus_watcher(ruby_name, dbus_name: dbus_name, emits_changed_signal: emits_changed_signal)
@@ -294,7 +294,7 @@ def self.dbus_watcher(ruby_name, dbus_name: nil, emits_changed_signal: nil)
294294
interface_name = @@cur_intf.name
295295

296296
ruby_name = ruby_name.to_s.sub(/=$/, "").to_sym
297-
ruby_name_eq = "#{ruby_name}=".to_sym
297+
ruby_name_eq = :"#{ruby_name}="
298298
original_ruby_name_eq = "_original_#{ruby_name_eq}"
299299

300300
dbus_name = make_dbus_name(ruby_name, dbus_name: dbus_name)
@@ -517,8 +517,8 @@ def interfaces_and_properties
517517
typed_value = Data.make_typed(property.type, value)
518518
p_hash[p_name.to_s] = typed_value
519519
rescue StandardError
520-
DBus.logger.debug "Property '#{interface_name}.#{p_name}' (on object '#{@path}')" \
521-
" has raised during GetAll, omitting it"
520+
DBus.logger.debug "Property '#{interface_name}.#{p_name}' (on object '#{@path}') " \
521+
"has raised during GetAll, omitting it"
522522
end
523523
end
524524

lib/dbus/proxy_object.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def has_iface?(name)
129129
# @return [void]
130130
def on_signal(name, &block)
131131
unless @default_iface && has_iface?(@default_iface)
132-
raise NoMethodError, "undefined signal #{OPEN_QUOTE}#{name}' for DBus interface "\
132+
raise NoMethodError, "undefined signal #{OPEN_QUOTE}#{name}' for DBus interface " \
133133
"#{OPEN_QUOTE}#{@default_iface}' on object #{OPEN_QUOTE}#{@path}'"
134134
end
135135

@@ -139,13 +139,6 @@ def on_signal(name, &block)
139139
####################################################
140140
private
141141

142-
# rubocop:disable Lint/MissingSuper
143-
# as this should forward everything
144-
#
145-
# https://github.com/rubocop-hq/ruby-style-guide#no-method-missing
146-
# and http://blog.marc-andre.ca/2010/11/15/methodmissing-politely/
147-
# have a point to be investigated
148-
149142
# Handles all unkown methods, mostly to route method calls to the
150143
# default interface.
151144
def method_missing(name, *args, &reply_handler)
@@ -154,7 +147,7 @@ def method_missing(name, *args, &reply_handler)
154147
# - di not specified
155148
# TODO
156149
# - di is specified but not found in introspection data
157-
raise NoMethodError, "undefined method #{OPEN_QUOTE}#{name}' for DBus interface "\
150+
raise NoMethodError, "undefined method #{OPEN_QUOTE}#{name}' for DBus interface " \
158151
"#{OPEN_QUOTE}#{@default_iface}' on object #{OPEN_QUOTE}#{@path}'"
159152
end
160153

@@ -166,16 +159,15 @@ def method_missing(name, *args, &reply_handler)
166159
raise unless e.to_s =~ /undefined method #{OPEN_QUOTE}#{name}'/
167160

168161
# BTW e.exception("...") would preserve the class.
169-
raise NoMethodError, "undefined method #{OPEN_QUOTE}#{name}' for DBus interface "\
162+
raise NoMethodError, "undefined method #{OPEN_QUOTE}#{name}' for DBus interface " \
170163
"#{OPEN_QUOTE}#{@default_iface}' on object #{OPEN_QUOTE}#{@path}'"
171164
end
172165
end
173-
# rubocop:enable Lint/MissingSuper
174166

175167
def respond_to_missing?(name, _include_private = false)
176-
@default_iface &&
168+
(@default_iface &&
177169
has_iface?(@default_iface) &&
178-
@interfaces[@default_iface].methods.key?(name) or super
170+
@interfaces[@default_iface].methods.key?(name)) or super
179171
end
180172
end
181173
end

lib/dbus/type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def <<(item)
163163
if @sigtype == DICT_ENTRY
164164
case @members.size
165165
when 2
166-
raise SignatureException, \
166+
raise SignatureException,
167167
"DICT_ENTRY must have 2 subtypes, found 3 or more: #{@members.inspect} << #{item.inspect}"
168168
when 0
169169
if [STRUCT, ARRAY, DICT_ENTRY, VARIANT].member?(item.sigtype)

spec/data_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,43 +223,43 @@
223223

224224
describe DBus::Data::Byte do
225225
include_examples "#== and #eql? work for basic types"
226-
include_examples "constructor accepts numeric range", 0, 2**8 - 1
226+
include_examples "constructor accepts numeric range", 0, (2**8) - 1
227227
include_examples "constructor accepts plain or typed values", 42
228228
end
229229

230230
describe DBus::Data::Int16 do
231231
include_examples "#== and #eql? work for basic types"
232-
include_examples "constructor accepts numeric range", -2**15, 2**15 - 1
232+
include_examples "constructor accepts numeric range", -2**15, (2**15) - 1
233233
include_examples "constructor accepts plain or typed values", 42
234234
end
235235

236236
describe DBus::Data::UInt16 do
237237
include_examples "#== and #eql? work for basic types"
238-
include_examples "constructor accepts numeric range", 0, 2**16 - 1
238+
include_examples "constructor accepts numeric range", 0, (2**16) - 1
239239
include_examples "constructor accepts plain or typed values", 42
240240
end
241241

242242
describe DBus::Data::Int32 do
243243
include_examples "#== and #eql? work for basic types"
244-
include_examples "constructor accepts numeric range", -2**31, 2**31 - 1
244+
include_examples "constructor accepts numeric range", -2**31, (2**31) - 1
245245
include_examples "constructor accepts plain or typed values", 42
246246
end
247247

248248
describe DBus::Data::UInt32 do
249249
include_examples "#== and #eql? work for basic types"
250-
include_examples "constructor accepts numeric range", 0, 2**32 - 1
250+
include_examples "constructor accepts numeric range", 0, (2**32) - 1
251251
include_examples "constructor accepts plain or typed values", 42
252252
end
253253

254254
describe DBus::Data::Int64 do
255255
include_examples "#== and #eql? work for basic types"
256-
include_examples "constructor accepts numeric range", -2**63, 2**63 - 1
256+
include_examples "constructor accepts numeric range", -2**63, (2**63) - 1
257257
include_examples "constructor accepts plain or typed values", 42
258258
end
259259

260260
describe DBus::Data::UInt64 do
261261
include_examples "#== and #eql? work for basic types"
262-
include_examples "constructor accepts numeric range", 0, 2**64 - 1
262+
include_examples "constructor accepts numeric range", 0, (2**64) - 1
263263
include_examples "constructor accepts plain or typed values", 42
264264
end
265265

spec/node_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
let(:manager_path) { "/org/example/FooManager" }
2626
let(:child_paths) do
2727
[
28-
# note that "/org/example/FooManager/good"
28+
# NOTE: "/org/example/FooManager/good"
2929
# is a path under a managed object but there is no object there
3030
"/org/example/FooManager/good/1",
3131
"/org/example/FooManager/good/2",

spec/property_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
context "when reading a property fails" do
3535
it "gets an error, mentioning the qualified property name" do
36-
expect { @iface["Explosive"] } \
36+
expect { @iface["Explosive"] }
3737
.to raise_error(DBus::Error, /getting.*SampleInterface.Explosive.*Something failed/)
3838
end
3939
end
@@ -50,14 +50,14 @@
5050

5151
context "when writing a read-only property" do
5252
it "gets an error, mentioning the qualified property name" do
53-
expect { @iface["ReadMe"] = "WROTE" } \
53+
expect { @iface["ReadMe"] = "WROTE" }
5454
.to raise_error(DBus::Error, /SampleInterface.ReadMe.*not writable/)
5555
end
5656
end
5757

5858
context "when writing a property fails" do
5959
it "gets an error, mentioning the qualified property name" do
60-
expect { @iface["WriteMe"] = "Bruno is a city in Czechia" } \
60+
expect { @iface["WriteMe"] = "Bruno is a city in Czechia" }
6161
.to raise_error(DBus::Error, /setting.*SampleInterface.WriteMe/)
6262
end
6363
end

0 commit comments

Comments
 (0)