dkubb / yardstick

A tool for verifying YARD documentation coverage
http://wiki.github.com/dkubb/yardstick
MIT License
173 stars 22 forks source link

YARD-Coverage being reported inconsistently #51

Open nimylian opened 6 years ago

nimylian commented 6 years ago

I have encountered an issue with the Yardstick::Rake::Verify. When I run my rake task, the output is as follows:

$ bundle exec rake yard:verify
YARD-Coverage: 82.3% (threshold: 100%)
rake aborted!
YARD-Coverage must be at least 100% but was 81.7%

After the first time #total_coverage is called, inYardstick::Rake::Verify#verify_measurements LOC:54, the measurements.coverage is a much larger set than in subsequent calls.

I've added some debugger to demonstrate:

$ bundle exec rake yard:verify
measurements.coverage: 13749/16690
YARD-Coverage: 82.3% (threshold: 100%)
measurements.coverage: 193/236
measurements.coverage: 193/236
YARD-Coverage must be at least 100% but was 81.7%

config/yardstick.yml:

---
threshold: 100
path: 'app/**/*.rb'
require_exact_threshold: false
rules:
  ApiTag::Presence:
    enabled: false
    exclude: []
  ApiTag::Inclusion:
    enabled: false
    exclude: []
  ApiTag::ProtectedMethod:
    enabled: false
    exclude: []
  ApiTag::PrivateMethod:
    enabled: false
    exclude: []
  ExampleTag:
    enabled: false
    exclude: []
  ReturnTag:
    enabled: true
    exclude: []
  Summary::Presence:
    enabled: true
    exclude: []
  Summary::Length:
    enabled: false
    exclude: []
  Summary::Delimiter:
    enabled: true
    exclude: []
  Summary::SingleLine:
    enabled: false
    exclude: []

Rakefile

if Rails.env.development?
  require 'yardstick/rake/verify'
  require 'yardstick/rake/measurement'

  namespace :yard do
    options = YAML.load_file('config/yardstick.yml')

    Yardstick::Rake::Measurement.new(:measure, options) do |measurement|
      measurement.output = 'doc/•yardstick_report.txt'
    end

    Yardstick::Rake::Verify.new(:verify, options)

    task :save_stats => :environment do
      sh %{yard stats --list-undoc --compact > 'doc/•undocumented.txt'}
    end
  end
end
nimylian commented 6 years ago

After some spelunking, I discovered that the original total_coverage includes many Objects and Modules in Ruby. These are the first 5 lines, after my repo's code, from my latest doc/•yardstick_report.txt:

array.c:659: Array.try_convert: The method summary should not end in a period
array.c:659: Array.try_convert: The @return tag should be specified
array.c:721: Array#initialize: The method summary should not end in a period
array.c:721: Array#initialize: The @return tag should be specified
array.c:786: Array.[]: The method summary should not end in a period
array.c:786: Array.[]: The @return tag should be specified
array.c:904: Array#<<: The method summary should not end in a period
array.c:904: Array#<<: The @return tag should be specified
array.c:942: Array#push: The method summary should not end in a period
array.c:942: Array#push: The @return tag should be specified
array.c:984: Array#pop: The method summary should not end in a period
array.c:984: Array#pop: The @return tag should be specified
array.c:1053: Array#shift: The method summary should not end in a period
array.c:1053: Array#shift: The @return tag should be specified
array.c:1160: Array#unshift: The method summary should not end in a period
array.c:1160: Array#unshift: The @return tag should be specified
array.c:1258: Array#[]: The method summary should not end in a period
array.c:1258: Array#[]: The @return tag should be specified
array.c:1258: Array#slice: The method summary should not end in a period
nimylian commented 6 years ago
$ yard stats
Files:         259
Modules:        13 (   11 undocumented)
Classes:       261 (  254 undocumented)
Constants:      26 (   20 undocumented)
Attributes:     22 (    0 undocumented)
Methods:      1104 (  868 undocumented)
 19.14% documented