Skip to content

Commit

Permalink
rake generate_cops_documentation generates AsciiDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
koic authored and bbatsov committed May 31, 2020
1 parent 7ac8354 commit 73a9015
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 107 deletions.
58 changes: 29 additions & 29 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// START_COP_LIST

==== Department xref:cops_performance.adoc[Performance]
= Department xref:cops_performance.adoc[Performance]

* link:cops_performance.adoc#performancebindcall[Performance/BindCall]
* link:cops_performance.adoc#performancecaller[Performance/Caller]
* link:cops_performance.adoc#performancecasewhensplat[Performance/CaseWhenSplat]
* link:cops_performance.adoc#performancecasecmp[Performance/Casecmp]
* link:cops_performance.adoc#performancechainarrayallocation[Performance/ChainArrayAllocation]
* link:cops_performance.adoc#performancecomparewithblock[Performance/CompareWithBlock]
* link:cops_performance.adoc#performancecount[Performance/Count]
* link:cops_performance.adoc#performancedeleteprefix[Performance/DeletePrefix]
* link:cops_performance.adoc#performancedeletesuffix[Performance/DeleteSuffix]
* link:cops_performance.adoc#performancedetect[Performance/Detect]
* link:cops_performance.adoc#performancedoublestartendwith[Performance/DoubleStartEndWith]
* link:cops_performance.adoc#performanceendwith[Performance/EndWith]
* link:cops_performance.adoc#performancefixedsize[Performance/FixedSize]
* link:cops_performance.adoc#performanceflatmap[Performance/FlatMap]
* link:cops_performance.adoc#performanceinefficienthashsearch[Performance/InefficientHashSearch]
* link:cops_performance.adoc#performanceopenstruct[Performance/OpenStruct]
* link:cops_performance.adoc#performancerangeinclude[Performance/RangeInclude]
* link:cops_performance.adoc#performanceredundantblockcall[Performance/RedundantBlockCall]
* link:cops_performance.adoc#performanceredundantmatch[Performance/RedundantMatch]
* link:cops_performance.adoc#performanceredundantmerge[Performance/RedundantMerge]
* link:cops_performance.adoc#performanceregexpmatch[Performance/RegexpMatch]
* link:cops_performance.adoc#performancereverseeach[Performance/ReverseEach]
* link:cops_performance.adoc#performancesize[Performance/Size]
* link:cops_performance.adoc#performancestartwith[Performance/StartWith]
* link:cops_performance.adoc#performancestringreplacement[Performance/StringReplacement]
* link:cops_performance.adoc#performancetimesmap[Performance/TimesMap]
* link:cops_performance.adoc#performanceunfreezestring[Performance/UnfreezeString]
* link:cops_performance.adoc#performanceuridefaultparser[Performance/UriDefaultParser]
* xref:cops_performance.adoc#performancebindcall[Performance/BindCall]
* xref:cops_performance.adoc#performancecaller[Performance/Caller]
* xref:cops_performance.adoc#performancecasewhensplat[Performance/CaseWhenSplat]
* xref:cops_performance.adoc#performancecasecmp[Performance/Casecmp]
* xref:cops_performance.adoc#performancechainarrayallocation[Performance/ChainArrayAllocation]
* xref:cops_performance.adoc#performancecomparewithblock[Performance/CompareWithBlock]
* xref:cops_performance.adoc#performancecount[Performance/Count]
* xref:cops_performance.adoc#performancedeleteprefix[Performance/DeletePrefix]
* xref:cops_performance.adoc#performancedeletesuffix[Performance/DeleteSuffix]
* xref:cops_performance.adoc#performancedetect[Performance/Detect]
* xref:cops_performance.adoc#performancedoublestartendwith[Performance/DoubleStartEndWith]
* xref:cops_performance.adoc#performanceendwith[Performance/EndWith]
* xref:cops_performance.adoc#performancefixedsize[Performance/FixedSize]
* xref:cops_performance.adoc#performanceflatmap[Performance/FlatMap]
* xref:cops_performance.adoc#performanceinefficienthashsearch[Performance/InefficientHashSearch]
* xref:cops_performance.adoc#performanceopenstruct[Performance/OpenStruct]
* xref:cops_performance.adoc#performancerangeinclude[Performance/RangeInclude]
* xref:cops_performance.adoc#performanceredundantblockcall[Performance/RedundantBlockCall]
* xref:cops_performance.adoc#performanceredundantmatch[Performance/RedundantMatch]
* xref:cops_performance.adoc#performanceredundantmerge[Performance/RedundantMerge]
* xref:cops_performance.adoc#performanceregexpmatch[Performance/RegexpMatch]
* xref:cops_performance.adoc#performancereverseeach[Performance/ReverseEach]
* xref:cops_performance.adoc#performancesize[Performance/Size]
* xref:cops_performance.adoc#performancestartwith[Performance/StartWith]
* xref:cops_performance.adoc#performancestringreplacement[Performance/StringReplacement]
* xref:cops_performance.adoc#performancetimesmap[Performance/TimesMap]
* xref:cops_performance.adoc#performanceunfreezestring[Performance/UnfreezeString]
* xref:cops_performance.adoc#performanceuridefaultparser[Performance/UriDefaultParser]

// END_COP_LIST
36 changes: 15 additions & 21 deletions docs/modules/ROOT/pages/cops_performance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

== Performance/BindCall

!!! Note

Required Ruby version: 2.7
NOTE: Required Ruby version: 2.7

|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
Expand All @@ -18,11 +16,11 @@

In Ruby 2.7, `UnboundMethod#bind_call` has been added.

This cop identifies places where `+bind(obj).call(args, ...)+`
can be replaced by `+bind_call(obj, args, ...)+`.
This cop identifies places where `bind(obj).call(args, ...)`
can be replaced by `bind_call(obj, args, ...)`.

The `+bind_call(obj, args, ...)+` method is faster than
`+bind(obj).call(args, ...)+`.
The `bind_call(obj, args, ...)` method is faster than
`bind(obj).call(args, ...)`.

=== Examples

Expand Down Expand Up @@ -152,7 +150,7 @@ end

| Enabled
| No
| Yes
| Yes (Unsafe)
| 0.36
| -
|===
Expand Down Expand Up @@ -180,7 +178,7 @@ str.casecmp('ABC').zero?

=== References

* https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code[https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase--code]
* https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code

== Performance/ChainArrayAllocation

Expand Down Expand Up @@ -234,7 +232,7 @@ array
| -
|===

This cop identifies places where `+sort { |a, b| a.foo <=> b.foo }+`
This cop identifies places where `sort { |a, b| a.foo <=> b.foo }`
can be replaced by `sort_by(&:foo)`.
This cop also checks `max` and `min` methods.

Expand Down Expand Up @@ -279,14 +277,14 @@ passed to the `count` call.
`ActiveRecord` will ignore the block that is passed to `count`.
Other methods, such as `select`, will convert the association to an
array and then run the block on the array. A simple work around to
make `count` work with a block is to call `+to_a.count {...}+`.
make `count` work with a block is to call `to_a.count {...}`.

Example:
`Model.where(id: [1, 2, 3]).select { |m| m.method == true }.size`

becomes:
becomes:

`Model.where(id: [1, 2, 3]).to_a.count { |m| m.method == true }`
`Model.where(id: [1, 2, 3]).to_a.count { |m| m.method == true }`

=== Examples

Expand All @@ -312,9 +310,7 @@ Model.select(:value).count

== Performance/DeletePrefix

!!! Note

Required Ruby version: 2.5
NOTE: Required Ruby version: 2.5

|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
Expand Down Expand Up @@ -356,9 +352,7 @@ str.delete_prefix!('prefix')

== Performance/DeleteSuffix

!!! Note

Required Ruby version: 2.5
NOTE: Required Ruby version: 2.5

|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
Expand Down Expand Up @@ -638,7 +632,7 @@ This cop is used to identify usages of

| Enabled
| No
| Yes
| Yes (Unsafe)
| 0.56
| -
|===
Expand Down Expand Up @@ -731,7 +725,7 @@ end

| Enabled
| No
| Yes
| Yes (Unsafe)
| 0.36
| -
|===
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/performance/unfreeze_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Performance
# literal instead of `String#dup` and `String.new`.
# Unary plus operator is faster than `String#dup`.
#
# Note: `String.new` (without operator) is not exactly the same as `+''`.
# NOTE: `String.new` (without operator) is not exactly the same as `+''`.
# These differ in encoding. `String.new.encoding` is always `ASCII-8BIT`.
# However, `(+'').encoding` is the same as script encoding(e.g. `UTF-8`).
# So, if you expect `ASCII-8BIT` encoding, disable this cop.
Expand Down
Loading

0 comments on commit 73a9015

Please sign in to comment.