Skip to content

Implement RuboCop rule Gitlab/NoCodeCoverageComment

Peter Leitzen requested to merge pl-rubocop-gitlab-no-code-coverage-comment into master

What does this MR do and why?

This MR adds a 🆕 👮 rule Gitlab/NoCodeCoverageComment to flag use of :nocov: which excludes code from coverage report.

Current offenses were generated via rake rubocop:todo:generate[Gitlab/NoCodeCoverageComment].

Contributes to #368096 (closed).

Example offense

Offenses:

app/models/integration.rb:145:5: C: Gitlab/NoCodeCoverageComment: The use of :nocov: is discouraged. All code must have tests. See https://docs.gitlab.com/ee/development/contributing/merge_request_workflow.html#testing
  # :nocov: Tested on subclasses.
    ^^^^^^^
app/models/integration.rb:160:5: C: Gitlab/NoCodeCoverageComment: The use of :nocov: is discouraged. All code must have tests. See https://docs.gitlab.com/ee/development/contributing/merge_request_workflow.html#testing
  # :nocov:
    ^^^^^^^

How to set up and validate locally

bundle exec rake rubocop:todo:generate[Gitlab/NoCodeCoverageComment]

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports

Loading