Skip to content

Commit a7639ee

Browse files
committed
Bump rubocop up to newer ruby versions (in progress)
1 parent 7a31075 commit a7639ee

File tree

9 files changed

+30
-27
lines changed

9 files changed

+30
-27
lines changed

auto/colour_reporter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def report(message)
1212
if !$colour_output
1313
$stdout.puts(message)
1414
else
15-
message = message.join('\n') if message.class == Array
15+
message = message.join('\n') if message.instance_of?(Array)
1616
message.each_line do |line|
1717
line.chomp!
1818
colour = case line

auto/generate_module.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def files_to_operate_on(module_name, pattern = nil)
133133

134134
# create triad definition
135135
prefix = @options[:test_prefix] || 'Test'
136-
triad = [{ ext: '.c', path: @options[:path_src], prefix: '', template: TEMPLATE_SRC, inc: :src, boilerplate: @options[:boilerplates][:src] },
136+
triad = [{ ext: '.c', path: @options[:path_src], prefix: '', template: TEMPLATE_SRC, inc: :src, boilerplate: @options[:boilerplates][:src] },
137137
{ ext: '.h', path: @options[:path_inc], prefix: '', template: TEMPLATE_INC, inc: :inc, boilerplate: @options[:boilerplates][:inc] },
138138
{ ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, boilerplate: @options[:boilerplates][:tst], test_define: @options[:test_define] }]
139139

auto/generate_test_runner.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ def find_tests(source)
144144
if @options[:use_param_tests] && !arguments.empty?
145145
args = []
146146
type_and_args = arguments.split(/TEST_(CASE|RANGE)/)
147-
for i in (1...type_and_args.length).step(2)
148-
if type_and_args[i] == "CASE"
147+
(1...type_and_args.length).step(2).each do |i|
148+
if type_and_args[i] == 'CASE'
149149
args << type_and_args[i + 1].sub(/^\s*\(\s*(.*?)\s*\)\s*$/m, '\1')
150150
next
151151
end
@@ -194,12 +194,11 @@ def find_includes(source)
194194
source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain)
195195

196196
# parse out includes
197-
includes = {
198-
local: source.scan(/^\s*#include\s+\"\s*(.+\.#{@options[:include_extensions]})\s*\"/).flatten,
197+
{
198+
local: source.scan(/^\s*#include\s+"\s*(.+\.#{@options[:include_extensions]})\s*"/).flatten,
199199
system: source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten.map { |inc| "<#{inc}>" },
200-
linkonly: source.scan(/^TEST_FILE\(\s*\"\s*(.+\.#{@options[:source_extensions]})\s*\"/).flatten
200+
linkonly: source.scan(/^TEST_FILE\(\s*"\s*(.+\.#{@options[:source_extensions]})\s*"/).flatten
201201
}
202-
includes
203202
end
204203

205204
def find_mocks(includes)
@@ -446,7 +445,7 @@ def create_main(output, filename, tests, used_mocks)
446445
end
447446

448447
def create_h_file(output, filename, tests, testfile_includes, used_mocks)
449-
filename = File.basename(filename).gsub(/[-\/\\\.\,\s]/, '_').upcase
448+
filename = File.basename(filename).gsub(/[-\/\\.,\s]/, '_').upcase
450449
output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
451450
output.puts("#ifndef _#{filename}")
452451
output.puts("#define _#{filename}\n\n")
@@ -485,7 +484,7 @@ def create_h_file(output, filename, tests, testfile_includes, used_mocks)
485484
when /\.*\.ya?ml$/
486485
options = UnityTestRunnerGenerator.grab_config(arg)
487486
true
488-
when /--(\w+)=\"?(.*)\"?/
487+
when /--(\w+)="?(.*)"?/
489488
options[Regexp.last_match(1).to_sym] = Regexp.last_match(2)
490489
true
491490
when /\.*\.(?:hpp|hh|H|h)$/

auto/test_file_filter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def initialize(all_files = false)
1515

1616
file = 'test_file_filter.yml'
1717
return unless File.exist?(file)
18+
1819
filters = YamlHelper.load_file(file)
1920
@all_files = filters[:all_files]
2021
@only_files = filters[:only_files]

auto/type_sanitizer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TypeSanitizer
22
def self.sanitize_c_identifier(unsanitized)
33
# convert filename to valid C identifier by replacing invalid chars with '_'
4-
unsanitized.gsub(/[-\/\\\.\,\s]/, '_')
4+
unsanitized.gsub(/[-\/\\.,\s]/, '_')
55
end
66
end

auto/unity_test_summary.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ def usage(err_msg = nil)
8686
def get_details(_result_file, lines)
8787
results = { failures: [], ignores: [], successes: [] }
8888
lines.each do |line|
89-
status_match = line.match(/^[^:]+:[^:]+:\w+(?:\([^\)]*\))?:([^:]+):?/)
89+
status_match = line.match(/^[^:]+:[^:]+:\w+(?:\([^)]*\))?:([^:]+):?/)
9090
next unless status_match
91+
9192
status = status_match.captures[0]
9293

9394
line_out = (@root && (@root != 0) ? "#{@root}#{line}" : line).gsub(/\//, '\\')

auto/yaml_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
module YamlHelper
1010
def self.load(body)
11-
YAML.respond_to?(:unsafe_load) ?
12-
YAML.unsafe_load(body) : YAML.load(body)
11+
if YAML.respond_to?(:unsafe_load)
12+
YAML.unsafe_load(body)
13+
else
14+
YAML.load(body)
15+
end
1316
end
1417

1518
def self.load_file(file)

examples/example_3/rakefile_helper.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def extract_headers(filename)
4242
includes = []
4343
lines = File.readlines(filename)
4444
lines.each do |line|
45-
m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
45+
m = line.match(/^\s*#include\s+"\s*(.+\.[hH])\s*"/)
4646
includes << m[1] unless m.nil?
4747
end
4848
includes
@@ -57,12 +57,11 @@ def find_source_file(header, paths)
5757
end
5858

5959
def tackit(strings)
60-
result = if strings.is_a?(Array)
61-
"\"#{strings.join}\""
62-
else
63-
strings
64-
end
65-
result
60+
if strings.is_a?(Array)
61+
"\"#{strings.join}\""
62+
else
63+
strings
64+
end
6665
end
6766

6867
def squash(prefix, items)
@@ -80,7 +79,7 @@ def build_compiler_fields
8079
end
8180
options = squash('', $cfg['compiler']['options'])
8281
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
83-
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
82+
includes = includes.gsub(/\\ /, ' ').gsub(/\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
8483

8584
{ command: command, defines: defines, options: options, includes: includes }
8685
end
@@ -105,7 +104,7 @@ def build_linker_fields
105104
''
106105
else
107106
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
108-
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
107+
end.gsub(/\\ /, ' ').gsub(/\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
109108

110109
{ command: command, options: options, includes: includes }
111110
end

test/.rubocop.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#inherit_from: .rubocop_todo.yml
44

55
AllCops:
6-
TargetRubyVersion: 2.3
6+
TargetRubyVersion: 3.0
77

88
# These are areas where ThrowTheSwitch's coding style diverges from the Ruby standard
99
Style/SpecialGlobalVars:
@@ -36,10 +36,12 @@ Style/FormatStringToken:
3636
Enabled: false
3737

3838
# This is disabled because it seems to get confused over nested hashes
39-
Layout/AlignHash:
39+
Layout/HashAlignment:
4040
Enabled: false
4141
EnforcedHashRocketStyle: table
4242
EnforcedColonStyle: table
43+
Layout/LineLength:
44+
Enabled: false
4345

4446
# We purposefully use these insecure features because they're what makes Ruby awesome
4547
Security/Eval:
@@ -64,8 +66,6 @@ Metrics/ClassLength:
6466
Enabled: false
6567
Metrics/CyclomaticComplexity:
6668
Enabled: false
67-
Metrics/LineLength:
68-
Enabled: false
6969
Metrics/MethodLength:
7070
Enabled: false
7171
Metrics/ModuleLength:

0 commit comments

Comments
 (0)