rubocop-minitest 0.17.0 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f04d27399103835be508a28975344afe09018c9f480217824f65c0c43be34b3d
4
- data.tar.gz: 3021b9fa8b826d056b69d2c91b6d447dc66a3acecc82bf439a2931e6f25ea9f6
3
+ metadata.gz: 06bac8581123850a3beb2e5f9e740279d6ef05889119afd4418d1d079b357b6e
4
+ data.tar.gz: e0257e30d0b413979b7ce990beae6fc685e3f12161f97ed3fc8391dd023544b2
5
5
  SHA512:
6
- metadata.gz: 61ae0ab74e4a736221044989b3ef08e5c743b6cd43024c6ed236e276a4fefb0ec6c3fd23232f401ef205d0db5e8575c8cb1b85b31186a8e26c7be031e65f9772
7
- data.tar.gz: a574a9d994741b69bf4280b91ef7321498aeeaec391cdfee7784230baf55a0d45bf4013a8395418b96b442a39fb13b5a33fa23b8bb03d2cce92bb77c040317c9
6
+ metadata.gz: a358ed867fb7a16f3430835a11560c1159940c67b66627db9116d4cf6c45efd2519701f93c8333ed722d1c296bd527ea7b52c970ba472056b7170f363d95ae05
7
+ data.tar.gz: a22c800e537e5461cb7446d88e60e3a73f7ac63119c72d4acc32d72707670550b16cb7e1f015668d35dcca7a746f947f93df2a4ee6db571ad23f0f0c17766475
data/.circleci/config.yml CHANGED
@@ -37,16 +37,19 @@ workflows:
37
37
  - documentation-checks
38
38
  - rake_default:
39
39
  name: Ruby 2.5
40
- image: circleci/ruby:2.5
40
+ image: cimg/ruby:2.5
41
41
  - rake_default:
42
42
  name: Ruby 2.6
43
- image: circleci/ruby:2.6
43
+ image: cimg/ruby:2.6
44
44
  - rake_default:
45
45
  name: Ruby 2.7
46
- image: circleci/ruby:2.7
46
+ image: cimg/ruby:2.7
47
47
  - rake_default:
48
48
  name: Ruby 3.0
49
- image: circleci/ruby:3.0
49
+ image: cimg/ruby:3.0
50
+ - rake_default:
51
+ name: Ruby 3.1
52
+ image: cimg/ruby:3.1
50
53
  - rake_default:
51
54
  name: Ruby HEAD
52
55
  image: rubocophq/circleci-ruby-snapshot:latest # Nightly snapshot build
@@ -5,14 +5,13 @@ The more detailed you are, the better.**
5
5
 
6
6
  Before submitting the PR make sure the following are checked:
7
7
 
8
+ * [ ] The PR relates to *only* one subject with a clear title and description in grammatically correct, complete sentences.
8
9
  * [ ] Wrote [good commit messages][1].
9
10
  * [ ] Commit message starts with `[Fix #issue-number]` (if the related issue exists).
10
11
  * [ ] Feature branch is up-to-date with `master` (if not - rebase it).
11
12
  * [ ] Squashed related commits together.
12
13
  * [ ] Added tests.
14
+ * [ ] Ran `bundle exec rake default`. It executes all tests and runs RuboCop on its own code.
13
15
  * [ ] Added an entry (file) to the [changelog folder](https://github.com/rubocop/rubocop-minitest/blob/master/changelog/) named `{change_type}_{change_description}.md` if the new code introduces user-observable changes. See [changelog entry format](https://github.com/rubocop/rubocop/blob/master/CONTRIBUTING.md#changelog-entry-format) for details.
14
- * [ ] The PR relates to *only* one subject with a clear title
15
- and description in grammatically correct, complete sentences.
16
- * [ ] Run `bundle exec rake default`. It executes all tests and RuboCop for itself, and generates the documentation.
17
16
 
18
17
  [1]: https://chris.beams.io/posts/git-commit/
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.17.1 (2022-01-30)
6
+
7
+ ### Changes
8
+
9
+ * [#158](https://github.com/rubocop/rubocop-minitest/pull/158): Make `Minitest/UnreachableAssertion` aware of `assert` and `refute` prefix methods. ([@koic][])
10
+
5
11
  ## 0.17.0 (2021-11-23)
6
12
 
7
13
  ### New features
data/Gemfile CHANGED
@@ -11,3 +11,6 @@ gem 'rake'
11
11
  gem 'rubocop', github: 'rubocop/rubocop'
12
12
  gem 'rubocop-performance', '~> 1.12.0'
13
13
  gem 'yard', '~> 0.9'
14
+
15
+ local_gemfile = File.expand_path('Gemfile.local', __dir__)
16
+ eval_gemfile local_gemfile if File.exist?(local_gemfile)
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019-2021 Bozhidar Batsov, Jonas Arvidsson, Koichi ITO
3
+ Copyright (c) 2019-2022 Bozhidar Batsov, Jonas Arvidsson, Koichi ITO
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -48,7 +48,7 @@ task :new_cop, [:cop] do |_task, args|
48
48
  generator.write_source
49
49
  generator.write_test
50
50
  generator.inject_require(root_file_path: 'lib/rubocop/cop/minitest_cops.rb')
51
- generator.inject_config(config_file_path: 'config/default.yml', version_added: bump_minor_version)
51
+ generator.inject_config(config_file_path: 'config/default.yml')
52
52
 
53
53
  puts generator.todo
54
54
  end
@@ -11,5 +11,5 @@ or if you use bundler put this in your `Gemfile`
11
11
 
12
12
  [source,ruby]
13
13
  ----
14
- gem 'rubocop-minitest'
14
+ gem 'rubocop-minitest', require: false
15
15
  ----
@@ -30,7 +30,7 @@ module RuboCop
30
30
 
31
31
  lifecycle_hooks(class_node).each do |hook_node|
32
32
  hook_node.each_descendant(:send) do |node|
33
- if assertion?(node)
33
+ if assertion_method?(node)
34
34
  message = format(MSG, assertion: node.method_name, hook: hook_node.method_name)
35
35
  add_offense(node, message: message)
36
36
  end
@@ -50,7 +50,7 @@ module RuboCop
50
50
  private
51
51
 
52
52
  def assertions_count(node)
53
- base = assertion?(node) ? 1 : 0
53
+ base = assertion_method?(node) ? 1 : 0
54
54
  base + node.each_child_node.sum { |c| assertions_count(c) }
55
55
  end
56
56
 
@@ -39,7 +39,7 @@ module RuboCop
39
39
  private
40
40
 
41
41
  def assertions_count(node)
42
- base = assertion?(node) ? 1 : 0
42
+ base = assertion_method?(node) ? 1 : 0
43
43
  base + node.each_child_node.sum { |c| assertions_count(c) }
44
44
  end
45
45
  end
@@ -30,11 +30,9 @@ module RuboCop
30
30
 
31
31
  last_node = body.begin_type? ? body.children.last : body
32
32
  return unless last_node.send_type?
33
+ return unless assertion_method?(last_node)
33
34
 
34
- method_name = last_node.method_name
35
- return unless assertion_method?(method_name)
36
-
37
- add_offense(last_node, message: format(MSG, assertion_method: method_name))
35
+ add_offense(last_node, message: format(MSG, assertion_method: last_node.method_name))
38
36
  end
39
37
  end
40
38
  end
@@ -10,17 +10,6 @@ module RuboCop
10
10
 
11
11
  ASSERTION_PREFIXES = %w[assert refute].freeze
12
12
 
13
- ASSERTION_METHODS = %i[
14
- assert assert_empty assert_equal assert_in_delta assert_in_epsilon assert_includes assert_instance_of
15
- assert_kind_of assert_match assert_nil assert_operator assert_output assert_path_exists assert_predicate
16
- assert_raises assert_respond_to assert_same assert_send assert_silent assert_throws
17
- refute refute_empty refute_equal refute_in_delta refute_in_epsilon refute_includes refute_instance_of
18
- refute_kind_of refute_match refute_nil refute_operator refute_path_exists refute_predicate
19
- refute_respond_to refute_same
20
- ].freeze
21
-
22
- FLUNK = 'flunk'
23
-
24
13
  LIFECYCLE_HOOK_METHODS = %i[
25
14
  before_setup
26
15
  setup
@@ -84,19 +73,18 @@ module RuboCop
84
73
  method_def.each_child_node(:send)
85
74
  end
86
75
 
87
- send_nodes.select { |send_node| assertion?(send_node) }
76
+ send_nodes.select { |send_node| assertion_method?(send_node) }
88
77
  end
89
78
 
90
- def assertion?(node)
91
- node.send_type? &&
92
- ASSERTION_PREFIXES.any? do |prefix|
93
- method_name = node.method_name.to_s
94
- method_name == FLUNK || method_name.start_with?(prefix)
95
- end
96
- end
79
+ def assertion_method?(node)
80
+ return false unless node.send_type?
81
+
82
+ ASSERTION_PREFIXES.any? do |prefix|
83
+ method_name = node.method_name
97
84
 
98
- def assertion_method?(method_name)
99
- method_name == FLUNK || ASSERTION_METHODS.include?(method_name)
85
+ # TODO: Remove the fllowing `to_s` since Ruby 2.7 that supports `Symbol#start_with?`.
86
+ method_name.to_s.start_with?(prefix) || node.method?(:flunk)
87
+ end
100
88
  end
101
89
 
102
90
  def lifecycle_hook_method?(node)
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Minitest
5
5
  # This module holds the RuboCop Minitest version information.
6
6
  module Version
7
- STRING = '0.17.0'
7
+ STRING = '0.17.1'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
data/mkdocs.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  site_name: "A RuboCop extension focused on enforcing Minitest best practices and coding conventions."
2
2
  repo_url: https://github.com/rubocop/rubocop-minitest
3
3
  edit_uri: edit/master/legacy-docs/
4
- copyright: "Copyright © 2021 Bozhidar Batsov, Jonas Arvidsson, Koichi ITO, and RuboCop contributors"
4
+ copyright: "Copyright © 2022 Bozhidar Batsov, Jonas Arvidsson, Koichi ITO, and RuboCop contributors"
5
5
  docs_dir: legacy-docs
6
6
  pages:
7
7
  - Home: index.md
@@ -0,0 +1,5 @@
1
+ ### Changes
2
+
3
+ * [#158](https://github.com/rubocop/rubocop-minitest/pull/158): Make `Minitest/UnreachableAssertion` aware of `assert` and `refute` prefix methods. ([@koic][])
4
+
5
+ [@koic]: https://github.com/koic
@@ -12,12 +12,12 @@ end
12
12
 
13
13
  task update_cops_documentation: :yard_for_generate_documentation do
14
14
  deps = ['Minitest']
15
- CopsDocumentationGenerator.new(departments: deps).call
16
- end
17
15
 
18
- desc 'Generate docs of all cops departments (obsolete)'
19
- task :generate_cops_documentation do
20
- puts 'Updating the documentation is now done automatically!'
16
+ # NOTE: Update `<<next>>` version for docs/modules/ROOT/pages/cops_minitest.adoc
17
+ # when running release tasks.
18
+ RuboCop::Minitest::Inject.defaults!
19
+
20
+ CopsDocumentationGenerator.new(departments: deps).call
21
21
  end
22
22
 
23
23
  desc 'Syntax check for the documentation comments'
@@ -39,7 +39,7 @@ namespace :cut_release do
39
39
 
40
40
  File.open('docs/antora.yml', 'w') do |f|
41
41
  f << antora_metadata.sub(
42
- 'version: master',
42
+ "version: 'master'",
43
43
  "version: '#{version_sans_patch(new_version)}'"
44
44
  )
45
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-11-22 00:00:00.000000000 Z
13
+ date: 2022-01-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -152,6 +152,7 @@ files:
152
152
  - relnotes/v0.15.2.md
153
153
  - relnotes/v0.16.0.md
154
154
  - relnotes/v0.17.0.md
155
+ - relnotes/v0.17.1.md
155
156
  - relnotes/v0.2.0.md
156
157
  - relnotes/v0.2.1.md
157
158
  - relnotes/v0.3.0.md
@@ -196,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
197
  - !ruby/object:Gem::Version
197
198
  version: '0'
198
199
  requirements: []
199
- rubygems_version: 3.3.0.dev
200
+ rubygems_version: 3.3.3
200
201
  signing_key:
201
202
  specification_version: 4
202
203
  summary: Automatic Minitest code style checking tool.