Skip to content

Commit 2be0f4b

Browse files
committed
Fix remaining standardrb issues
1 parent 20db245 commit 2be0f4b

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

lib/cc/engine/file_list_resolver.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ def expanded_list
2222
attr_reader :config_store
2323

2424
def absolute_include_paths
25-
@include_paths.map do |path|
26-
Pathname.new(path).realpath.to_s
27-
rescue Errno::ENOENT
28-
nil
29-
end.compact
25+
@include_paths.map { |path| to_absolute_path(path) }.compact
26+
end
27+
28+
def to_absolute_path(path)
29+
Pathname.new(path).realpath.to_s
30+
rescue Errno::ENOENT
31+
nil
3032
end
3133

3234
def rubocop_file_to_include?(file)

lib/cc/engine/issue.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def to_json(*_)
3131
positions: positions
3232
}
3333
}
34-
hash[:content] = {body: content_body } if content_body.present?
34+
hash[:content] = {body: content_body} if content_body.present?
3535

3636
if (fingerprint = Fingerprint.new(path, cop_name, message).compute)
3737
hash[:fingerprint] = fingerprint

lib/tasks/docs.rake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ namespace :docs do
3434
content = content.gsub(/.*\n\s+(?=module RuboCop)/, "")
3535

3636
class_doc = content.match(/(\s+#.*)+/).to_s
37-
doc_lines = class_doc.
38-
gsub(/^\n/, "").
39-
gsub("@example", "### Example:").
40-
gsub("@good", "# good").
41-
gsub("@bad", "# bad").
42-
split("\n").
43-
map { |line| line.gsub(/\A\s+#\s?/, "") }.
44-
map { |line| line.gsub(/\A\s{2}/, " " * 4) }.
45-
join("\n")
37+
doc_lines = class_doc
38+
.gsub(/^\n/, "")
39+
.gsub("@example", "### Example:")
40+
.gsub("@good", "# good")
41+
.gsub("@bad", "# bad")
42+
.split("\n")
43+
.map { |line| line.gsub(/\A\s+#\s?/, "") }
44+
.map { |line| line.gsub(/\A\s{2}/, " " * 4) }
45+
.join("\n")
4646
hash[file] = doc_lines
4747
}
4848

spec/cc/engine/file_list_resolver_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module CC::Engine
3434
create_source_file("a.rb", "def a; true; end")
3535
create_source_file("src/b.rb", "def a; true; end")
3636

37-
resolver = FileListResolver.new(root: @code, engine_config: { "include_paths" => %w[src/] }, config_store: rubocop_config)
37+
resolver = FileListResolver.new(root: @code, engine_config: {"include_paths" => %w[src/]}, config_store: rubocop_config)
3838
expect(resolver.expanded_list).to eq [Pathname.new("src/b.rb").realpath.to_s]
3939
end
4040
end
@@ -52,7 +52,7 @@ module CC::Engine
5252
- Gemfile
5353
YML
5454

55-
resolver = FileListResolver.new(root: @code, engine_config: { "include_paths" => %w[Gemfile src/] }, config_store: rubocop_config)
55+
resolver = FileListResolver.new(root: @code, engine_config: {"include_paths" => %w[Gemfile src/]}, config_store: rubocop_config)
5656
expect(resolver.expanded_list).to eq [Pathname.new("src/b.rb").realpath.to_s]
5757
end
5858
end
@@ -61,7 +61,7 @@ module CC::Engine
6161
Dir.chdir(@code) do
6262
create_source_file("src/b.rb", "def a; true; end")
6363

64-
resolver = FileListResolver.new(root: @code, engine_config: { "include_paths" => %w[src/ public/assets] }, config_store: rubocop_config)
64+
resolver = FileListResolver.new(root: @code, engine_config: {"include_paths" => %w[src/ public/assets]}, config_store: rubocop_config)
6565
expect(resolver.expanded_list).to eq [Pathname.new("src/b.rb").realpath.to_s]
6666
end
6767
end

spec/cc/engine/standard_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def method
6868
location: OpenStruct.new(
6969
line: 1,
7070
column: 0,
71-
source_line: "",
71+
source_line: ""
7272
),
7373
cop_name: "fake",
7474
message: "message"
@@ -90,8 +90,8 @@ def method
9090
location = {
9191
"path" => "my_script.rb",
9292
"positions" => {
93-
"begin" => { "column" => 1, "line" => 1 },
94-
"end" => { "column" => 1, "line" => 1 }
93+
"begin" => {"column" => 1, "line" => 1},
94+
"end" => {"column" => 1, "line" => 1}
9595
}
9696
}
9797

0 commit comments

Comments
 (0)