Sha256: 9e891c164ee5e90b74709fb5f7945135ba2c48e2c48a4a0bcefe69b22ecc890d
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true module Danger # Report missing coverage report using undercover and danger-undercover # # You have to use [undercover](https://github.com/grodowski/undercover) to gather # undercover report and send the report to this plugin so that danger-undercover # can use it. # # @example Report missing coverage report # # undercover.report('coverage/undercover.txt') # # @see nimblehq/danger-undercover # @tags ruby, code-coverage, simplecov, undercover, danger, simplecov-lcov # class DangerUndercover < Plugin VALID_FILE_FORMAT = '.txt' DEFAULT_PATH = 'coverage/undercover.txt' # Checks the file validity and warns if no file is found # if a valid file is found then if there are no changes, # shows the report as a message in Danger. # If there are reports then it shows the report as a warning in danger. # @return [void] # def report(undercover_path = DEFAULT_PATH, sticky: true) return fail('Undercover: coverage report cannot be found.') unless valid_file? undercover_path report = File.open(undercover_path).read.force_encoding('UTF-8') if report.match(/some methods have no test coverage/) warn(report, sticky: sticky) else message(report, sticky: sticky) end end private # Checks if the file exists and the file is valid # @return [Boolean] File validity # def valid_file?(undercover_path) File.exist?(undercover_path) && (File.extname(undercover_path) == VALID_FILE_FORMAT) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
danger-undercover-1.1.0 | lib/undercover/plugin.rb |