Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error with the formatter #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/simplecov_small_badge/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def format(result)
end

private

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you didn't mean to add those spaces here 😜

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please remove the empty line?

def badge(name, title, percent)
percent_txt = percent_text(percent)
@image.config_merge(map_image_config(state(percent)))
Expand All @@ -33,8 +33,8 @@ def percent_text(percent)
end

def state(covered_percent)
if line_coverage_minimum&.positive?
if covered_percent >= line_coverage_minimum
if coverage_minimum&.positive?
if covered_percent >= coverage_minimum
'good'
else
'bad'
Expand All @@ -44,6 +44,13 @@ def state(covered_percent)
end
end

def coverage_minimum
@coverage_minimum ||= begin
minimums = SimpleCov.minimum_coverage
minimums.is_a?(Hash) ? minimums[SimpleCov.primary_coverage] : minimums
end
end

def line_coverage_minimum
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also remove the old line_coverage_minimum method. I guess it's not needed any more.

minimums = SimpleCov.minimum_coverage
minimums.is_a?(Hash) ? minimums[:line] : minimums
Expand Down