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 1 commit
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
6 changes: 3 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 SimpleCov.minimum_coverage[:line]&.positive?
if covered_percent >= SimpleCov.minimum_coverage[:line]

Choose a reason for hiding this comment

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

Suggested change
if SimpleCov.minimum_coverage[:line]&.positive?
if covered_percent >= SimpleCov.minimum_coverage[:line]
if coverage_minimum&.positive?
if covered_percent >= coverage_minimum

With:

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

This ensures that we use the minimum corresponding to the primary coverage (which is not necessary :line)

'good'
else
'bad'
Expand Down