Skip to content

Commit

Permalink
Rubocop update
Browse files Browse the repository at this point in the history
  • Loading branch information
grodowski committed Jan 4, 2024
1 parent 5a21178 commit ae3d265
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ AllCops:
TargetRubyVersion: 2.7.0
Exclude:
- spec/fixtures/**/*
SuggestExtensions: false

Style/RegexpLiteral:
EnforcedStyle: slashes
Expand Down
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
source 'https://rubygems.org'

gemspec

gem 'bundler'
gem 'pry'
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.0'
gem 'rubocop'
gem 'simplecov'
gem 'simplecov-html'
gem 'simplecov-lcov', '~> 0.8'
gem 'timecop'
3 changes: 2 additions & 1 deletion lib/undercover/changeset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def each_changed_line
# TODO: add specs
def validate(lcov_report_path)
return :no_changes if files.empty?
return :stale_coverage if last_modified > File.mtime(lcov_report_path)

:stale_coverage if last_modified > File.mtime(lcov_report_path)
end

private
Expand Down
12 changes: 6 additions & 6 deletions lib/undercover/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ def to_s
def formatted_warnings
@results.map.with_index(1) do |res, idx|
"🚨 #{idx}) node `#{res.node.name}` type: #{res.node.human_name},\n" +
(' ' * pad_size) + "loc: #{res.file_path_with_lines}," \
" coverage: #{res.coverage_f * 100}%\n" +
(' ' * pad_size) + "loc: #{res.file_path_with_lines}, " \
"coverage: #{res.coverage_f * 100}%\n" +
res.pretty_print
end
end

def success
"#{Rainbow('undercover').bold.green}: ✅ No coverage" \
' is missing in latest changes'
"#{Rainbow('undercover').bold.green}: ✅ No coverage " \
'is missing in latest changes'
end

def warnings_header
"#{Rainbow('undercover').bold.red}: " \
'👮‍♂️ some methods have no test coverage! Please add specs for' \
' methods listed below'
'👮‍♂️ some methods have no test coverage! Please add specs for ' \
'methods listed below'
end

def pad_size
Expand Down
10 changes: 5 additions & 5 deletions lib/undercover/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def coverage_f
lines[ln] = 0
end
end
return 1.0 if lines.keys.size.zero?
return 1.0 if lines.keys.empty?

(lines.values.sum.to_f / lines.keys.size).round(4)
end
Expand Down Expand Up @@ -84,7 +84,7 @@ def pretty_print
pad = node.last_line.to_s.length
pretty_print_lines.map do |covered, (num, line)|
formatted_line = "#{num.to_s.rjust(pad)}: #{line}"
if line.strip.length.zero?
if line.strip.empty?
Rainbow(formatted_line).darkgray.dark
elsif covered.nil?
Rainbow(formatted_line).darkgray.dark + \
Expand All @@ -107,8 +107,8 @@ def file_path_with_lines
end

def inspect
"#<Undercover::Report::Result:#{object_id}" \
" name: #{node.name}, coverage: #{coverage_f}>"
"#<Undercover::Report::Result:#{object_id} " \
"name: #{node.name}, coverage: #{coverage_f}>"
end
alias to_s inspect

Expand All @@ -119,7 +119,7 @@ def count_covered_branches(line_number)
branches = coverage.select { |cov| cov.size == 4 && cov[0] == line_number }
count_covered = branches.count { |cov| cov[3].positive? }

return '' if branches.size.zero?
return '' if branches.empty?

if count_covered < branches.size
Rainbow(' branches: ').italic.darkgray.dark + \
Expand Down
16 changes: 2 additions & 14 deletions undercover.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'undercover/version'

# rubocop:disable Metrics/BlockLength
Gem::Specification.new do |spec|
spec.name = 'undercover'
spec.version = Undercover::VERSION
spec.authors = ['Jan Grodowski']
spec.email = ['[email protected]']

spec.summary = 'Actionable code coverage - detects untested' \
' code blocks in recent changes'
spec.summary = 'Actionable code coverage - detects untested ' \
'code blocks in recent changes'
spec.homepage = 'https://github.com/grodowski/undercover'
spec.license = 'MIT'
spec.metadata = {
Expand All @@ -32,15 +31,4 @@ Gem::Specification.new do |spec|
spec.add_dependency 'imagen', '>= 0.1.8'
spec.add_dependency 'rainbow', '>= 2.1', '< 4.0'
spec.add_dependency 'rugged', '>= 0.27', '< 1.8'

spec.add_development_dependency 'bundler'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 1.28.2'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'simplecov-html'
spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
spec.add_development_dependency 'timecop'
end
# rubocop:enable Metrics/BlockLength

0 comments on commit ae3d265

Please sign in to comment.