Skip to content

Conversation

@diegojromerolopez
Copy link
Contributor

@diegojromerolopez diegojromerolopez commented Jul 6, 2018

New Feature: Pre-commit hook to check your yard documentation coverage:

Introduction

This pre-commit hook forces the developers to write yard docs in our code before commiting their changes. This is a good way to review the changes before commiting them. Thus, it make sure the code has some minimal quality.

Requirements

yard

Configuration

Default configuration for this hook

Note the 100% minimum documentation coverage required. Setting a 100% of documentation coverage is like the Boy Scouts rule: Leave your code better than you found it.

  CheckYardCoverage:
    enabled: false
    description: 'Checking for yard coverage'
    command: 'yard'
    flags: ['--private', '--protected']
     required_executable: 'yard'
    install_command: 'gem install yard'
    min_coverage_percentage: 100
    include:
      - '/**/*.rb'

Example configuration for this hook

    CheckYardCoverage:
      enabled: true
      flags: ['--private', '--protected']
      min_coverage_percentage: 75
      include:
        - '/app/controllers/*.rb'
        - '/app/facades/*.rb'
        - '/app/libs/*.rb'
        - '/app/models/**.rb'
        - '/app/presenters/*.rb'

Tests

RSpec tests that check the following conditions:

  • No undocumented code.
  • Couldn't get the yard stats (only possible if yard stats changes its output format).
  • Couldn't get the yard stats (only possible if yard stats changes its output format).
  • Actual coverage value is less than required one, report an error.

Fix some issues detected by Rubocop: CheckYardCoverage hook: run was too big and lines too long
Removing empty, following Rubocop orders
The earlier command createded documentation files in ./doc. The current command does not.
@sds sds merged commit f6ecd43 into sds:master Jul 17, 2018
@sds
Copy link
Owner

sds commented Jul 17, 2018

Thanks!

@sds
Copy link
Owner

sds commented Jul 17, 2018

Renamed the hook to YardCoverage to simplify the name, as "check" is unnecessary in this context.

891b42b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants