docs: complete the YARD @param tags and correct six docstrings - #177
Merged
Conversation
Every method already carried a docstring, but three took a parameter that no @PARAM tag described: Kitchen::Driver::Gce#state= Kitchen::Driver::Gce#check_api_call Kitchen::Driver::Gce#wait_for_status `state=` is generated by `attr_accessor :state`, so the reader and the writer share one docstring and a bare `@param value` on it made YARD warn that `#state` has no such parameter. A `@!method state=(value)` directive placed after the accessor documents the writer on its own instead. The other two take an explicit `&block`; they keep their `@yield` tags and gain a `@param block` so the documented signature matches the real one. While reading each method against its docstring, six doc claims turned out to contradict the code: * `authorization` documented `@return [Google::Auth::Credentials]`, but `Google::Auth.get_application_default` returns a `Signet::OAuth2::Client` subclass; `Google::Auth::Credentials` is an unrelated wrapper class that is never in that return path. * `metadata` documented `Hash{String => String}`, but `user_metadata` only stringifies keys, so a `kitchen.yml` value such as `count: 3` reaches it as an Integer. `user_metadata` already documented this correctly. * `max_server_name_length` said it raises when a disk name "leaves no room at all"; it actually raises once fewer than `fallback_server_name_length` characters remain. * `validate!` did not list the `email` setting among its raise conditions. * `normalize_disks` did not list the two raises it propagates from `assign_boot_disk`. * `create` named three state keys it mutates but also writes `:created_disks` and, for Windows guests, `:password`. Comments only; no code changed. Signed-off-by: Tim Smith <tim@mondoo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every method in
lib/already had a docstring andyard statsalready reported 100.00%, but coverage counts docstrings, not tags. Measured over the.yardoptsscope, three methods took a parameter that no@paramdescribed.Before:
After:
The three
state=is generated byattr_accessor :state, so the reader and writer share one docstring. Putting a bare@param valueon it documents the writer but makes YARD warn that#statehas no such parameter, so the writer is documented separately with a@!method state=(value)directive placed after the accessor.yardis warning-free before and after.check_api_callandwait_for_statustake an explicit&block. They keep their@yield/@yieldreturntags and gain a@param blockso the documented signature matches the real one.Six docstrings that contradicted the code
Reading each method against its docstring turned up six claims the code does not support:
authorization@return [Google::Auth::Credentials]Google::Auth.get_application_defaultreturns aSignet::OAuth2::Clientsubclass (ServiceAccountCredentials,UserRefreshCredentials,GCECredentials).Google::Auth::Credentialsis an unrelated wrapper class, never in that return path.metadataHash{String => String}user_metadataonly stringifies keys, socount: 3inkitchen.ymlstays an Integer.user_metadataalready documented this correctly asHash{String => Object}.max_server_name_lengthfallback_server_name_length(39) characters remain, so up to 39 characters of room can still exist.validate!email, which raises under the WinRM transport.normalize_disksassign_boot_disk("No disks specified", "no disk is eligible to become one").assign_boot_disk's own docstring lists all three.create:server_name,:hostname,:zone:created_disks(viacreate_instance_object→create_disks→created_disk_names) and:passwordfor Windows guests.destroy's docstring already named:created_disks.Prose that was already accurate is left alone.
Not changed
The YARD rake tasks (
yard,yard:stats,yard:server) and.yardoptsalready existed; both tasks were run and are untouched.One nit found and deliberately left, because it is a behaviour change and this PR is comments-only:
normalize_disksraises"Disk name invalid. Must match #{DISK_NAME_REGEX}.", interpolating theRegexpobject so the message reads(?-mix:...). The instance-name path atcheck_server_nameusesRESOURCE_NAME_REGEX.sourceand reads cleanly. Worth a separatefix:PR.Verification
bundle exec rake test— 344 examples, 0 failures (unchanged; comments only)bundle exec cookstyle --chefstyle— 18 files inspected, no offenses detected (Cookstyle 9.0.0, RuboCop 1.90.0)bundle exec yard— no warningsbundle exec yard stats— 100.00% documentedThe diff touches only comment lines;
git diff -U0 -- lib/filtered to non-comment lines is empty.Merge order
No conflict with the open PRs. #176 touches
spec/only, #174 adds integration files, and #175 (README) is already merged into main. This is the sole change tolib/kitchen/driver/gce.rb, so it can merge in any order relative to those.