rubocop-minitest 0.10.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +18 -3
- data/.github/ISSUE_TEMPLATE/bug_report.md +5 -1
- data/.rubocop.yml +5 -1
- data/.rubocop_todo.yml +8 -7
- data/CHANGELOG.md +95 -50
- data/CONTRIBUTING.md +3 -3
- data/Gemfile +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +18 -2
- data/Rakefile +1 -1
- data/bin/console +2 -0
- data/config/default.yml +15 -4
- data/docs/antora.yml +1 -1
- data/docs/modules/ROOT/pages/cops.adoc +14 -1
- data/docs/modules/ROOT/pages/cops_minitest.adoc +79 -8
- data/docs/modules/ROOT/pages/index.adoc +1 -1
- data/legacy-docs/cops_minitest.md +16 -16
- data/legacy-docs/index.md +1 -1
- data/lib/rubocop/cop/minitest/assert_empty.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_empty_literal.rb +12 -16
- data/lib/rubocop/cop/minitest/assert_equal.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_in_delta.rb +4 -1
- data/lib/rubocop/cop/minitest/assert_includes.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_instance_of.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_kind_of.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_match.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_nil.rb +5 -11
- data/lib/rubocop/cop/minitest/assert_output.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_path_exists.rb +6 -12
- data/lib/rubocop/cop/minitest/assert_respond_to.rb +1 -1
- data/lib/rubocop/cop/minitest/assert_silent.rb +8 -6
- data/lib/rubocop/cop/minitest/assert_truthy.rb +5 -11
- data/lib/rubocop/cop/minitest/assert_with_expected_argument.rb +41 -0
- data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +1 -1
- data/lib/rubocop/cop/minitest/global_expectations.rb +6 -7
- data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +15 -14
- data/lib/rubocop/cop/minitest/multiple_assertions.rb +2 -2
- data/lib/rubocop/cop/minitest/no_assertions.rb +48 -0
- data/lib/rubocop/cop/minitest/refute_empty.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_equal.rb +7 -8
- data/lib/rubocop/cop/minitest/refute_false.rb +15 -22
- data/lib/rubocop/cop/minitest/refute_in_delta.rb +4 -1
- data/lib/rubocop/cop/minitest/refute_includes.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_instance_of.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_kind_of.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_match.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_nil.rb +4 -8
- data/lib/rubocop/cop/minitest/refute_path_exists.rb +6 -12
- data/lib/rubocop/cop/minitest/refute_respond_to.rb +1 -1
- data/lib/rubocop/cop/minitest/test_method_name.rb +18 -8
- data/lib/rubocop/cop/minitest/unspecified_exception.rb +1 -1
- data/lib/rubocop/cop/minitest_cops.rb +2 -0
- data/lib/rubocop/cop/mixin/in_delta_mixin.rb +5 -15
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +13 -13
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +27 -3
- data/lib/rubocop/minitest/version.rb +8 -1
- data/mkdocs.yml +2 -2
- data/relnotes/v0.1.0.md +1 -1
- data/relnotes/v0.10.0.md +12 -12
- data/relnotes/v0.10.1.md +1 -1
- data/relnotes/v0.10.2.md +5 -0
- data/relnotes/v0.10.3.md +5 -0
- data/relnotes/v0.11.0.md +16 -0
- data/relnotes/v0.11.1.md +5 -0
- data/relnotes/v0.12.0.md +10 -0
- data/relnotes/v0.2.0.md +4 -4
- data/relnotes/v0.2.1.md +1 -1
- data/relnotes/v0.3.0.md +6 -6
- data/relnotes/v0.4.0.md +5 -5
- data/relnotes/v0.4.1.md +1 -1
- data/relnotes/v0.5.0.md +1 -1
- data/relnotes/v0.5.1.md +1 -1
- data/relnotes/v0.6.0.md +1 -1
- data/relnotes/v0.6.1.md +2 -2
- data/relnotes/v0.6.2.md +1 -1
- data/relnotes/v0.7.0.md +5 -5
- data/relnotes/v0.8.0.md +4 -4
- data/relnotes/v0.8.1.md +1 -1
- data/relnotes/v0.9.0.md +3 -3
- data/rubocop-minitest.gemspec +7 -7
- data/tasks/cops_documentation.rake +24 -304
- metadata +28 -15
data/relnotes/v0.1.0.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
### New features
|
2
2
|
|
3
3
|
* Create RuboCop Minitest gem. ([@koic][])
|
4
|
-
* [#6](https://github.com/rubocop
|
4
|
+
* [#6](https://github.com/rubocop/rubocop-minitest/pull/6): Add new `Minitest/AssertNil` cop. ([@duduribeiro ][])
|
5
5
|
|
6
6
|
[@koic]: https://github.com/koic
|
7
7
|
[@duduribeiro]: https://github.com/duduribeiro
|
data/relnotes/v0.10.0.md
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
### New features
|
2
2
|
|
3
|
-
* [#92](https://github.com/rubocop
|
4
|
-
* [#95](https://github.com/rubocop
|
5
|
-
* [#91](https://github.com/rubocop
|
6
|
-
* [#89](https://github.com/rubocop
|
7
|
-
* [#83](https://github.com/rubocop
|
8
|
-
* [#88](https://github.com/rubocop
|
9
|
-
* [#87](https://github.com/rubocop
|
10
|
-
* [#96](https://github.com/rubocop
|
11
|
-
* [#98](https://github.com/rubocop
|
12
|
-
* [#84](https://github.com/rubocop
|
13
|
-
* [#85](https://github.com/rubocop
|
3
|
+
* [#92](https://github.com/rubocop/rubocop-minitest/pull/92): Add new `Minitest/LiteralAsActualArgument` cop. ([@fatkodima][], [@tsmmark][])
|
4
|
+
* [#95](https://github.com/rubocop/rubocop-minitest/pull/95): Add new `Minitest/AssertionInLifecycleHook` cop. ([@fatkodima][])
|
5
|
+
* [#91](https://github.com/rubocop/rubocop-minitest/pull/91): Add new `Minitest/AssertInDelta` and `Minitest/RefuteInDelta` cops. ([@fatkodima][])
|
6
|
+
* [#89](https://github.com/rubocop/rubocop-minitest/pull/89): Add new `Minitest/TestMethodName` cop. ([@fatkodima][])
|
7
|
+
* [#83](https://github.com/rubocop/rubocop-minitest/pull/83): New cops `AssertPathExists` and `RefutePathExists` check for use of `assert_path_exists`/`refute_path_exists` instead of `assert(File.exist?(path))`/`refute(File.exist?(path))`. ([@fatkodima][])
|
8
|
+
* [#88](https://github.com/rubocop/rubocop-minitest/pull/88): Add new `Minitest/MultipleAssertions` cop. ([@fatkodima][])
|
9
|
+
* [#87](https://github.com/rubocop/rubocop-minitest/pull/87): Add new `Minitest/AssertSilent` cop. ([@fatkodima][])
|
10
|
+
* [#96](https://github.com/rubocop/rubocop-minitest/pull/96): Add new `Minitest/UnspecifiedException` cop. ([@fatkodima][])
|
11
|
+
* [#98](https://github.com/rubocop/rubocop-minitest/pull/98): Add new `Minitest/AssertOutput` cop. ([@fatkodima][])
|
12
|
+
* [#84](https://github.com/rubocop/rubocop-minitest/pull/84): New cops `AssertKindOf` and `RefuteKindOf` check for use of `assert_kind_of`/`refute_kind_of` instead of `assert(foo.kind_of?(Class))`/`refute(foo.kind_of?(Class))`. ([@fatkodima][])
|
13
|
+
* [#85](https://github.com/rubocop/rubocop-minitest/pull/85): Add autocorrect to `Rails/AssertEmptyLiteral` cop. ([@fatkodima][])
|
14
14
|
|
15
15
|
### Changes
|
16
16
|
|
17
|
-
* [#104](https://github.com/rubocop
|
17
|
+
* [#104](https://github.com/rubocop/rubocop-minitest/pull/104): Require RuboCop 0.87 or higher. ([@koic][])
|
18
18
|
|
19
19
|
[@fatkodima]: https://github.com/fatkodima
|
20
20
|
[@tsmmark]: https://github.com/tsmmark
|
data/relnotes/v0.10.1.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
### Bug fixes
|
2
2
|
|
3
|
-
* [#106](https://github.com/rubocop
|
3
|
+
* [#106](https://github.com/rubocop/rubocop-minitest/issues/106): Fix an error for `Minitest/AssertOutput` when using gvar at top level. ([@koic][])
|
4
4
|
|
5
5
|
[@koic]: https://github.com/koic
|
data/relnotes/v0.10.2.md
ADDED
data/relnotes/v0.10.3.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
### Bug fixes
|
2
|
+
|
3
|
+
* [#115](https://github.com/rubocop/rubocop-minitest/issues/115): Fix a false positive for `Minitest/TestMethodName` for when defining test method has an argument, and test method without assertion methods. ([@koic][])
|
4
|
+
|
5
|
+
[@koic]: https://github.com/koic
|
data/relnotes/v0.11.0.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
### New features
|
2
|
+
|
3
|
+
* [#117](https://github.com/rubocop/rubocop-minitest/issues/117): Add new cop `Minitest/AssertWithExpectedArgument` to check for unintended usages of `assert` instead of `assert_equal`. ([@cstyles][])
|
4
|
+
|
5
|
+
### Bug fixes
|
6
|
+
|
7
|
+
* [#122](https://github.com/rubocop/rubocop-minitest/pull/122): Fix `Minitest/TestMethodName` for tests with multiple assertions. ([@ghiculescu][])
|
8
|
+
|
9
|
+
### Changes
|
10
|
+
|
11
|
+
* [#118](https://github.com/rubocop/rubocop-minitest/pull/118): **(BREAKING)** Fix `Minitest/AssertEmptyLiteral` by making it check for `assert_equal([], array)` instead of `assert([], array)`. ([@cstyles][])
|
12
|
+
* [#125](https://github.com/rubocop/rubocop-minitest/pull/125): Require RuboCop 0.90 or higher. ([@koic][])
|
13
|
+
|
14
|
+
[@cstyles]: https://github.com/cstyles
|
15
|
+
[@ghiculescu]: https://github.com/ghiculescu
|
16
|
+
[@koic]: https://github.com/koic
|
data/relnotes/v0.11.1.md
ADDED
data/relnotes/v0.12.0.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
### New features
|
2
|
+
|
3
|
+
* [#124](https://github.com/rubocop/rubocop-minitest/pull/124): Add new `Minitest/NoAssertions` cop. ([@ghiculescu][])
|
4
|
+
|
5
|
+
### Changes
|
6
|
+
|
7
|
+
* [#129](https://github.com/rubocop/rubocop-minitest/pull/129): Drop Ruby 2.4 support. ([@koic][])
|
8
|
+
|
9
|
+
[@ghiculescu]: https://github.com/ghiculescu
|
10
|
+
[@koic]: https://github.com/koic
|
data/relnotes/v0.2.0.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
### New features
|
2
2
|
|
3
|
-
* [#11](https://github.com/rubocop
|
4
|
-
* [#8](https://github.com/rubocop
|
5
|
-
* [#9](https://github.com/rubocop
|
6
|
-
* [#10](https://github.com/rubocop
|
3
|
+
* [#11](https://github.com/rubocop/rubocop-minitest/pull/11): Add new `Minitest/RefuteNil` cop. ([@tejasbubane ][])
|
4
|
+
* [#8](https://github.com/rubocop/rubocop-minitest/pull/8): Add new `Minitest/AssertTruthy` cop. ([@abhaynikam ][])
|
5
|
+
* [#9](https://github.com/rubocop/rubocop-minitest/pull/9): Add new `Minitest/AssertIncludes` cop. ([@abhaynikam ][])
|
6
|
+
* [#10](https://github.com/rubocop/rubocop-minitest/pull/10): Add new `Minitest/AssertEmpty` cop. ([@abhaynikam ][])
|
7
7
|
|
8
8
|
[@tejasbubane]: https://github.com/tejasbubane
|
9
9
|
[@abhaynikam]: https://github.com/abhaynikam
|
data/relnotes/v0.2.1.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
### Bug fixes
|
2
2
|
|
3
|
-
* [#13](https://github.com/rubocop
|
3
|
+
* [#13](https://github.com/rubocop/rubocop-minitest/issues/13): Fix the execution target specified in `Include` parameter. ([@koic][])
|
4
4
|
|
5
5
|
[@koic]: https://github.com/koic
|
data/relnotes/v0.3.0.md
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
### New features
|
4
4
|
|
5
|
-
* [#15](https://github.com/rubocop
|
6
|
-
* [#18](https://github.com/rubocop
|
7
|
-
* [#20](https://github.com/rubocop
|
8
|
-
* [#21](https://github.com/rubocop
|
9
|
-
* [#27](https://github.com/rubocop
|
5
|
+
* [#15](https://github.com/rubocop/rubocop-minitest/pull/15): Add new `Minitest/RefuteIncludes` cop. ([@abhaynikam][])
|
6
|
+
* [#18](https://github.com/rubocop/rubocop-minitest/pull/18): Add new `Minitest/RefuteFalse` cop. ([@duduribeiro][])
|
7
|
+
* [#20](https://github.com/rubocop/rubocop-minitest/pull/20): Add new `Minitest/RefuteEmpty` cop. ([@abhaynikam][])
|
8
|
+
* [#21](https://github.com/rubocop/rubocop-minitest/pull/21): Add new `Minitest/RefuteEqual` cop. ([@duduribeiro][])
|
9
|
+
* [#27](https://github.com/rubocop/rubocop-minitest/pull/27): Add new `Minitest/AssertRespondTo` cop. ([@duduribeiro][])
|
10
10
|
|
11
11
|
### Bug fixes
|
12
12
|
|
13
|
-
* [#19](https://github.com/rubocop
|
13
|
+
* [#19](https://github.com/rubocop/rubocop-minitest/pull/19): Fix a false negative for `Minitest/AssertIncludes` when using `include` method in arguments of `assert` method. ([@abhaynikam][])
|
14
14
|
|
15
15
|
[@abhaynikam]: https://github.com/abhaynikam
|
16
16
|
[@duduribeiro]: https://github.com/duduribeiro
|
data/relnotes/v0.4.0.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
### New features
|
2
2
|
|
3
|
-
* [#29](https://github.com/rubocop
|
4
|
-
* [#31](https://github.com/rubocop
|
5
|
-
* [#34](https://github.com/rubocop
|
6
|
-
* [#35](https://github.com/rubocop
|
3
|
+
* [#29](https://github.com/rubocop/rubocop-minitest/pull/29): Add new `Minitest/RefuteRespondTo` cop. ([@herwinw][])
|
4
|
+
* [#31](https://github.com/rubocop/rubocop-minitest/pull/31): Add new `Minitest/AssertEqual` cop. ([@herwinw][])
|
5
|
+
* [#34](https://github.com/rubocop/rubocop-minitest/pull/34): Add new `Minitest/AssertInstanceOf` cop. ([@abhaynikam][])
|
6
|
+
* [#35](https://github.com/rubocop/rubocop-minitest/pull/35): Add new `Minitest/RefuteInstanceOf` cop. ([@abhaynikam][])
|
7
7
|
|
8
8
|
### Bug fixes
|
9
9
|
|
10
|
-
* [#25](https://github.com/rubocop
|
10
|
+
* [#25](https://github.com/rubocop/rubocop-minitest/issues/25): Add `Enabled: true` to `Minitest` department config to suppress `Warning: Minitest does not support Enabled parameter`. ([@koic][])
|
11
11
|
|
12
12
|
[@herwinw]: https://github.com/herwinw
|
13
13
|
[@abhaynikam]: https://github.com/abhaynikam
|
data/relnotes/v0.4.1.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
### Bug fixes
|
2
2
|
|
3
|
-
* [#39](https://github.com/rubocop
|
3
|
+
* [#39](https://github.com/rubocop/rubocop-minitest/issues/39): Fix an incorrect autocorrect for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo` when using assertion method calling `respond_to` with receiver omitted. ([@koic][])
|
4
4
|
|
5
5
|
[@koic]: https://github.com/koic
|
data/relnotes/v0.5.0.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
### New features
|
2
2
|
|
3
|
-
* [#32](https://github.com/rubocop
|
3
|
+
* [#32](https://github.com/rubocop/rubocop-minitest/issues/32): Add new `Minitest/AssertEmptyLiteral` cop. ([@tejasbubane][])
|
4
4
|
|
5
5
|
[@tejasbubane]: https://github.com/tejasbubane
|
data/relnotes/v0.5.1.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
### Bug fixes
|
2
2
|
|
3
|
-
* [#42](https://github.com/rubocop
|
3
|
+
* [#42](https://github.com/rubocop/rubocop-minitest/issues/42): Fix an incorrect autocorrect for some cops of `Minitest` department when using heredoc message. ([@koic][])
|
4
4
|
|
5
5
|
[@koic]: https://github.com/koic
|
data/relnotes/v0.6.0.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
### New features
|
2
2
|
|
3
|
-
* [#49](https://github.com/rubocop
|
3
|
+
* [#49](https://github.com/rubocop/rubocop-minitest/pull/49): New cops `AssertMatch` and `RefuteMatch` check for use of `assert_match`/`refute_match` instead of `assert(foo.match(bar))`/`refute(foo.match(bar))`. ([@fsateler][])
|
4
4
|
|
5
5
|
[@fsateler]: https://github.com/fsateler
|
data/relnotes/v0.6.1.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### Bug fixes
|
2
2
|
|
3
|
-
* [#52](https://github.com/rubocop
|
4
|
-
* [#52](https://github.com/rubocop
|
3
|
+
* [#52](https://github.com/rubocop/rubocop-minitest/issues/52): Make `Minitest/RefuteFalse` cop aware of `assert(!test)`. ([@koic][])
|
4
|
+
* [#52](https://github.com/rubocop/rubocop-minitest/issues/52): Fix a false negative for `Minitest/AssertIncludes` and `Minitest/RefuteIncludes` when an argument is enclosed in redundant parentheses. ([@koic][])
|
5
5
|
|
6
6
|
[@koic]: https://github.com/koic
|
data/relnotes/v0.6.2.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
### Bug fixes
|
2
2
|
|
3
|
-
* [#55](https://github.com/rubocop
|
3
|
+
* [#55](https://github.com/rubocop/rubocop-minitest/issues/55): Fix an error for `Minitest/AssertIncludes` when using local variable argument. ([@koic][])
|
4
4
|
|
5
5
|
[@koic]: https://github.com/koic
|
data/relnotes/v0.7.0.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
### New features
|
2
2
|
|
3
|
-
* [#60](https://github.com/rubocop
|
3
|
+
* [#60](https://github.com/rubocop/rubocop-minitest/issues/60): Add new cop `Minitest/GlobalExpectations` to check for deprecated global expectations. ([@tejasbubane][])
|
4
4
|
|
5
5
|
### Bug fixes
|
6
6
|
|
7
|
-
* [#58](https://github.com/rubocop
|
8
|
-
* [#59](https://github.com/rubocop
|
9
|
-
* [#61](https://github.com/rubocop
|
10
|
-
* [#62](https://github.com/rubocop
|
7
|
+
* [#58](https://github.com/rubocop/rubocop-minitest/pull/58): Fix a false negative for `Minitest/AssertMatch` and `Minitest/RefuteMatch` when an argument is enclosed in redundant parentheses. ([@koic][])
|
8
|
+
* [#59](https://github.com/rubocop/rubocop-minitest/pull/59): Fix a false negative for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo` when an argument is enclosed in redundant parentheses. ([@koic][])
|
9
|
+
* [#61](https://github.com/rubocop/rubocop-minitest/pull/61): Fix a false negative for `Minitest/AssertInstanceOf` and `Minitest/RefuteInstanceOf` when an argument is enclosed in redundant parentheses. ([@koic][])
|
10
|
+
* [#62](https://github.com/rubocop/rubocop-minitest/pull/62): Fix a false negative for `Minitest/AssertEmpty` and `Minitest/RefuteEmpty` when an argument is enclosed in redundant parentheses. ([@koic][])
|
11
11
|
|
12
12
|
[@tejasbubane]: https://github.com/tejasbubane
|
13
13
|
[@koic]: https://github.com/koic
|
data/relnotes/v0.8.0.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
### New features
|
2
2
|
|
3
|
-
* [#66](https://github.com/rubocop
|
3
|
+
* [#66](https://github.com/rubocop/rubocop-minitest/issues/66): Support all expectations of `Minitest::Expectations` for `Minitest/GlobalExpectations` cop. ([@koic][])
|
4
4
|
|
5
5
|
### Bug fixes
|
6
6
|
|
7
|
-
* [#60](https://github.com/rubocop
|
8
|
-
* [#69](https://github.com/rubocop
|
9
|
-
* [#71](https://github.com/rubocop
|
7
|
+
* [#60](https://github.com/rubocop/rubocop-minitest/issues/60): Fix `Minitest/GlobalExpectations` autocorrection for chained methods. ([@tejasbubane][])
|
8
|
+
* [#69](https://github.com/rubocop/rubocop-minitest/pull/69): Fix a false negative for `Minitest/GlobalExpectations` cop when using a variable or a hash index for receiver. ([@koic][])
|
9
|
+
* [#71](https://github.com/rubocop/rubocop-minitest/pull/71): Fix a false negative for `Minitest/AssertEqual` when an argument is enclosed in redundant parentheses. ([@koic][])
|
10
10
|
|
11
11
|
[@koic]: https://github.com/koic
|
12
12
|
[@tejasbubane]: https://github.com/tejasbubane
|
data/relnotes/v0.8.1.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
### Bug fixes
|
2
2
|
|
3
|
-
* [#72](https://github.com/rubocop
|
3
|
+
* [#72](https://github.com/rubocop/rubocop-minitest/pull/72): Fix some false negatives for `Minitest/GlobalExpectations`. ([@andrykonchin][])
|
4
4
|
|
5
5
|
[@andrykonchin]: https://github.com/andrykonchin
|
data/relnotes/v0.9.0.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
### Bug fixes
|
2
2
|
|
3
|
-
* [#75](https://github.com/rubocop
|
3
|
+
* [#75](https://github.com/rubocop/rubocop-minitest/issues/75): Fix a false negative for `Minitest/GlobalExpectations` when using global expectation methods with no arguments. ([@koic][])
|
4
4
|
|
5
5
|
### Changes
|
6
6
|
|
7
|
-
* [#73](https://github.com/rubocop
|
8
|
-
* [#77](https://github.com/rubocop
|
7
|
+
* [#73](https://github.com/rubocop/rubocop-minitest/issues/73): The Minitest department works on file names end with `_test.rb` by default. ([@koic][])
|
8
|
+
* [#77](https://github.com/rubocop/rubocop-minitest/pull/77): **(BREAKING)** Drop support for Ruby 2.3. ([@koic][])
|
9
9
|
|
10
10
|
[@koic]: https://github.com/koic
|
data/rubocop-minitest.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'rubocop/minitest/version'
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'rubocop-minitest'
|
9
|
-
spec.version = RuboCop::Minitest::
|
9
|
+
spec.version = RuboCop::Minitest::Version::STRING
|
10
10
|
spec.authors = ['Bozhidar Batsov', 'Jonas Arvidsson', 'Koichi ITO']
|
11
11
|
|
12
12
|
spec.summary = 'Automatic Minitest code style checking tool.'
|
@@ -16,13 +16,13 @@ Gem::Specification.new do |spec|
|
|
16
16
|
DESCRIPTION
|
17
17
|
spec.license = 'MIT'
|
18
18
|
|
19
|
-
spec.required_ruby_version = '>= 2.
|
19
|
+
spec.required_ruby_version = '>= 2.5.0'
|
20
20
|
spec.metadata = {
|
21
21
|
'homepage_uri' => 'https://docs.rubocop.org/rubocop-minitest/',
|
22
|
-
'changelog_uri' => 'https://github.com/rubocop
|
23
|
-
'source_code_uri' => 'https://github.com/rubocop
|
24
|
-
'documentation_uri' =>
|
25
|
-
'bug_tracker_uri' => 'https://github.com/rubocop
|
22
|
+
'changelog_uri' => 'https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md',
|
23
|
+
'source_code_uri' => 'https://github.com/rubocop/rubocop-minitest',
|
24
|
+
'documentation_uri' => "https://docs.rubocop.org/rubocop-minitest/#{RuboCop::Minitest::Version.document_version}",
|
25
|
+
'bug_tracker_uri' => 'https://github.com/rubocop/rubocop-minitest/issues'
|
26
26
|
}
|
27
27
|
|
28
28
|
# Specify which files should be added to the gem when it is released.
|
@@ -34,6 +34,6 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
35
|
spec.require_paths = ['lib']
|
36
36
|
|
37
|
-
spec.add_runtime_dependency 'rubocop', '>= 0.
|
37
|
+
spec.add_runtime_dependency 'rubocop', '>= 0.90', '< 2.0'
|
38
38
|
spec.add_development_dependency 'minitest', '~> 5.11'
|
39
39
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'yard'
|
4
4
|
require 'rubocop'
|
5
5
|
require 'rubocop-minitest'
|
6
|
+
require 'rubocop/cops_documentation_generator'
|
6
7
|
|
7
8
|
YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
|
8
9
|
task.files = ['lib/rubocop/cop/**/*.rb']
|
@@ -11,302 +12,23 @@ end
|
|
11
12
|
|
12
13
|
desc 'Generate docs of all cops departments'
|
13
14
|
task generate_cops_documentation: :yard_for_generate_documentation do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def cops_body(config, cop, description, examples_objects, pars)
|
19
|
-
content = h2(cop.cop_name)
|
20
|
-
content << required_ruby_version(cop)
|
21
|
-
content << properties(cop.new(config))
|
22
|
-
content << "#{description}\n"
|
23
|
-
content << examples(examples_objects) if examples_objects.count.positive?
|
24
|
-
content << configurations(pars)
|
25
|
-
content << references(config, cop)
|
26
|
-
content
|
27
|
-
end
|
28
|
-
|
29
|
-
def examples(examples_object)
|
30
|
-
examples_object.each_with_object(h3('Examples').dup) do |example, content|
|
31
|
-
content << "\n" unless content.end_with?("\n\n")
|
32
|
-
content << h4(example.name) unless example.name == ''
|
33
|
-
content << code_example(example)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def required_ruby_version(cop)
|
38
|
-
return '' unless cop.respond_to?(:required_minimum_ruby_version)
|
39
|
-
|
40
|
-
"NOTE: Required Ruby version: #{cop.required_minimum_ruby_version}\n\n"
|
41
|
-
end
|
42
|
-
|
43
|
-
# rubocop:disable Metrics/MethodLength
|
44
|
-
def properties(cop_instance)
|
45
|
-
header = [
|
46
|
-
'Enabled by default', 'Safe', 'Supports autocorrection', 'VersionAdded',
|
47
|
-
'VersionChanged'
|
48
|
-
]
|
49
|
-
autocorrect = if cop_instance.support_autocorrect?
|
50
|
-
"Yes#{' (Unsafe)' unless cop_instance.safe_autocorrect?}"
|
51
|
-
else
|
52
|
-
'No'
|
53
|
-
end
|
54
|
-
cop_config = cop_instance.cop_config
|
55
|
-
content = [[
|
56
|
-
cop_status(cop_config.fetch('Enabled')),
|
57
|
-
cop_config.fetch('Safe', true) ? 'Yes' : 'No',
|
58
|
-
autocorrect,
|
59
|
-
cop_config.fetch('VersionAdded', '-'),
|
60
|
-
cop_config.fetch('VersionChanged', '-')
|
61
|
-
]]
|
62
|
-
"#{to_table(header, content)}\n"
|
63
|
-
end
|
64
|
-
# rubocop:enable Metrics/MethodLength
|
65
|
-
|
66
|
-
def h2(title)
|
67
|
-
content = +"\n"
|
68
|
-
content << "== #{title}\n"
|
69
|
-
content << "\n"
|
70
|
-
content
|
71
|
-
end
|
72
|
-
|
73
|
-
def h3(title)
|
74
|
-
content = +"\n"
|
75
|
-
content << "=== #{title}\n"
|
76
|
-
content << "\n"
|
77
|
-
content
|
78
|
-
end
|
79
|
-
|
80
|
-
def h4(title)
|
81
|
-
content = +"==== #{title}\n"
|
82
|
-
content << "\n"
|
83
|
-
content
|
84
|
-
end
|
85
|
-
|
86
|
-
def code_example(ruby_code)
|
87
|
-
content = +"[source,ruby]\n----\n"
|
88
|
-
content << ruby_code.text.gsub('@good', '# good')
|
89
|
-
.gsub('@bad', '# bad').strip
|
90
|
-
content << "\n----\n"
|
91
|
-
content
|
92
|
-
end
|
93
|
-
|
94
|
-
def configurations(pars)
|
95
|
-
return '' if pars.empty?
|
96
|
-
|
97
|
-
header = ['Name', 'Default value', 'Configurable values']
|
98
|
-
configs = pars
|
99
|
-
.each_key
|
100
|
-
.reject { |key| key.start_with?('Supported') }
|
101
|
-
.reject { |key| key.start_with?('AllowMultipleStyles') }
|
102
|
-
content = configs.map do |name|
|
103
|
-
configurable = configurable_values(pars, name)
|
104
|
-
default = format_table_value(pars[name])
|
105
|
-
[name, default, configurable]
|
106
|
-
end
|
107
|
-
|
108
|
-
h3('Configurable attributes') + to_table(header, content)
|
109
|
-
end
|
110
|
-
|
111
|
-
# rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
|
112
|
-
def configurable_values(pars, name)
|
113
|
-
case name
|
114
|
-
when /^Enforced/
|
115
|
-
supported_style_name = RuboCop::Cop::Util.to_supported_styles(name)
|
116
|
-
format_table_value(pars[supported_style_name])
|
117
|
-
when 'IndentationWidth'
|
118
|
-
'Integer'
|
119
|
-
else
|
120
|
-
case pars[name]
|
121
|
-
when String
|
122
|
-
'String'
|
123
|
-
when Integer
|
124
|
-
'Integer'
|
125
|
-
when Float
|
126
|
-
'Float'
|
127
|
-
when true, false
|
128
|
-
'Boolean'
|
129
|
-
when Array
|
130
|
-
'Array'
|
131
|
-
else
|
132
|
-
''
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/MethodLength
|
137
|
-
|
138
|
-
def to_table(header, content)
|
139
|
-
table = [
|
140
|
-
'|===',
|
141
|
-
"| #{header.join(' | ')}\n\n"
|
142
|
-
].join("\n")
|
143
|
-
marked_contents = content.map do |plain_content|
|
144
|
-
plain_content.map { |c| "| #{c}" }.join("\n")
|
145
|
-
end
|
146
|
-
table << marked_contents.join("\n\n")
|
147
|
-
table << "\n|===\n"
|
148
|
-
end
|
149
|
-
|
150
|
-
def format_table_value(val)
|
151
|
-
value =
|
152
|
-
case val
|
153
|
-
when Array
|
154
|
-
if val.empty?
|
155
|
-
'`[]`'
|
156
|
-
else
|
157
|
-
val.map { |config| format_table_value(config) }.join(', ')
|
158
|
-
end
|
159
|
-
else
|
160
|
-
wrap_backtick(val.nil? ? '<none>' : val)
|
161
|
-
end
|
162
|
-
value.gsub("#{Dir.pwd}/", '').rstrip
|
163
|
-
end
|
164
|
-
|
165
|
-
def wrap_backtick(value)
|
166
|
-
if value.is_a?(String)
|
167
|
-
# Use `+` to prevent text like `**/*.gemspec` from being bold.
|
168
|
-
value.start_with?('*') ? "`+#{value}+`" : "`#{value}`"
|
169
|
-
else
|
170
|
-
"`#{value}`"
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def references(config, cop)
|
175
|
-
cop_config = config.for_cop(cop)
|
176
|
-
urls = RuboCop::Cop::MessageAnnotator.new(
|
177
|
-
config, cop.name, cop_config, {}
|
178
|
-
).urls
|
179
|
-
return '' if urls.empty?
|
180
|
-
|
181
|
-
content = h3('References')
|
182
|
-
content << urls.map { |url| "* #{url}" }.join("\n")
|
183
|
-
content << "\n"
|
184
|
-
content
|
185
|
-
end
|
186
|
-
|
187
|
-
def print_cops_of_department(cops, department, config)
|
188
|
-
selected_cops = cops_of_department(cops, department).select do |cop|
|
189
|
-
cop.to_s.start_with?('RuboCop::Cop::Minitest')
|
190
|
-
end
|
191
|
-
return if selected_cops.empty?
|
192
|
-
|
193
|
-
selected_cops = cops_of_department(cops, department)
|
194
|
-
content = +"= #{department}\n"
|
195
|
-
selected_cops.each do |cop|
|
196
|
-
content << print_cop_with_doc(cop, config)
|
197
|
-
end
|
198
|
-
file_name = "#{Dir.pwd}/docs/modules/ROOT/pages/cops_#{department.downcase}.adoc"
|
199
|
-
File.open(file_name, 'w') do |file|
|
200
|
-
puts "* generated #{file_name}"
|
201
|
-
file.write("#{content.strip}\n")
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
def print_cop_with_doc(cop, config)
|
206
|
-
t = config.for_cop(cop)
|
207
|
-
non_display_keys = %w[
|
208
|
-
Description Enabled StyleGuide Reference Safe SafeAutoCorrect VersionAdded
|
209
|
-
VersionChanged
|
210
|
-
]
|
211
|
-
pars = t.reject { |k| non_display_keys.include? k }
|
212
|
-
description = 'No documentation'
|
213
|
-
examples_object = []
|
214
|
-
cop_code(cop) do |code_object|
|
215
|
-
description = code_object.docstring unless code_object.docstring.blank?
|
216
|
-
examples_object = code_object.tags('example')
|
217
|
-
end
|
218
|
-
cops_body(config, cop, description, examples_object, pars)
|
219
|
-
end
|
220
|
-
|
221
|
-
def cop_code(cop)
|
222
|
-
YARD::Registry.all(:class).detect do |code_object|
|
223
|
-
next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
|
224
|
-
|
225
|
-
yield code_object
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
# rubocop:disable Metrics/AbcSize
|
230
|
-
def table_of_content_for_department(cops, department)
|
231
|
-
selected_cops = cops_of_department(cops, department.to_sym).select do |cop|
|
232
|
-
cop.to_s.start_with?('RuboCop::Cop::Minitest')
|
233
|
-
end
|
234
|
-
return if selected_cops.empty?
|
235
|
-
|
236
|
-
type_title = department[0].upcase + department[1..-1]
|
237
|
-
filename = "cops_#{department.downcase}.adoc"
|
238
|
-
content = +"= Department xref:#{filename}[#{type_title}]\n\n"
|
239
|
-
cops_of_department(cops, department.to_sym).each do |cop|
|
240
|
-
anchor = cop.cop_name.sub('/', '').downcase
|
241
|
-
content << "* xref:#{filename}##{anchor}[#{cop.cop_name}]\n"
|
242
|
-
end
|
243
|
-
|
244
|
-
content
|
245
|
-
end
|
246
|
-
# rubocop:enable Metrics/AbcSize
|
247
|
-
|
248
|
-
def print_table_of_contents(cops)
|
249
|
-
path = "#{Dir.pwd}/docs/modules/ROOT/pages/cops.adoc"
|
250
|
-
original = File.read(path)
|
251
|
-
content = +"// START_COP_LIST\n\n"
|
252
|
-
|
253
|
-
content << table_contents(cops)
|
254
|
-
|
255
|
-
content << "\n// END_COP_LIST"
|
256
|
-
|
257
|
-
content = original.sub(
|
258
|
-
%r{// START_COP_LIST.+// END_COP_LIST}m, content
|
259
|
-
)
|
260
|
-
File.write(path, content)
|
261
|
-
end
|
262
|
-
|
263
|
-
def table_contents(cops)
|
264
|
-
cops
|
265
|
-
.departments
|
266
|
-
.map(&:to_s)
|
267
|
-
.sort
|
268
|
-
.map { |department| table_of_content_for_department(cops, department) }
|
269
|
-
.compact
|
270
|
-
.join("\n")
|
271
|
-
end
|
272
|
-
|
273
|
-
def cop_status(status)
|
274
|
-
return 'Disabled' unless status
|
275
|
-
|
276
|
-
status == 'pending' ? 'Pending' : 'Enabled'
|
277
|
-
end
|
278
|
-
|
279
|
-
def assert_docs_synchronized
|
280
|
-
# Do not print diff and yield whether exit code was zero
|
281
|
-
sh('git diff --quiet docs') do |outcome, _|
|
282
|
-
return if outcome
|
283
|
-
|
284
|
-
# Output diff before raising error
|
285
|
-
sh('GIT_PAGER=cat git diff docs')
|
286
|
-
|
287
|
-
warn 'The docs directory is out of sync. ' \
|
288
|
-
'Run `rake generate_cops_documentation` and commit the results.'
|
289
|
-
exit!
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
def main
|
294
|
-
cops = RuboCop::Cop::Cop.registry
|
295
|
-
config = RuboCop::ConfigLoader.load_file('config/default.yml')
|
15
|
+
deps = ['Minitest']
|
16
|
+
CopsDocumentationGenerator.new(departments: deps).call
|
17
|
+
end
|
296
18
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
19
|
+
desc 'Verify that documentation is up to date'
|
20
|
+
task verify_cops_documentation: :generate_cops_documentation do
|
21
|
+
# Do not print diff and yield whether exit code was zero
|
22
|
+
sh('git diff --quiet docs') do |outcome, _|
|
23
|
+
exit if outcome
|
301
24
|
|
302
|
-
|
25
|
+
# Output diff before raising error
|
26
|
+
sh('GIT_PAGER=cat git diff docs')
|
303
27
|
|
304
|
-
|
305
|
-
|
306
|
-
|
28
|
+
warn 'The docs directory is out of sync. ' \
|
29
|
+
'Run `rake generate_cops_documentation` and commit the results.'
|
30
|
+
exit!
|
307
31
|
end
|
308
|
-
|
309
|
-
main
|
310
32
|
end
|
311
33
|
|
312
34
|
desc 'Syntax check for the documentation comments'
|
@@ -315,7 +37,7 @@ task documentation_syntax_check: :yard_for_generate_documentation do
|
|
315
37
|
|
316
38
|
ok = true
|
317
39
|
YARD::Registry.load!
|
318
|
-
cops = RuboCop::Cop::
|
40
|
+
cops = RuboCop::Cop::Registry.global
|
319
41
|
cops.each do |cop|
|
320
42
|
examples = YARD::Registry.all(:class).find do |code_object|
|
321
43
|
next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
|
@@ -324,17 +46,15 @@ task documentation_syntax_check: :yard_for_generate_documentation do
|
|
324
46
|
end
|
325
47
|
|
326
48
|
examples.to_a.each do |example|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
ok = false
|
337
|
-
end
|
49
|
+
buffer = Parser::Source::Buffer.new('<code>', 1)
|
50
|
+
buffer.source = example.text
|
51
|
+
parser = Parser::Ruby25.new(RuboCop::AST::Builder.new)
|
52
|
+
parser.diagnostics.all_errors_are_fatal = true
|
53
|
+
parser.parse(buffer)
|
54
|
+
rescue Parser::SyntaxError => e
|
55
|
+
path = example.object.file
|
56
|
+
puts "#{path}: Syntax Error in an example. #{e}"
|
57
|
+
ok = false
|
338
58
|
end
|
339
59
|
end
|
340
60
|
abort unless ok
|