Skip to content

Commit b43be59

Browse files
committed
bump rubocop
1 parent f967e73 commit b43be59

11 files changed

+52
-7
lines changed

.rubocop.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ AllCops:
77

88
# inherit_from: .rubocop_todo.yml
99

10+
# TODO: stuff I actually want to fix
11+
Style/RescueStandardError:
12+
Enabled: false
13+
14+
Security/Open:
15+
Enabled: false
16+
17+
1018
# Extra lines for readability
1119
Layout/EmptyLinesAroundClassBody:
1220
Enabled: false
@@ -79,7 +87,10 @@ Style/RedundantSelf:
7987
Style/StringLiterals:
8088
Enabled: false
8189

82-
Style/TrailingCommaInLiteral:
90+
Style/TrailingCommaInArrayLiteral:
91+
Enabled: false
92+
93+
Style/TrailingCommaInHashLiteral:
8394
Enabled: false
8495

8596
Style/SymbolArray:

arduino_ci.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
3030

3131
spec.add_development_dependency "bundler", "~> 1.15"
3232
spec.add_development_dependency "rspec", "~> 3.0"
33-
spec.add_development_dependency 'rubocop', '~>0.49.0'
33+
spec.add_development_dependency 'rubocop', '~>0.59.0'
3434
spec.add_development_dependency 'yard', '~>0.9.11'
3535
end

exe/arduino_ci_remote.rb

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def assured_platform(purpose, name, config)
8484
attempt_multiline("Checking #{gcc_binary} version") do
8585
version = cpp_library.gcc_version(gcc_binary)
8686
next nil unless version
87+
8788
puts version.split("\n").map { |l| " #{l}" }.join("\n")
8889
version
8990
end

lib/arduino_ci/arduino_cmd.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ArduinoCmd
1414
# @return [String] the text of the command line flag (`$2` in this case)
1515
def self.flag(name, text = nil)
1616
text = "(flag #{name} not defined)" if text.nil?
17-
self.class_eval("def flag_#{name};\"#{text}\";end")
17+
self.class_eval("def flag_#{name};\"#{text}\";end", __FILE__, __LINE__)
1818
end
1919

2020
# the path to the Arduino executable
@@ -75,6 +75,7 @@ def lib_dir
7575
def _prefs_raw
7676
resp = run_and_capture(flag_get_pref)
7777
return nil unless resp[:success]
78+
7879
resp[:out]
7980
end
8081

@@ -83,6 +84,7 @@ def _prefs_raw
8384
def prefs
8485
prefs_raw = _prefs_raw unless @prefs_fetched
8586
return nil if prefs_raw.nil?
87+
8688
@prefs_cache = parse_pref_string(prefs_raw)
8789
@prefs_cache.clone
8890
end
@@ -224,9 +226,11 @@ def use_board(boardname)
224226
# @return [bool] whether the command succeeded
225227
def use_board!(boardname)
226228
return true if use_board(boardname)
229+
227230
boardfamily = boardname.split(":")[0..1].join(":")
228231
puts "Board '#{boardname}' not found; attempting to install '#{boardfamily}'"
229232
return false unless install_boards(boardfamily) # guess board family from first 2 :-separated fields
233+
230234
use_board(boardname)
231235
end
232236

@@ -264,6 +268,7 @@ def install_local_library(path)
264268
# maybe it's a symlink? that would be OK
265269
if File.symlink?(destination_path)
266270
return destination_path if File.readlink(destination_path) == realpath
271+
267272
@last_msg = "#{uhoh} and it's not symlinked to #{realpath}"
268273
return nil
269274
end
@@ -282,6 +287,7 @@ def install_local_library(path)
282287
def library_examples(installed_library_path)
283288
example_path = File.join(installed_library_path, "examples")
284289
return [] unless File.exist?(example_path)
290+
285291
examples = Pathname.new(example_path).children.select(&:directory?).map(&:to_path).map(&File.method(:basename))
286292
files = examples.map do |e|
287293
proj_file = File.join(example_path, e, "#{e}.ino")

lib/arduino_ci/arduino_cmd_linux.rb

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def _prefs_raw
2828
resp = run_and_capture(flag_get_pref)
2929
@prefs_response_time = Time.now - start
3030
return nil unless resp[:success]
31+
3132
resp[:out]
3233
end
3334

lib/arduino_ci/arduino_downloader.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def self.autolocated_executable
3535
locations.each do |loc|
3636
next if loc.nil?
3737
next unless File.exist? loc
38+
3839
return loc
3940
end
4041
nil
@@ -51,6 +52,7 @@ def self.autolocated_installation
5152
locations.each do |loc|
5253
next if loc.nil?
5354
next unless File.exist? loc
55+
5456
return loc
5557
end
5658
nil
@@ -132,7 +134,7 @@ def download
132134
open(package_url, ssl_verify_mode: 0, progress_proc: dot_printer) do |url|
133135
File.open(package_file, 'wb') { |file| file.write(url.read) }
134136
end
135-
rescue Net::OpenTimeout => e, Net::ReadTimeout => e
137+
rescue Net::OpenTimeout, Net::ReadTimeout => e
136138
puts "Arduino force-install failed to download #{package_url}: #{e}"
137139
end
138140

lib/arduino_ci/arduino_downloader_linux.rb

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def extracted_file
4747
def self.existing_installation
4848
exe = self.existing_executable
4949
return nil if exe.nil?
50+
5051
File.dirname(exe) # it's not really this
5152
# but for this platform it doesn't really matter
5253
end
@@ -79,6 +80,7 @@ def self.force_installed_executable
7980
end
8081
forced_arduino = File.join(self.force_install_location, "arduino")
8182
return forced_arduino if File.exist? forced_arduino
83+
8284
nil
8385
end
8486

lib/arduino_ci/arduino_downloader_windows.rb

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def extracted_file
7373
def self.existing_installation
7474
exe = self.existing_executable
7575
return nil if exe.nil?
76+
7677
File.dirname(exe)
7778
end
7879

@@ -94,6 +95,7 @@ def self.existing_executable
9495
def self.force_installed_executable
9596
exe = File.join(self.force_install_location, "arduino_debug.exe")
9697
return nil if exe.nil?
98+
9799
exe
98100
end
99101

lib/arduino_ci/arduino_installation.rb

+2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ def autolocate
2929
when :linux then
3030
loc = ArduinoDownloaderLinux.autolocated_executable
3131
return nil if loc.nil?
32+
3233
ret = ArduinoCmdLinux.new
3334
ret.base_cmd = [loc]
3435
when :windows then
3536
loc = ArduinoDownloaderWindows.autolocated_executable
3637
return nil if loc.nil?
38+
3739
ret = ArduinoCmdWindows.new
3840
ret.base_cmd = [loc]
3941
end

lib/arduino_ci/ci_config.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class << self
5454
# @return [ArudinoCI::CIConfig] The configuration with defaults filled in
5555
def default
5656
ret = new
57-
ret.load_yaml(File.expand_path("../../../misc/default.yml", __FILE__))
57+
ret.load_yaml(File.expand_path("../../misc/default.yml", __dir__))
5858
ret
5959
end
6060
end
@@ -85,6 +85,7 @@ def deep_clone(hash)
8585
# @return [Hash] a copy, containing only expected & valid data
8686
def validate_data(rootname, source, schema)
8787
return nil if source.nil?
88+
8889
good_data = {}
8990
source.each do |key, value|
9091
ksym = key.to_sym
@@ -186,6 +187,7 @@ def from_example(example_path)
186187
def platform_definition(platform_name)
187188
defn = @platform_info[platform_name]
188189
return nil if defn.nil?
190+
189191
deep_clone(defn)
190192
end
191193

@@ -195,39 +197,45 @@ def platform_definition(platform_name)
195197
# @return [String] the URL defined for this package
196198
def package_url(package)
197199
return nil if @package_info[package].nil?
200+
198201
@package_info[package][:url]
199202
end
200203

201204
# compilers to build (unit tests) with
202205
# @return [Array<String>] The compiler binary names (e.g. g++) to build with
203206
def compilers_to_use
204207
return [] if @unittest_info[:compilers].nil?
208+
205209
@unittest_info[:compilers]
206210
end
207211

208212
# platforms to build [the examples on]
209213
# @return [Array<String>] The platforms to build
210214
def platforms_to_build
211215
return [] if @compile_info[:platforms].nil?
216+
212217
@compile_info[:platforms]
213218
end
214219

215220
# platforms to unit test [the tests on]
216221
# @return [Array<String>] The platforms to unit test on
217222
def platforms_to_unittest
218223
return [] if @unittest_info[:platforms].nil?
224+
219225
@unittest_info[:platforms]
220226
end
221227

222228
# @return [Array<String>] The aux libraries required for building/verifying
223229
def aux_libraries_for_build
224230
return [] if @compile_info[:libraries].nil?
231+
225232
@compile_info[:libraries]
226233
end
227234

228235
# @return [Array<String>] The aux libraries required for unit testing
229236
def aux_libraries_for_unittest
230237
return [] if @unittest_info[:libraries].nil?
238+
231239
@unittest_info[:libraries]
232240
end
233241

@@ -236,6 +244,7 @@ def aux_libraries_for_unittest
236244
# @return [Array<String>] files that match the select/reject criteria
237245
def allowable_unittest_files(paths)
238246
return paths if @unittest_info[:testfiles].nil?
247+
239248
ret = paths
240249
unless @unittest_info[:testfiles][:select].nil? || @unittest_info[:testfiles][:select].empty?
241250
ret = ret.select { |p| unittest_info[:testfiles][:select].any? { |glob| File.fnmatch(glob, File.basename(p)) } }
@@ -253,6 +262,7 @@ def gcc_config(platform_name)
253262
plat = @platform_info[platform_name]
254263
return {} if plat.nil?
255264
return {} if plat[:gcc].nil?
265+
256266
plat[:gcc]
257267
end
258268
end

lib/arduino_ci/cpp_library.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
HPP_EXTENSIONS = [".hpp", ".hh", ".h", ".hxx", ".h++"].freeze
55
CPP_EXTENSIONS = [".cpp", ".cc", ".c", ".cxx", ".c++"].freeze
6-
ARDUINO_HEADER_DIR = File.expand_path("../../../cpp/arduino", __FILE__)
7-
UNITTEST_HEADER_DIR = File.expand_path("../../../cpp/unittest", __FILE__)
6+
ARDUINO_HEADER_DIR = File.expand_path("../../cpp/arduino", __dir__)
7+
UNITTEST_HEADER_DIR = File.expand_path("../../cpp/unittest", __dir__)
88

99
module ArduinoCI
1010

@@ -50,6 +50,7 @@ def vendor_bundle?(path)
5050
real = File.join(File.realpath(@base_dir), "vendor")
5151
return true if path.start_with?(base)
5252
return true if path.start_with?(real)
53+
5354
false
5455
end
5556

@@ -58,6 +59,7 @@ def vendor_bundle?(path)
5859
# @return [Array<String>] The paths of the found files
5960
def cpp_files_in(some_dir)
6061
return [] unless File.exist?(some_dir)
62+
6163
real = File.realpath(some_dir)
6264
files = Find.find(real).reject { |path| File.directory?(path) }
6365
cpp = files.select { |path| CPP_EXTENSIONS.include?(File.extname(path)) }
@@ -130,6 +132,7 @@ def run_gcc(gcc_binary, *args, **kwargs)
130132
# @return [String] the version reported by `gcc -v`
131133
def gcc_version(gcc_binary)
132134
return nil unless run_gcc(gcc_binary, "-v")
135+
133136
@last_err
134137
end
135138

@@ -159,6 +162,7 @@ def include_args(aux_libraries)
159162
# @return [Array<String>] GCC command-line flags
160163
def feature_args(ci_gcc_config)
161164
return [] if ci_gcc_config[:features].nil?
165+
162166
ci_gcc_config[:features].map { |f| "-f#{f}" }
163167
end
164168

@@ -167,6 +171,7 @@ def feature_args(ci_gcc_config)
167171
# @return [Array<String>] GCC command-line flags
168172
def warning_args(ci_gcc_config)
169173
return [] if ci_gcc_config[:warnings].nil?
174+
170175
ci_gcc_config[:features].map { |w| "-W#{w}" }
171176
end
172177

@@ -175,6 +180,7 @@ def warning_args(ci_gcc_config)
175180
# @return [Array<String>] GCC command-line flags
176181
def define_args(ci_gcc_config)
177182
return [] if ci_gcc_config[:defines].nil?
183+
178184
ci_gcc_config[:defines].map { |d| "-D#{d}" }
179185
end
180186

@@ -183,6 +189,7 @@ def define_args(ci_gcc_config)
183189
# @return [Array<String>] GCC command-line flags
184190
def flag_args(ci_gcc_config)
185191
return [] if ci_gcc_config[:flags].nil?
192+
186193
ci_gcc_config[:flags]
187194
end
188195

@@ -222,6 +229,7 @@ def build_for_test_with_configuration(test_file, aux_libraries, gcc_binary, ci_g
222229
[test_file],
223230
].flatten(1)
224231
return nil unless run_gcc(gcc_binary, *args)
232+
225233
artifacts << executable
226234
executable
227235
end

0 commit comments

Comments
 (0)