From 3d0aeeebd004f5385ed1ba21e027dc2589bb8b76 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Mon, 30 Jan 2023 11:14:47 +0900 Subject: [PATCH] Cut 0.27.0 --- CHANGELOG.md | 2 + config/default.yml | 6 +- docs/antora.yml | 2 +- docs/modules/ROOT/pages/cops.adoc | 1 + docs/modules/ROOT/pages/cops_minitest.adoc | 91 ++++++++++++++++++++-- lib/rubocop/minitest/version.rb | 2 +- relnotes/v0.27.0.md | 16 ++++ 7 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 relnotes/v0.27.0.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 18696b40..5003c3e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master (unreleased) +## 0.27.0 (2023-01-30) + ### New features * [#220](https://github.com/rubocop/rubocop-minitest/issues/220): Add new `Minitest/NonPublicTestMethod` cop. ([@fatkodima][]) diff --git a/config/default.yml b/config/default.yml index 20ad058b..1279a745 100644 --- a/config/default.yml +++ b/config/default.yml @@ -113,7 +113,7 @@ Minitest/AssertTruthy: Enabled: true Safe: false VersionAdded: '0.2' - VersionChanged: '<>' + VersionChanged: '0.27' Minitest/AssertWithExpectedArgument: Description: 'This cop tries to detect when a user accidentally used `assert` when they meant to use `assert_equal`.' @@ -179,7 +179,7 @@ Minitest/NonPublicTestMethod: Description: 'Detects non `public` (marked as `private` or `protected`) test methods.' Enabled: pending Severity: warning - VersionAdded: '<>' + VersionAdded: '0.27' Minitest/RefuteEmpty: Description: 'This cop enforces to use `refute_empty` instead of using `refute(object.empty?)`.' @@ -199,7 +199,7 @@ Minitest/RefuteFalse: Enabled: true Safe: false VersionAdded: '0.3' - VersionChanged: '<>' + VersionChanged: '0.27' Minitest/RefuteInDelta: Description: 'This cop enforces the test to use `refute_in_delta` instead of using `refute_equal` to compare floats.' diff --git a/docs/antora.yml b/docs/antora.yml index 02c36842..33258f61 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -2,6 +2,6 @@ name: rubocop-minitest title: RuboCop Minitest # We always provide version without patch here (e.g. 1.1), # as patch versions should not appear in the docs. -version: ~ +version: '0.27' nav: - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/pages/cops.adoc b/docs/modules/ROOT/pages/cops.adoc index 51c1dd66..bb9e6bfe 100644 --- a/docs/modules/ROOT/pages/cops.adoc +++ b/docs/modules/ROOT/pages/cops.adoc @@ -39,6 +39,7 @@ based on the https://minitest.rubystyle.guide/[Minitest Style Guide]. * xref:cops_minitest.adoc#minitestliteralasactualargument[Minitest/LiteralAsActualArgument] * xref:cops_minitest.adoc#minitestmultipleassertions[Minitest/MultipleAssertions] * xref:cops_minitest.adoc#minitestnoassertions[Minitest/NoAssertions] +* xref:cops_minitest.adoc#minitestnonpublictestmethod[Minitest/NonPublicTestMethod] * xref:cops_minitest.adoc#minitestrefuteempty[Minitest/RefuteEmpty] * xref:cops_minitest.adoc#minitestrefuteequal[Minitest/RefuteEqual] * xref:cops_minitest.adoc#minitestrefutefalse[Minitest/RefuteFalse] diff --git a/docs/modules/ROOT/pages/cops_minitest.adoc b/docs/modules/ROOT/pages/cops_minitest.adoc index 4db9f40e..b56aed8e 100644 --- a/docs/modules/ROOT/pages/cops_minitest.adoc +++ b/docs/modules/ROOT/pages/cops_minitest.adoc @@ -565,17 +565,24 @@ assert_silent { puts object.do_something } | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed | Enabled -| Yes +| No | Yes (Unsafe) | 0.2 -| 0.26 +| 0.27 |=== Enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`. === Safety -This cop's autocorrection is unsafe because true might be expected instead of truthy. +This cop is unsafe because true might be expected instead of truthy. +False positives cannot be prevented when this is a variable or method return value. + +[source,ruby] +---- +assert_equal(true, 'truthy') # failure +assert('truthy') # success +---- === Examples @@ -1013,6 +1020,67 @@ class FooTest < Minitest::Test end ---- +== Minitest/NonPublicTestMethod + +|=== +| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed + +| Pending +| Yes +| No +| 0.27 +| - +|=== + +Detects non `public` (marked as `private` or `protected`) test methods. +Minitest runs only test methods which are `public`. + +=== Examples + +[source,ruby] +---- +# bad +class FooTest + private # or protected + def test_does_something + assert_equal 42, do_something + end +end + +# good +class FooTest + def test_does_something + assert_equal 42, do_something + end +end + +# good (not a test case name) +class FooTest + private # or protected + def does_something + assert_equal 42, do_something + end +end + +# good (no assertions) +class FooTest + private # or protected + def test_does_something + do_something + end +end +---- + +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Severity +| `warning` +| String +|=== + == Minitest/RefuteEmpty |=== @@ -1081,14 +1149,25 @@ refute_equal("rubocop-minitest", actual) | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed | Enabled -| Yes -| Yes +| No +| Yes (Unsafe) | 0.3 -| - +| 0.27 |=== Enforces the use of `refute(object)` over `assert_equal(false, object)`. +=== Safety + +This cop is unsafe because it cannot detect failure when second argument is `nil`. +False positives cannot be prevented when this is a variable or method return value. + +[source,ruby] +---- +assert_equal(false, nil) # failure +refute(nil) # success +---- + === Examples [source,ruby] diff --git a/lib/rubocop/minitest/version.rb b/lib/rubocop/minitest/version.rb index a6ccf0eb..a9806ae8 100644 --- a/lib/rubocop/minitest/version.rb +++ b/lib/rubocop/minitest/version.rb @@ -4,7 +4,7 @@ module RuboCop module Minitest # This module holds the RuboCop Minitest version information. module Version - STRING = '0.26.1' + STRING = '0.27.0' def self.document_version STRING.match('\d+\.\d+').to_s diff --git a/relnotes/v0.27.0.md b/relnotes/v0.27.0.md new file mode 100644 index 00000000..e32377a6 --- /dev/null +++ b/relnotes/v0.27.0.md @@ -0,0 +1,16 @@ +### New features + +* [#220](https://github.com/rubocop/rubocop-minitest/issues/220): Add new `Minitest/NonPublicTestMethod` cop. ([@fatkodima][]) + +### Bug fixes + +* [#237](https://github.com/rubocop/rubocop-minitest/pull/237): Fix a false positive for `Minitest/UselessAssertion` when using command execution. ([@fatkodima][]) + +### Changes + +* [#234](https://github.com/rubocop/rubocop-minitest/pull/234): Mark `Minitest/AssertTruthy` as unsafe. ([@koic][]) +* [#233](https://github.com/rubocop/rubocop-minitest/pull/233): Mark `Minitest/RefuteFalse` as unsafe. ([@koic][]) +* [#231](https://github.com/rubocop/rubocop-minitest/pull/231): Change what is considered a test case by `rubocop-minitest` (`public` method without arguments with `test_` name prefix). ([@fatkodima][]) + +[@fatkodima]: https://github.com/fatkodima +[@koic]: https://github.com/koic