rubocop-minitest 0.8.1 → 0.10.3
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/.rubocop.yml +3 -4
- data/.rubocop_todo.yml +8 -7
- data/CHANGELOG.md +51 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +18 -2
- data/Rakefile +29 -0
- data/config/default.yml +96 -16
- data/docs/antora.yml +7 -0
- data/docs/modules/ROOT/nav.adoc +6 -0
- data/docs/modules/ROOT/pages/cops.adoc +48 -0
- data/docs/modules/ROOT/pages/cops_minitest.adoc +1021 -0
- data/docs/modules/ROOT/pages/index.adoc +5 -0
- data/docs/modules/ROOT/pages/installation.adoc +15 -0
- data/docs/modules/ROOT/pages/usage.adoc +32 -0
- data/{manual → legacy-docs}/cops.md +0 -0
- data/{manual → legacy-docs}/cops_minitest.md +0 -0
- data/{manual → legacy-docs}/index.md +0 -0
- data/{manual → legacy-docs}/installation.md +0 -0
- data/{manual → legacy-docs}/usage.md +0 -0
- data/lib/rubocop/cop/generator.rb +56 -0
- data/lib/rubocop/cop/minitest/assert_empty_literal.rb +15 -0
- data/lib/rubocop/cop/minitest/assert_in_delta.rb +27 -0
- data/lib/rubocop/cop/minitest/assert_kind_of.rb +25 -0
- data/lib/rubocop/cop/minitest/assert_output.rb +49 -0
- data/lib/rubocop/cop/minitest/assert_path_exists.rb +58 -0
- data/lib/rubocop/cop/minitest/assert_silent.rb +45 -0
- data/lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb +43 -0
- data/lib/rubocop/cop/minitest/global_expectations.rb +3 -5
- data/lib/rubocop/cop/minitest/literal_as_actual_argument.rb +52 -0
- data/lib/rubocop/cop/minitest/multiple_assertions.rb +63 -0
- data/lib/rubocop/cop/minitest/refute_equal.rb +1 -1
- data/lib/rubocop/cop/minitest/refute_in_delta.rb +27 -0
- data/lib/rubocop/cop/minitest/refute_kind_of.rb +25 -0
- data/lib/rubocop/cop/minitest/refute_path_exists.rb +58 -0
- data/lib/rubocop/cop/minitest/test_method_name.rb +79 -0
- data/lib/rubocop/cop/minitest/unspecified_exception.rb +36 -0
- data/lib/rubocop/cop/minitest_cops.rb +15 -0
- data/lib/rubocop/cop/mixin/argument_range_helper.rb +10 -0
- data/lib/rubocop/cop/mixin/in_delta_mixin.rb +50 -0
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +1 -1
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +97 -0
- data/lib/rubocop/minitest/version.rb +8 -1
- data/mkdocs.yml +3 -3
- data/relnotes/v0.10.0.md +21 -0
- data/relnotes/v0.10.1.md +5 -0
- data/relnotes/v0.10.2.md +5 -0
- data/relnotes/v0.10.3.md +5 -0
- data/relnotes/v0.9.0.md +10 -0
- data/rubocop-minitest.gemspec +5 -5
- data/tasks/cops_documentation.rake +15 -264
- data/tasks/cut_release.rake +16 -0
- metadata +52 -18
    
        data/mkdocs.yml
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            site_name: "A RuboCop extension focused on enforcing Minitest best practices and coding conventions."
         | 
| 2 2 | 
             
            repo_url: https://github.com/rubocop-hq/rubocop-minitest
         | 
| 3 | 
            -
            edit_uri: edit/master/ | 
| 4 | 
            -
            copyright: "Copyright ©  | 
| 5 | 
            -
            docs_dir:  | 
| 3 | 
            +
            edit_uri: edit/master/legacy-docs/
         | 
| 4 | 
            +
            copyright: "Copyright © 2021 Bozhidar Batsov, Jonas Arvidsson, Koichi ITO, and RuboCop contributors"
         | 
| 5 | 
            +
            docs_dir: legacy-docs
         | 
| 6 6 | 
             
            pages:
         | 
| 7 7 | 
             
            - Home: index.md
         | 
| 8 8 | 
             
            - Installation: installation.md
         | 
    
        data/relnotes/v0.10.0.md
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            ### New features
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * [#92](https://github.com/rubocop-hq/rubocop-minitest/pull/92): Add new `Minitest/LiteralAsActualArgument` cop. ([@fatkodima][], [@tsmmark][])
         | 
| 4 | 
            +
            * [#95](https://github.com/rubocop-hq/rubocop-minitest/pull/95): Add new `Minitest/AssertionInLifecycleHook` cop. ([@fatkodima][])
         | 
| 5 | 
            +
            * [#91](https://github.com/rubocop-hq/rubocop-minitest/pull/91): Add new `Minitest/AssertInDelta` and `Minitest/RefuteInDelta` cops. ([@fatkodima][])
         | 
| 6 | 
            +
            * [#89](https://github.com/rubocop-hq/rubocop-minitest/pull/89): Add new `Minitest/TestMethodName` cop. ([@fatkodima][])
         | 
| 7 | 
            +
            * [#83](https://github.com/rubocop-hq/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-hq/rubocop-minitest/pull/88): Add new `Minitest/MultipleAssertions` cop. ([@fatkodima][])
         | 
| 9 | 
            +
            * [#87](https://github.com/rubocop-hq/rubocop-minitest/pull/87): Add new `Minitest/AssertSilent` cop. ([@fatkodima][])
         | 
| 10 | 
            +
            * [#96](https://github.com/rubocop-hq/rubocop-minitest/pull/96): Add new `Minitest/UnspecifiedException` cop. ([@fatkodima][])
         | 
| 11 | 
            +
            * [#98](https://github.com/rubocop-hq/rubocop-minitest/pull/98): Add new `Minitest/AssertOutput` cop. ([@fatkodima][])
         | 
| 12 | 
            +
            * [#84](https://github.com/rubocop-hq/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-hq/rubocop-minitest/pull/85): Add autocorrect to `Rails/AssertEmptyLiteral` cop. ([@fatkodima][])
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ### Changes
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            * [#104](https://github.com/rubocop-hq/rubocop-minitest/pull/104): Require RuboCop 0.87 or higher. ([@koic][])
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            [@fatkodima]: https://github.com/fatkodima
         | 
| 20 | 
            +
            [@tsmmark]: https://github.com/tsmmark
         | 
| 21 | 
            +
            [@koic]: https://github.com/koic
         | 
    
        data/relnotes/v0.10.1.md
    ADDED
    
    
    
        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-hq/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.9.0.md
    ADDED
    
    | @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            ### Bug fixes
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * [#75](https://github.com/rubocop-hq/rubocop-minitest/issues/75): Fix a false negative for `Minitest/GlobalExpectations` when using global expectation methods with no arguments. ([@koic][])
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ### Changes
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            * [#73](https://github.com/rubocop-hq/rubocop-minitest/issues/73): The Minitest department works on file names end with `_test.rb` by default. ([@koic][])
         | 
| 8 | 
            +
            * [#77](https://github.com/rubocop-hq/rubocop-minitest/pull/77): **(BREAKING)** Drop support for Ruby 2.3. ([@koic][])
         | 
| 9 | 
            +
             | 
| 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,12 +16,12 @@ 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.4.0'
         | 
| 20 20 | 
             
              spec.metadata = {
         | 
| 21 | 
            -
                'homepage_uri' => 'https://docs.rubocop.org/ | 
| 21 | 
            +
                'homepage_uri' => 'https://docs.rubocop.org/rubocop-minitest/',
         | 
| 22 22 | 
             
                'changelog_uri' => 'https://github.com/rubocop-hq/rubocop-minitest/blob/master/CHANGELOG.md',
         | 
| 23 23 | 
             
                'source_code_uri' => 'https://github.com/rubocop-hq/rubocop-minitest',
         | 
| 24 | 
            -
                'documentation_uri' =>  | 
| 24 | 
            +
                'documentation_uri' => "https://docs.rubocop.org/rubocop-minitest/#{RuboCop::Minitest::Version.document_version}",
         | 
| 25 25 | 
             
                'bug_tracker_uri' => 'https://github.com/rubocop-hq/rubocop-minitest/issues'
         | 
| 26 26 | 
             
              }
         | 
| 27 27 |  | 
| @@ -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.87', '< 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,273 +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 << properties(config, cop)
         | 
| 21 | 
            -
                content << "#{description}\n"
         | 
| 22 | 
            -
                content << examples(examples_objects) if examples_objects.count.positive?
         | 
| 23 | 
            -
                content << configurations(pars)
         | 
| 24 | 
            -
                content << references(config, cop)
         | 
| 25 | 
            -
                content
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              def examples(examples_object)
         | 
| 29 | 
            -
                examples_object.each_with_object(h3('Examples').dup) do |example, content|
         | 
| 30 | 
            -
                  content << h4(example.name) unless example.name == ''
         | 
| 31 | 
            -
                  content << code_example(example)
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
              # rubocop:disable Metrics/MethodLength
         | 
| 36 | 
            -
              def properties(config, cop)
         | 
| 37 | 
            -
                header = [
         | 
| 38 | 
            -
                  'Enabled by default', 'Safe', 'Supports autocorrection', 'VersionAdded',
         | 
| 39 | 
            -
                  'VersionChanged'
         | 
| 40 | 
            -
                ]
         | 
| 41 | 
            -
                config = config.for_cop(cop)
         | 
| 42 | 
            -
                safe_auto_correct = config.fetch('SafeAutoCorrect', true)
         | 
| 43 | 
            -
                autocorrect = if cop.new.support_autocorrect?
         | 
| 44 | 
            -
                                "Yes #{'(Unsafe)' unless safe_auto_correct}"
         | 
| 45 | 
            -
                              else
         | 
| 46 | 
            -
                                'No'
         | 
| 47 | 
            -
                              end
         | 
| 48 | 
            -
                content = [[
         | 
| 49 | 
            -
                  config.fetch('Enabled') ? 'Enabled' : 'Disabled',
         | 
| 50 | 
            -
                  config.fetch('Safe', true) ? 'Yes' : 'No',
         | 
| 51 | 
            -
                  autocorrect,
         | 
| 52 | 
            -
                  config.fetch('VersionAdded', '-'),
         | 
| 53 | 
            -
                  config.fetch('VersionChanged', '-')
         | 
| 54 | 
            -
                ]]
         | 
| 55 | 
            -
                to_table(header, content) + "\n"
         | 
| 56 | 
            -
              end
         | 
| 57 | 
            -
              # rubocop:enable Metrics/MethodLength
         | 
| 58 | 
            -
             | 
| 59 | 
            -
              def h2(title)
         | 
| 60 | 
            -
                content = +"\n"
         | 
| 61 | 
            -
                content << "## #{title}\n"
         | 
| 62 | 
            -
                content << "\n"
         | 
| 63 | 
            -
                content
         | 
| 64 | 
            -
              end
         | 
| 65 | 
            -
             | 
| 66 | 
            -
              def h3(title)
         | 
| 67 | 
            -
                content = +"\n"
         | 
| 68 | 
            -
                content << "### #{title}\n"
         | 
| 69 | 
            -
                content << "\n"
         | 
| 70 | 
            -
                content
         | 
| 71 | 
            -
              end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
              def h4(title)
         | 
| 74 | 
            -
                content = +"#### #{title}\n"
         | 
| 75 | 
            -
                content << "\n"
         | 
| 76 | 
            -
                content
         | 
| 77 | 
            -
              end
         | 
| 78 | 
            -
             | 
| 79 | 
            -
              def code_example(ruby_code)
         | 
| 80 | 
            -
                content = +"```ruby\n"
         | 
| 81 | 
            -
                content << ruby_code.text
         | 
| 82 | 
            -
                                    .gsub('@good', '# good').gsub('@bad', '# bad').strip
         | 
| 83 | 
            -
                content << "\n```\n"
         | 
| 84 | 
            -
                content
         | 
| 85 | 
            -
              end
         | 
| 86 | 
            -
             | 
| 87 | 
            -
              def configurations(pars)
         | 
| 88 | 
            -
                return '' if pars.empty?
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                header = ['Name', 'Default value', 'Configurable values']
         | 
| 91 | 
            -
                configs = pars.each_key.reject { |key| key.start_with?('Supported') }
         | 
| 92 | 
            -
                content = configs.map do |name|
         | 
| 93 | 
            -
                  configurable = configurable_values(pars, name)
         | 
| 94 | 
            -
                  default = format_table_value(pars[name])
         | 
| 95 | 
            -
                  [name, default, configurable]
         | 
| 96 | 
            -
                end
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                h3('Configurable attributes') + to_table(header, content)
         | 
| 99 | 
            -
              end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
              # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
         | 
| 102 | 
            -
              def configurable_values(pars, name)
         | 
| 103 | 
            -
                case name
         | 
| 104 | 
            -
                when /^Enforced/
         | 
| 105 | 
            -
                  supported_style_name = RuboCop::Cop::Util.to_supported_styles(name)
         | 
| 106 | 
            -
                  format_table_value(pars[supported_style_name])
         | 
| 107 | 
            -
                when 'IndentationWidth'
         | 
| 108 | 
            -
                  'Integer'
         | 
| 109 | 
            -
                when 'Database'
         | 
| 110 | 
            -
                  format_table_value(pars['SupportedDatabases'])
         | 
| 111 | 
            -
                else
         | 
| 112 | 
            -
                  case pars[name]
         | 
| 113 | 
            -
                  when String
         | 
| 114 | 
            -
                    'String'
         | 
| 115 | 
            -
                  when Integer
         | 
| 116 | 
            -
                    'Integer'
         | 
| 117 | 
            -
                  when Float
         | 
| 118 | 
            -
                    'Float'
         | 
| 119 | 
            -
                  when true, false
         | 
| 120 | 
            -
                    'Boolean'
         | 
| 121 | 
            -
                  when Array
         | 
| 122 | 
            -
                    'Array'
         | 
| 123 | 
            -
                  else
         | 
| 124 | 
            -
                    ''
         | 
| 125 | 
            -
                  end
         | 
| 126 | 
            -
                end
         | 
| 127 | 
            -
              end
         | 
| 128 | 
            -
              # rubocop:enable Metrics/CyclomaticComplexity,Metrics/MethodLength
         | 
| 129 | 
            -
             | 
| 130 | 
            -
              def to_table(header, content)
         | 
| 131 | 
            -
                table = [
         | 
| 132 | 
            -
                  header.join(' | '),
         | 
| 133 | 
            -
                  Array.new(header.size, '---').join(' | ')
         | 
| 134 | 
            -
                ]
         | 
| 135 | 
            -
                table.concat(content.map { |c| c.join(' | ') })
         | 
| 136 | 
            -
                table.join("\n") + "\n"
         | 
| 137 | 
            -
              end
         | 
| 138 | 
            -
             | 
| 139 | 
            -
              def format_table_value(val)
         | 
| 140 | 
            -
                value =
         | 
| 141 | 
            -
                  case val
         | 
| 142 | 
            -
                  when Array
         | 
| 143 | 
            -
                    if val.empty?
         | 
| 144 | 
            -
                      '`[]`'
         | 
| 145 | 
            -
                    else
         | 
| 146 | 
            -
                      val.map { |config| format_table_value(config) }.join(', ')
         | 
| 147 | 
            -
                    end
         | 
| 148 | 
            -
                  else
         | 
| 149 | 
            -
                    "`#{val.nil? ? '<none>' : val}`"
         | 
| 150 | 
            -
                  end
         | 
| 151 | 
            -
                value.gsub("#{Dir.pwd}/", '').rstrip
         | 
| 152 | 
            -
              end
         | 
| 153 | 
            -
             | 
| 154 | 
            -
              def references(config, cop)
         | 
| 155 | 
            -
                cop_config = config.for_cop(cop)
         | 
| 156 | 
            -
                urls = RuboCop::Cop::MessageAnnotator.new(
         | 
| 157 | 
            -
                  config, cop.name, cop_config, {}
         | 
| 158 | 
            -
                ).urls
         | 
| 159 | 
            -
                return '' if urls.empty?
         | 
| 160 | 
            -
             | 
| 161 | 
            -
                content = h3('References')
         | 
| 162 | 
            -
                content << urls.map { |url| "* [#{url}](#{url})" }.join("\n")
         | 
| 163 | 
            -
                content << "\n"
         | 
| 164 | 
            -
                content
         | 
| 165 | 
            -
              end
         | 
| 166 | 
            -
             | 
| 167 | 
            -
              def print_cops_of_department(cops, department, config)
         | 
| 168 | 
            -
                selected_cops = cops_of_department(cops, department).select do |cop|
         | 
| 169 | 
            -
                  cop.to_s.start_with?('RuboCop::Cop::Minitest')
         | 
| 170 | 
            -
                end
         | 
| 171 | 
            -
                return if selected_cops.empty?
         | 
| 172 | 
            -
             | 
| 173 | 
            -
                content = +"# #{department}\n"
         | 
| 174 | 
            -
                selected_cops.each do |cop|
         | 
| 175 | 
            -
                  content << print_cop_with_doc(cop, config)
         | 
| 176 | 
            -
                end
         | 
| 177 | 
            -
                file_name = "#{Dir.pwd}/manual/cops_#{department.downcase}.md"
         | 
| 178 | 
            -
                File.open(file_name, 'w') do |file|
         | 
| 179 | 
            -
                  puts "* generated #{file_name}"
         | 
| 180 | 
            -
                  file.write(content.strip + "\n")
         | 
| 181 | 
            -
                end
         | 
| 182 | 
            -
              end
         | 
| 183 | 
            -
             | 
| 184 | 
            -
              def print_cop_with_doc(cop, config)
         | 
| 185 | 
            -
                t = config.for_cop(cop)
         | 
| 186 | 
            -
                non_display_keys = %w[
         | 
| 187 | 
            -
                  Description Enabled StyleGuide Reference Safe SafeAutoCorrect VersionAdded
         | 
| 188 | 
            -
                  VersionChanged
         | 
| 189 | 
            -
                ]
         | 
| 190 | 
            -
                pars = t.reject { |k| non_display_keys.include? k }
         | 
| 191 | 
            -
                description = 'No documentation'
         | 
| 192 | 
            -
                examples_object = []
         | 
| 193 | 
            -
                YARD::Registry.all(:class).detect do |code_object|
         | 
| 194 | 
            -
                  next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
         | 
| 195 | 
            -
             | 
| 196 | 
            -
                  description = code_object.docstring unless code_object.docstring.blank?
         | 
| 197 | 
            -
                  examples_object = code_object.tags('example')
         | 
| 198 | 
            -
                end
         | 
| 199 | 
            -
                cops_body(config, cop, description, examples_object, pars)
         | 
| 200 | 
            -
              end
         | 
| 201 | 
            -
             | 
| 202 | 
            -
              # rubocop:disable Metrics/AbcSize
         | 
| 203 | 
            -
              def table_of_content_for_department(cops, department)
         | 
| 204 | 
            -
                selected_cops = cops_of_department(cops, department.to_sym).select do |cop|
         | 
| 205 | 
            -
                  cop.to_s.start_with?('RuboCop::Cop::Minitest')
         | 
| 206 | 
            -
                end
         | 
| 207 | 
            -
                return if selected_cops.empty?
         | 
| 208 | 
            -
             | 
| 209 | 
            -
                type_title = department[0].upcase + department[1..-1]
         | 
| 210 | 
            -
                filename = "cops_#{department.downcase}.md"
         | 
| 211 | 
            -
                content = +"#### Department [#{type_title}](#{filename})\n\n"
         | 
| 212 | 
            -
                selected_cops.each do |cop|
         | 
| 213 | 
            -
                  anchor = cop.cop_name.sub('/', '').downcase
         | 
| 214 | 
            -
                  content << "* [#{cop.cop_name}](#{filename}##{anchor})\n"
         | 
| 215 | 
            -
                end
         | 
| 216 | 
            -
             | 
| 217 | 
            -
                content
         | 
| 218 | 
            -
              end
         | 
| 219 | 
            -
              # rubocop:enable Metrics/AbcSize
         | 
| 220 | 
            -
             | 
| 221 | 
            -
              def print_table_of_contents(cops)
         | 
| 222 | 
            -
                path = "#{Dir.pwd}/manual/cops.md"
         | 
| 223 | 
            -
                original = File.read(path)
         | 
| 224 | 
            -
                content = +"<!-- START_COP_LIST -->\n"
         | 
| 225 | 
            -
             | 
| 226 | 
            -
                content << table_contents(cops)
         | 
| 227 | 
            -
             | 
| 228 | 
            -
                content << "\n<!-- END_COP_LIST -->"
         | 
| 229 | 
            -
             | 
| 230 | 
            -
                content = if original.empty?
         | 
| 231 | 
            -
                            content
         | 
| 232 | 
            -
                          else
         | 
| 233 | 
            -
                            original.sub(
         | 
| 234 | 
            -
                              /<!-- START_COP_LIST -->.+<!-- END_COP_LIST -->/m, content
         | 
| 235 | 
            -
                            )
         | 
| 236 | 
            -
                          end
         | 
| 237 | 
            -
                File.write(path, content)
         | 
| 238 | 
            -
              end
         | 
| 239 | 
            -
             | 
| 240 | 
            -
              def table_contents(cops)
         | 
| 241 | 
            -
                cops
         | 
| 242 | 
            -
                  .departments
         | 
| 243 | 
            -
                  .map(&:to_s)
         | 
| 244 | 
            -
                  .sort
         | 
| 245 | 
            -
                  .map { |department| table_of_content_for_department(cops, department) }
         | 
| 246 | 
            -
                  .reject(&:nil?)
         | 
| 247 | 
            -
                  .join("\n")
         | 
| 248 | 
            -
              end
         | 
| 249 | 
            -
             | 
| 250 | 
            -
              def assert_manual_synchronized
         | 
| 251 | 
            -
                # Do not print diff and yield whether exit code was zero
         | 
| 252 | 
            -
                sh('git diff --quiet manual') do |outcome, _|
         | 
| 253 | 
            -
                  return if outcome
         | 
| 254 | 
            -
             | 
| 255 | 
            -
                  # Output diff before raising error
         | 
| 256 | 
            -
                  sh('GIT_PAGER=cat git diff manual')
         | 
| 257 | 
            -
             | 
| 258 | 
            -
                  warn 'The manual directory is out of sync. ' \
         | 
| 259 | 
            -
                    'Run `rake generate_cops_documentation` and commit the results.'
         | 
| 260 | 
            -
                  exit!
         | 
| 261 | 
            -
                end
         | 
| 262 | 
            -
              end
         | 
| 263 | 
            -
             | 
| 264 | 
            -
              def main
         | 
| 265 | 
            -
                cops   = RuboCop::Cop::Cop.registry
         | 
| 266 | 
            -
                config = RuboCop::ConfigLoader.load_file('config/default.yml')
         | 
| 15 | 
            +
              deps = ['Minitest']
         | 
| 16 | 
            +
              CopsDocumentationGenerator.new(departments: deps).call
         | 
| 17 | 
            +
            end
         | 
| 267 18 |  | 
| 268 | 
            -
             | 
| 269 | 
            -
             | 
| 270 | 
            -
             | 
| 271 | 
            -
             | 
| 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
         | 
| 272 24 |  | 
| 273 | 
            -
                 | 
| 25 | 
            +
                # Output diff before raising error
         | 
| 26 | 
            +
                sh('GIT_PAGER=cat git diff docs')
         | 
| 274 27 |  | 
| 275 | 
            -
                 | 
| 276 | 
            -
             | 
| 277 | 
            -
                 | 
| 28 | 
            +
                warn 'The docs directory is out of sync. ' \
         | 
| 29 | 
            +
                  'Run `rake generate_cops_documentation` and commit the results.'
         | 
| 30 | 
            +
                exit!
         | 
| 278 31 | 
             
              end
         | 
| 279 | 
            -
             | 
| 280 | 
            -
              main
         | 
| 281 32 | 
             
            end
         | 
| 282 33 |  | 
| 283 34 | 
             
            desc 'Syntax check for the documentation comments'
         | 
| @@ -286,7 +37,7 @@ task documentation_syntax_check: :yard_for_generate_documentation do | |
| 286 37 |  | 
| 287 38 | 
             
              ok = true
         | 
| 288 39 | 
             
              YARD::Registry.load!
         | 
| 289 | 
            -
              cops = RuboCop::Cop:: | 
| 40 | 
            +
              cops = RuboCop::Cop::Registry.global
         | 
| 290 41 | 
             
              cops.each do |cop|
         | 
| 291 42 | 
             
                examples = YARD::Registry.all(:class).find do |code_object|
         | 
| 292 43 | 
             
                  next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
         | 
    
        data/tasks/cut_release.rake
    CHANGED
    
    | @@ -35,6 +35,21 @@ namespace :cut_release do | |
| 35 35 | 
             
                end
         | 
| 36 36 | 
             
              end
         | 
| 37 37 |  | 
| 38 | 
            +
              def update_antora_yml(new_version)
         | 
| 39 | 
            +
                antora_metadata = File.read('docs/antora.yml')
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                File.open('docs/antora.yml', 'w') do |f|
         | 
| 42 | 
            +
                  f << antora_metadata.sub(
         | 
| 43 | 
            +
                    'version: master',
         | 
| 44 | 
            +
                    "version: '#{version_sans_patch(new_version)}'"
         | 
| 45 | 
            +
                  )
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              def version_sans_patch(version)
         | 
| 50 | 
            +
                version.split('.').take(2).join('.')
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 38 53 | 
             
              def new_version_changes
         | 
| 39 54 | 
             
                changelog = File.read('CHANGELOG.md')
         | 
| 40 55 | 
             
                _, _, new_changes, _older_changes = changelog.split(/^## .*$/, 4)
         | 
| @@ -54,6 +69,7 @@ namespace :cut_release do | |
| 54 69 |  | 
| 55 70 | 
             
                add_header_to_changelog(new_version)
         | 
| 56 71 | 
             
                create_release_notes(new_version)
         | 
| 72 | 
            +
                update_antora_yml(new_version)
         | 
| 57 73 |  | 
| 58 74 | 
             
                puts "Changed version from #{old_version} to #{new_version}."
         | 
| 59 75 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,16 +1,16 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rubocop-minitest
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.10.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Bozhidar Batsov
         | 
| 8 8 | 
             
            - Jonas Arvidsson
         | 
| 9 9 | 
             
            - Koichi ITO
         | 
| 10 | 
            -
            autorequire: | 
| 10 | 
            +
            autorequire:
         | 
| 11 11 | 
             
            bindir: exe
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date:  | 
| 13 | 
            +
            date: 2021-01-12 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: rubocop
         | 
| @@ -18,14 +18,20 @@ dependencies: | |
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ">="
         | 
| 20 20 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version: '0. | 
| 21 | 
            +
                    version: '0.87'
         | 
| 22 | 
            +
                - - "<"
         | 
| 23 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 24 | 
            +
                    version: '2.0'
         | 
| 22 25 | 
             
              type: :runtime
         | 
| 23 26 | 
             
              prerelease: false
         | 
| 24 27 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 28 | 
             
                requirements:
         | 
| 26 29 | 
             
                - - ">="
         | 
| 27 30 | 
             
                  - !ruby/object:Gem::Version
         | 
| 28 | 
            -
                    version: '0. | 
| 31 | 
            +
                    version: '0.87'
         | 
| 32 | 
            +
                - - "<"
         | 
| 33 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 34 | 
            +
                    version: '2.0'
         | 
| 29 35 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 30 36 | 
             
              name: minitest
         | 
| 31 37 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -43,7 +49,7 @@ dependencies: | |
| 43 49 | 
             
            description: |
         | 
| 44 50 | 
             
              Automatic Minitest code style checking tool.
         | 
| 45 51 | 
             
              A RuboCop extension focused on enforcing Minitest best practices and coding conventions.
         | 
| 46 | 
            -
            email: | 
| 52 | 
            +
            email:
         | 
| 47 53 | 
             
            executables: []
         | 
| 48 54 | 
             
            extensions: []
         | 
| 49 55 | 
             
            extra_rdoc_files: []
         | 
| @@ -66,39 +72,66 @@ files: | |
| 66 72 | 
             
            - bin/console
         | 
| 67 73 | 
             
            - bin/setup
         | 
| 68 74 | 
             
            - config/default.yml
         | 
| 75 | 
            +
            - docs/antora.yml
         | 
| 76 | 
            +
            - docs/modules/ROOT/nav.adoc
         | 
| 77 | 
            +
            - docs/modules/ROOT/pages/cops.adoc
         | 
| 78 | 
            +
            - docs/modules/ROOT/pages/cops_minitest.adoc
         | 
| 79 | 
            +
            - docs/modules/ROOT/pages/index.adoc
         | 
| 80 | 
            +
            - docs/modules/ROOT/pages/installation.adoc
         | 
| 81 | 
            +
            - docs/modules/ROOT/pages/usage.adoc
         | 
| 82 | 
            +
            - legacy-docs/cops.md
         | 
| 83 | 
            +
            - legacy-docs/cops_minitest.md
         | 
| 84 | 
            +
            - legacy-docs/index.md
         | 
| 85 | 
            +
            - legacy-docs/installation.md
         | 
| 86 | 
            +
            - legacy-docs/usage.md
         | 
| 69 87 | 
             
            - lib/rubocop-minitest.rb
         | 
| 88 | 
            +
            - lib/rubocop/cop/generator.rb
         | 
| 70 89 | 
             
            - lib/rubocop/cop/minitest/assert_empty.rb
         | 
| 71 90 | 
             
            - lib/rubocop/cop/minitest/assert_empty_literal.rb
         | 
| 72 91 | 
             
            - lib/rubocop/cop/minitest/assert_equal.rb
         | 
| 92 | 
            +
            - lib/rubocop/cop/minitest/assert_in_delta.rb
         | 
| 73 93 | 
             
            - lib/rubocop/cop/minitest/assert_includes.rb
         | 
| 74 94 | 
             
            - lib/rubocop/cop/minitest/assert_instance_of.rb
         | 
| 95 | 
            +
            - lib/rubocop/cop/minitest/assert_kind_of.rb
         | 
| 75 96 | 
             
            - lib/rubocop/cop/minitest/assert_match.rb
         | 
| 76 97 | 
             
            - lib/rubocop/cop/minitest/assert_nil.rb
         | 
| 98 | 
            +
            - lib/rubocop/cop/minitest/assert_output.rb
         | 
| 99 | 
            +
            - lib/rubocop/cop/minitest/assert_path_exists.rb
         | 
| 77 100 | 
             
            - lib/rubocop/cop/minitest/assert_respond_to.rb
         | 
| 101 | 
            +
            - lib/rubocop/cop/minitest/assert_silent.rb
         | 
| 78 102 | 
             
            - lib/rubocop/cop/minitest/assert_truthy.rb
         | 
| 103 | 
            +
            - lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb
         | 
| 79 104 | 
             
            - lib/rubocop/cop/minitest/global_expectations.rb
         | 
| 105 | 
            +
            - lib/rubocop/cop/minitest/literal_as_actual_argument.rb
         | 
| 106 | 
            +
            - lib/rubocop/cop/minitest/multiple_assertions.rb
         | 
| 80 107 | 
             
            - lib/rubocop/cop/minitest/refute_empty.rb
         | 
| 81 108 | 
             
            - lib/rubocop/cop/minitest/refute_equal.rb
         | 
| 82 109 | 
             
            - lib/rubocop/cop/minitest/refute_false.rb
         | 
| 110 | 
            +
            - lib/rubocop/cop/minitest/refute_in_delta.rb
         | 
| 83 111 | 
             
            - lib/rubocop/cop/minitest/refute_includes.rb
         | 
| 84 112 | 
             
            - lib/rubocop/cop/minitest/refute_instance_of.rb
         | 
| 113 | 
            +
            - lib/rubocop/cop/minitest/refute_kind_of.rb
         | 
| 85 114 | 
             
            - lib/rubocop/cop/minitest/refute_match.rb
         | 
| 86 115 | 
             
            - lib/rubocop/cop/minitest/refute_nil.rb
         | 
| 116 | 
            +
            - lib/rubocop/cop/minitest/refute_path_exists.rb
         | 
| 87 117 | 
             
            - lib/rubocop/cop/minitest/refute_respond_to.rb
         | 
| 118 | 
            +
            - lib/rubocop/cop/minitest/test_method_name.rb
         | 
| 119 | 
            +
            - lib/rubocop/cop/minitest/unspecified_exception.rb
         | 
| 88 120 | 
             
            - lib/rubocop/cop/minitest_cops.rb
         | 
| 89 121 | 
             
            - lib/rubocop/cop/mixin/argument_range_helper.rb
         | 
| 122 | 
            +
            - lib/rubocop/cop/mixin/in_delta_mixin.rb
         | 
| 90 123 | 
             
            - lib/rubocop/cop/mixin/minitest_cop_rule.rb
         | 
| 124 | 
            +
            - lib/rubocop/cop/mixin/minitest_exploration_helpers.rb
         | 
| 91 125 | 
             
            - lib/rubocop/minitest.rb
         | 
| 92 126 | 
             
            - lib/rubocop/minitest/inject.rb
         | 
| 93 127 | 
             
            - lib/rubocop/minitest/version.rb
         | 
| 94 | 
            -
            - manual/cops.md
         | 
| 95 | 
            -
            - manual/cops_minitest.md
         | 
| 96 | 
            -
            - manual/index.md
         | 
| 97 | 
            -
            - manual/installation.md
         | 
| 98 | 
            -
            - manual/usage.md
         | 
| 99 128 | 
             
            - mkdocs.yml
         | 
| 100 129 | 
             
            - readthedocs.yml
         | 
| 101 130 | 
             
            - relnotes/v0.1.0.md
         | 
| 131 | 
            +
            - relnotes/v0.10.0.md
         | 
| 132 | 
            +
            - relnotes/v0.10.1.md
         | 
| 133 | 
            +
            - relnotes/v0.10.2.md
         | 
| 134 | 
            +
            - relnotes/v0.10.3.md
         | 
| 102 135 | 
             
            - relnotes/v0.2.0.md
         | 
| 103 136 | 
             
            - relnotes/v0.2.1.md
         | 
| 104 137 | 
             
            - relnotes/v0.3.0.md
         | 
| @@ -112,19 +145,20 @@ files: | |
| 112 145 | 
             
            - relnotes/v0.7.0.md
         | 
| 113 146 | 
             
            - relnotes/v0.8.0.md
         | 
| 114 147 | 
             
            - relnotes/v0.8.1.md
         | 
| 148 | 
            +
            - relnotes/v0.9.0.md
         | 
| 115 149 | 
             
            - rubocop-minitest.gemspec
         | 
| 116 150 | 
             
            - tasks/cops_documentation.rake
         | 
| 117 151 | 
             
            - tasks/cut_release.rake
         | 
| 118 | 
            -
            homepage: | 
| 152 | 
            +
            homepage:
         | 
| 119 153 | 
             
            licenses:
         | 
| 120 154 | 
             
            - MIT
         | 
| 121 155 | 
             
            metadata:
         | 
| 122 | 
            -
              homepage_uri: https://docs.rubocop.org/ | 
| 156 | 
            +
              homepage_uri: https://docs.rubocop.org/rubocop-minitest/
         | 
| 123 157 | 
             
              changelog_uri: https://github.com/rubocop-hq/rubocop-minitest/blob/master/CHANGELOG.md
         | 
| 124 158 | 
             
              source_code_uri: https://github.com/rubocop-hq/rubocop-minitest
         | 
| 125 | 
            -
              documentation_uri: https://docs.rubocop.org/ | 
| 159 | 
            +
              documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.10
         | 
| 126 160 | 
             
              bug_tracker_uri: https://github.com/rubocop-hq/rubocop-minitest/issues
         | 
| 127 | 
            -
            post_install_message: | 
| 161 | 
            +
            post_install_message:
         | 
| 128 162 | 
             
            rdoc_options: []
         | 
| 129 163 | 
             
            require_paths:
         | 
| 130 164 | 
             
            - lib
         | 
| @@ -132,15 +166,15 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 132 166 | 
             
              requirements:
         | 
| 133 167 | 
             
              - - ">="
         | 
| 134 168 | 
             
                - !ruby/object:Gem::Version
         | 
| 135 | 
            -
                  version: 2. | 
| 169 | 
            +
                  version: 2.4.0
         | 
| 136 170 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 137 171 | 
             
              requirements:
         | 
| 138 172 | 
             
              - - ">="
         | 
| 139 173 | 
             
                - !ruby/object:Gem::Version
         | 
| 140 174 | 
             
                  version: '0'
         | 
| 141 175 | 
             
            requirements: []
         | 
| 142 | 
            -
            rubygems_version: 3. | 
| 143 | 
            -
            signing_key: | 
| 176 | 
            +
            rubygems_version: 3.2.4
         | 
| 177 | 
            +
            signing_key:
         | 
| 144 178 | 
             
            specification_version: 4
         | 
| 145 179 | 
             
            summary: Automatic Minitest code style checking tool.
         | 
| 146 180 | 
             
            test_files: []
         |