Skip to content

Commit 7a8826a

Browse files
committed
Fix rubocop errors
1 parent d043e85 commit 7a8826a

File tree

6 files changed

+38
-29
lines changed

6 files changed

+38
-29
lines changed

lib/danger_plugin.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# frozen_string_literal: true
2+
13
require 'xcode_summary/plugin'

lib/danger_xcode_summary.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# frozen_string_literal: true
2+
13
require 'xcode_summary/gem_version'

lib/xcode_summary/gem_version.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module XcodeSummary
2-
VERSION = '0.5.0'.freeze
4+
VERSION = '0.5.0'
35
end

lib/xcode_summary/plugin.rb

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'json'
24

35
module Danger
@@ -196,9 +198,9 @@ def errors(xcode_summary)
196198
errors.delete_if(&ignored_results)
197199
end
198200

199-
def parse_location(h)
200-
file_path, line, _column = h[:file_path].split(':')
201-
Location.new(h[:file_name], file_path, line.to_i)
201+
def parse_location(input)
202+
file_path, line, _column = input[:file_path].split(':')
203+
Location.new(input[:file_name], file_path, line.to_i)
202204
end
203205

204206
def parse_test_location(failure)
@@ -225,13 +227,12 @@ def format_path(path)
225227
def parse_filename(path)
226228
regex = /^(.*?):(\d*):?\d*$/
227229
match = path.match(regex)
228-
if match
229-
match.captures
230-
end
230+
match&.captures
231231
end
232232

233233
def relative_path(path)
234234
return nil if project_root.nil?
235+
235236
path.gsub(project_root, '')
236237
end
237238

@@ -245,38 +246,38 @@ def escape_reason(reason)
245246
reason.gsub('>', '\>').gsub('<', '\<')
246247
end
247248

248-
def format_compile_warning(h)
249-
path = relative_path(h[:file_path])
249+
def format_compile_warning(input)
250+
path = relative_path(input[:file_path])
250251
return nil if should_ignore_warning?(path)
251252

252253
path_link = format_path(path)
253254

254-
warning = "**#{path_link}**: #{escape_reason(h[:reason])} <br />"
255-
if h[:line] && !h[:line].empty?
255+
warning = "**#{path_link}**: #{escape_reason(input[:reason])} <br />"
256+
if input[:line] && !input[:line].empty?
256257
"#{warning}" \
257258
"```\n" \
258-
"#{h[:line]}\n" \
259+
"#{input[:line]}\n" \
259260
'```'
260261
else
261262
warning
262263
end
263264
end
264265

265-
def format_format_file_missing_error(h)
266-
path = relative_path(h[:file_path])
266+
def format_format_file_missing_error(input)
267+
path = relative_path(input[:file_path])
267268
path_link = format_path(path)
268-
"**#{escape_reason(h[:reason])}**: #{path_link}"
269+
"**#{escape_reason(input[:reason])}**: #{path_link}"
269270
end
270271

271-
def format_undefined_symbols(h)
272-
"#{h[:message]} <br />" \
273-
"> Symbol: #{h[:symbol]} <br />" \
274-
"> Referenced from: #{h[:reference]}"
272+
def format_undefined_symbols(input)
273+
"#{input[:message]} <br />" \
274+
"> Symbol: #{input[:symbol]} <br />" \
275+
"> Referenced from: #{input[:reference]}"
275276
end
276277

277-
def format_duplicate_symbols(h)
278-
"#{h[:message]} <br />" \
279-
"> #{h[:file_paths].map { |path| path.split('/').last }.join('<br /> ')}"
278+
def format_duplicate_symbols(input)
279+
"#{input[:message]} <br />" \
280+
"> #{input[:file_paths].map { |path| path.split('/').last }.join('<br /> ')}"
280281
end
281282

282283
def format_test_failure(suite_name, failure)

spec/spec_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# frozen_string_literal: true
2+
13
require 'pathname'
2-
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
4+
ROOT = Pathname.new(File.expand_path('..', __dir__))
35
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
46
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
57

spec/xcode_summary_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
require File.expand_path('../spec_helper', __FILE__)
1+
# frozen_string_literal: true
2+
3+
require File.expand_path('spec_helper', __dir__)
24

35
module Danger
46
describe Danger::DangerXcodeSummary do
@@ -73,7 +75,7 @@ module Danger
7375
@xcode_summary.report('spec/fixtures/summary.json')
7476
expect(@dangerfile.status_report[:warnings]).to eq [
7577
# rubocop:disable LineLength
76-
"**<a href='https://github.com/diogot/danger-xcode_summary/blob/129jef029jf029fj2039fj203f92/MyWeight/Bla.m#L32'>MyWeight/Bla.m#L32</a>**: Value stored to 'theme' is never read <br />```\n theme = *ptr++;\n```",
78+
"**<a href='https://github.com/diogot/danger-xcode_summary/blob/129jef029jf029fj2039fj203f92/MyWeight/Bla.m#L32'>MyWeight/Bla.m#L32</a>**: Value stored to 'theme' is never read <br />```\n theme = *ptr++;\n```"
7779
# rubocop:enable LineLength
7880
]
7981
end
@@ -89,7 +91,7 @@ module Danger
8991
expect(@dangerfile.status_report[:errors]).to eq [
9092
# rubocop:disable LineLength
9193
'**MyWeight.MyWeightSpec**: works_with_success, expected to eventually not be nil, got \<nil\> <br /> ' \
92-
"<a href='https://github.com/diogot/danger-xcode_summary/blob/129jef029jf029fj2039fj203f92/MyWeight/MyWeightTests/Tests.swift#L86'>MyWeight/MyWeightTests/Tests.swift#L86</a>",
94+
"<a href='https://github.com/diogot/danger-xcode_summary/blob/129jef029jf029fj2039fj203f92/MyWeight/MyWeightTests/Tests.swift#L86'>MyWeight/MyWeightTests/Tests.swift#L86</a>"
9395
# rubocop:enable LineLength
9496
]
9597
end
@@ -205,9 +207,7 @@ module Danger
205207
describe 'where request source' do
206208
it 'should be bitbucket' do
207209
path = @xcode_summary.send(:format_path, 'lib/xcode_summary/plugin.rb:3')
208-
# rubocop:disable LineLength
209-
expect(path).to eq "lib/xcode_summary/plugin.rb:3"
210-
# rubocop:enable LineLength
210+
expect(path).to eq 'lib/xcode_summary/plugin.rb:3'
211211
end
212212
end
213213
end

0 commit comments

Comments
 (0)