Skip to content

Commit

Permalink
Merge pull request #110 from koic/add_required_ruby_version_to_cops_m…
Browse files Browse the repository at this point in the history
…anual

Add required Ruby version to generated cops manual
  • Loading branch information
koic committed May 21, 2020
2 parents 31aa377 + c9b34c2 commit cbee419
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions manual/cops_performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Performance/BindCall

!!! Note

Required Ruby version: 2.7

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | Yes | 1.6 | -
Expand Down Expand Up @@ -253,6 +257,10 @@ Model.select(:value).count

## Performance/DeletePrefix

!!! Note

Required Ruby version: 2.5

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | Yes | 1.6 | -
Expand Down Expand Up @@ -281,6 +289,10 @@ str.delete_prefix!('prefix')

## Performance/DeleteSuffix

!!! Note

Required Ruby version: 2.5

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | Yes | 1.6 | -
Expand Down
12 changes: 12 additions & 0 deletions tasks/cops_documentation.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do

def cops_body(config, cop, description, examples_objects, pars)
content = h2(cop.cop_name)
content << required_ruby_version(cop)
content << properties(config, cop)
content << "#{description}\n"
content << examples(examples_objects) if examples_objects.count.positive?
Expand All @@ -32,6 +33,17 @@ task generate_cops_documentation: :yard_for_generate_documentation do
end
end

def required_ruby_version(cop)
return '' unless cop.respond_to?(:required_minimum_ruby_version)

<<~NOTE
!!! Note
Required Ruby version: #{cop.required_minimum_ruby_version}
NOTE
end

# rubocop:disable Metrics/MethodLength
def properties(config, cop)
header = [
Expand Down

0 comments on commit cbee419

Please sign in to comment.