Skip to content

Commit ec1be6c

Browse files
committed
Cleanup Ruby (with RuboCop)
1 parent 7072091 commit ec1be6c

File tree

4 files changed

+18
-23
lines changed

4 files changed

+18
-23
lines changed

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Rake::TestTask.new do |t|
66
t.verbose = false
77
end
88

9-
task :default => :test
9+
task default: :test

script/html-proofer

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ require "html-proofer"
55

66
url_ignores = [
77
%r{^https://github.com/github/opensource.guide},
8-
'https://karissa.github.io/post/okf-de',
9-
'https://this-week-in-rust.org/',
10-
'https://www.vagrantup.com/',
11-
'https://www.quora.com/'
8+
"https://karissa.github.io/post/okf-de",
9+
"https://this-week-in-rust.org/",
10+
"https://www.vagrantup.com/",
11+
"https://www.quora.com/",
1212
]
1313

14-
HTMLProofer::Runner.new(["_site"],
15-
:type => :directory,
16-
:url_ignore => url_ignores,
17-
:verbose => !!ENV["VERBOSE"],
18-
:check_html => true
14+
HTMLProofer::Runner.new(
15+
["_site"],
16+
type: :directory,
17+
url_ignore: url_ignores,
18+
verbose: !!ENV["VERBOSE"],
19+
check_html: true
1920
).run

test/helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class << self
88
end
99

1010
def source
11-
File.expand_path('../', File.dirname(__FILE__))
11+
File.expand_path("../", File.dirname(__FILE__))
1212
end
1313

1414
def config
@@ -20,7 +20,7 @@ def docs
2020
end
2121

2222
def pages
23-
docs.map { |doc| doc.to_liquid }
23+
docs.map(&:to_liquid)
2424
end
2525

2626
def site

test/lint_test.rb

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
require_relative "./helper"
22

33
describe "lint test" do
4-
54
pages.each do |page|
6-
next unless page["path"].match(/\.md$/)
5+
next unless page["path"].match?(/\.md$/)
76

87
describe page["path"] do
9-
108
describe "frontmatter" do
11-
129
before do
1310
# Load raw metadata to skip defaults
1411
@data = SafeYAML.load_file(page["path"])
@@ -26,19 +23,16 @@ def assert_valid_fields(data, fields)
2623
assert extra_fields.empty?, "Unexpected metadata: #{extra_fields.inspect}"
2724

2825
fields.each do |name, attrs|
29-
if attrs["required"]
30-
assert data.key?(name), "#{name} is required"
31-
end
26+
assert data.key?(name), "#{name} is required" if attrs["required"]
3227

3328
if attrs["type"] && @data[name]
3429
assert_kind_of Kernel.const_get(attrs["type"]), @data[name]
3530
end
3631

3732
# Check subfields
38-
if attrs["fields"] && @data[name]
39-
@data[name].each do |d|
40-
assert_valid_fields(d, attrs["fields"])
41-
end
33+
next unless attrs["fields"] && @data[name]
34+
@data[name].each do |d|
35+
assert_valid_fields(d, attrs["fields"])
4236
end
4337
end
4438
end

0 commit comments

Comments
 (0)