Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress YARD warning logs #26

Merged
merged 1 commit into from
Jan 28, 2024
Merged

Suppress YARD warning logs #26

merged 1 commit into from
Jan 28, 2024

Conversation

euglena1215
Copy link
Contributor

Fixed #25

When rubocop is executed, the warning of YARD itself should not be output,
but should be reported as an offenct of rubocop.

@euglena1215
Copy link
Contributor Author

Sorry, I didn't know how to guarantee the behavior in this repository since there was no test.
I have confirmed that the warning log is no longer output in my application.

@ksss
Copy link
Owner

ksss commented Jan 26, 2024

You can try bundle exec rake for testing.

Fixed ksss#25

When rubocop is executed, the warning of YARD itself should not be output, but should be reported as an offenct of rubocop.
@euglena1215
Copy link
Contributor Author

@ksss
After the fix, I confirmed that bundle exec rake passes!

@ksss
Copy link
Owner

ksss commented Jan 27, 2024

To reproduce the problem, could you add a test case that does not produce warnings, or provide a sample YARD case that does produce warnings?

@euglena1215
Copy link
Contributor Author

Oh, sorry. I forgot to share how to reproduce.

diff --git a/smoke/mismatch_name.rb b/smoke/mismatch_name.rb
index debfa1b..0191f5e 100644
--- a/smoke/mismatch_name.rb
+++ b/smoke/mismatch_name.rb
@@ -45,6 +45,10 @@ class Foo
   #   arg doc
   def returned(arg)
   end
+
+  # @return Hash{Symbol => String}
+  def invalid_format(arg)
+  end
 end

 # https://github.com/ksss/rubocop-yard/issues/18

After applying the above changes in the main branch, the following command will output a warn log.

% bundle exec rubocop --cache false --no-server --config .rubocop.yml --only YARD/MismatchName ./smoke/mismatch_name.rb
Inspecting 1 file
[warn]: Invalid tag format for @return
C

Offenses:

smoke/mismatch_name.rb:3:3: C: YARD/MismatchName: No tag name is supplied in @param
  # @param
  ^^^^^^^^
smoke/mismatch_name.rb:4:3: C: YARD/MismatchName: No types are associated with the tag in @param
  # @param aaa
  ^^^^^^^^^^^^
smoke/mismatch_name.rb:5:3: C: YARD/MismatchName: No tag name is supplied in @param
  # @param [void]
  ^^^^^^^^^^^^^^^
smoke/mismatch_name.rb:6:12: C: YARD/MismatchName: opt is not found in method arguments of [bar, opts]
  # @option opt aaa [void]
           ^^^
smoke/mismatch_name.rb:7:3: C: YARD/MismatchName: No types are associated with the tag in @option
  # @option opts aaa
  ^^^^^^^^^^^^^^^^^^
smoke/mismatch_name.rb:9:3: C: YARD/MismatchName: No tag name is supplied in @param
  # @param [void]
  ^^^^^^^^^^^^^^^
smoke/mismatch_name.rb:17:3: C: [Correctable] YARD/MismatchName: This method has argument opts, But not documented
  # @param [String] strings
  ^^^^^^^^^^^^^^^^^^^^^^^^^
smoke/mismatch_name.rb:56:18: C: YARD/MismatchName: context, is not found in method arguments of [context]
  # @param [Hash] context, Extra colon at the end of param name.
                 ^^^^^^^^

1 file inspected, 8 offenses detected, 1 offense autocorrectable

The warn log is not included in the rubocop results.
Therefore, they are difficult to handle in smoke tests and are better suited for unit tests.

Should I set up a minitest or rspec and write a unit test?

@ksss
Copy link
Owner

ksss commented Jan 28, 2024

Thank you for sharing repro.
I'll add testing code later.

@ksss ksss merged commit d6503b4 into ksss:main Jan 28, 2024
3 checks passed
@ksss ksss mentioned this pull request Jan 28, 2024
@euglena1215 euglena1215 deleted the supress-warn-log branch January 29, 2024 02:09
@ksss
Copy link
Owner

ksss commented Jan 31, 2024

v0.9.3 has been shipped :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

YARD warning log is output when executing rubocop
2 participants