Skip to content

Commit 6d099f6

Browse files
committed
Upgrade rubocop
1 parent 6dad531 commit 6d099f6

File tree

8 files changed

+34
-15
lines changed

8 files changed

+34
-15
lines changed

.rubocop.yml

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
AllCops:
2+
TargetRubyVersion: 2.6
3+
NewCops: enable
4+
SuggestExtensions: false
25
Exclude:
36
- '*.gemspec'
47
- 'spec/*.rb'
@@ -13,6 +16,24 @@ Style/RescueStandardError:
1316
Security/Open:
1417
Enabled: false
1518

19+
Style/FrozenStringLiteralComment:
20+
Enabled: false
21+
22+
# broken :( https://github.com/rubocop-hq/rubocop/issues/9144
23+
Style/StringConcatenation:
24+
Enabled: false
25+
26+
# Ruins git diffs
27+
Style/AccessorGrouping:
28+
Enabled: false
29+
30+
# Ruins keeping the upper half of the conditional smaller
31+
Style/NegatedIfElseCondition:
32+
Enabled: false
33+
34+
# affects calling style?
35+
Style/OptionalBooleanParameter:
36+
Enabled: false
1637

1738
# Extra lines for readability
1839
Layout/EmptyLinesAroundClassBody:
@@ -37,9 +58,7 @@ Layout/EndAlignment:
3758
Layout/CaseIndentation:
3859
EnforcedStyle: end
3960

40-
Metrics/LineLength:
41-
Description: Limit lines to 80 characters.
42-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
61+
Layout/LineLength:
4362
Enabled: true
4463
Max: 130
4564

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ gemspec
88
gem "bundler", "> 1.15", require: false, group: :test
99
gem "keepachangelog_manager", "~> 0.0.2", require: false, group: :test
1010
gem "rspec", "~> 3.0", require: false, group: :test
11-
gem 'rubocop', '~>0.59.0', require: false, group: :test
11+
gem 'rubocop', '~>1.5.0', require: false, group: :test
1212
gem 'simplecov', require: false, group: :test
1313
gem 'yard', '~>0.9.11', require: false, group: :test

exe/arduino_ci_remote.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env ruby
22
puts "arduino_ci_remote.rb is deprecated in favor of arduino_ci.rb."
3-
require_relative "arduino_ci.rb"
3+
require_relative "arduino_ci"

lib/arduino_ci/arduino_backend.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def initialize(binary_path)
5050

5151
def _wrap_run(work_fn, *args, **kwargs)
5252
# do some work to extract & merge environment variables if they exist
53-
has_env = !args.empty? && args[0].class == Hash
53+
has_env = !args.empty? && args[0].instance_of?(Hash)
5454
env_vars = has_env ? args[0] : {}
55-
actual_args = has_env ? args[1..-1] : args # need to shift over if we extracted args
55+
actual_args = has_env ? args[1..] : args # need to shift over if we extracted args
5656
custom_config = @config_dir.nil? ? [] : ["--config-file", @config_dir.to_s]
5757
full_args = [binary_path.to_s, "--format", "json"] + custom_config + actual_args
5858
full_cmd = env_vars.empty? ? full_args : [env_vars] + full_args

lib/arduino_ci/arduino_downloader.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def download
104104
total_size += size
105105
needed_dots = (total_size / chunk_size).to_i
106106
unprinted_dots = needed_dots - dots
107-
@output.print("." * unprinted_dots) if unprinted_dots > 0
107+
@output.print("." * unprinted_dots) if unprinted_dots.positive?
108108
dots = needed_dots
109109
end
110110

lib/arduino_ci/ci_config.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def default
6666
attr_accessor :platform_info
6767
attr_accessor :compile_info
6868
attr_accessor :unittest_info
69+
6970
def initialize
7071
@package_info = {}
7172
@platform_info = {}
@@ -107,15 +108,15 @@ def validate_data(rootname, source, schema)
107108
good_data = {}
108109
source.each do |key, value|
109110
ksym = key.to_sym
110-
expected_type = schema[ksym].class == Class ? schema[ksym] : Hash
111+
expected_type = schema[ksym].instance_of?(Class) ? schema[ksym] : Hash
111112
if !schema.include?(ksym)
112113
puts "Warning: unknown field '#{ksym}' under definition for #{rootname}"
113114
elsif value.nil?
114115
good_data[ksym] = nil
115116
elsif value.class != expected_type
116117
puts "Warning: expected field '#{ksym}' of #{rootname} to be '#{expected_type}', got '#{value.class}'"
117118
else
118-
good_data[ksym] = value.class == Hash ? validate_data(key, value, schema[ksym]) : value
119+
good_data[ksym] = value.instance_of?(Hash) ? validate_data(key, value, schema[ksym]) : value
119120
end
120121
end
121122
good_data

lib/arduino_ci/cpp_library.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,7 @@ def all_arduino_library_dependencies!(additional_libraries = [])
407407
other_lib.install unless other_lib.installed?
408408
other_lib.all_arduino_library_dependencies!
409409
end.flatten
410-
ret = (additional_libraries + recursive).uniq
411-
ret
410+
(additional_libraries + recursive).uniq
412411
end
413412

414413
# Arduino library directories containing sources -- only those of the dependencies
@@ -522,7 +521,7 @@ def build_for_test_with_configuration(test_file, aux_libraries, gcc_binary, ci_g
522521
# @param executable [Pathname] the path to the test file
523522
def print_stack_dump(executable)
524523
possible_dumpfiles = [
525-
executable.sub_ext(executable.extname + ".stackdump")
524+
executable.sub_ext("#{executable.extname}.stackdump")
526525
]
527526
possible_dumpfiles.select(&:exist?).each do |dump|
528527
puts "========== Stack dump from #{dump}:"

lib/arduino_ci/host.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ module ArduinoCI
88
class Host
99
# TODO: this came from https://stackoverflow.com/a/22716582/2063546
1010
# and I'm not sure if it can be replaced by self.os == :windows
11-
WINDOWS_VARIANT_REGEX = /mswin32|cygwin|mingw|bccwin/
11+
WINDOWS_VARIANT_REGEX = /mswin32|cygwin|mingw|bccwin/.freeze
1212

1313
# e.g. 11/27/2020 01:02 AM <SYMLINKD> ExcludeSomething [C:\projects\arduino-ci\SampleProjects\ExcludeSomething]
14-
DIR_SYMLINK_REGEX = %r{\d+/\d+/\d+\s+[^<]+<SYMLINKD?>\s+(.*) \[([^\]]+)\]}
14+
DIR_SYMLINK_REGEX = %r{\d+/\d+/\d+\s+[^<]+<SYMLINKD?>\s+(.*) \[([^\]]+)\]}.freeze
1515

1616
# Cross-platform way of finding an executable in the $PATH.
1717
# via https://stackoverflow.com/a/5471032/2063546

0 commit comments

Comments
 (0)