redi_search 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +516 -112
  3. data/lib/redi_search.rb +5 -2
  4. data/lib/redi_search/add.rb +70 -0
  5. data/lib/redi_search/alter.rb +30 -0
  6. data/lib/redi_search/create.rb +53 -0
  7. data/lib/redi_search/document.rb +71 -16
  8. data/lib/redi_search/index.rb +31 -26
  9. data/lib/redi_search/lazily_load.rb +65 -0
  10. data/lib/redi_search/log_subscriber.rb +4 -0
  11. data/lib/redi_search/model.rb +41 -18
  12. data/lib/redi_search/schema.rb +17 -8
  13. data/lib/redi_search/schema/text_field.rb +0 -2
  14. data/lib/redi_search/search.rb +22 -44
  15. data/lib/redi_search/search/clauses.rb +60 -31
  16. data/lib/redi_search/search/clauses/and.rb +17 -0
  17. data/lib/redi_search/search/clauses/application_clause.rb +18 -0
  18. data/lib/redi_search/search/clauses/boolean.rb +72 -0
  19. data/lib/redi_search/search/clauses/highlight.rb +47 -0
  20. data/lib/redi_search/search/clauses/in_order.rb +17 -0
  21. data/lib/redi_search/search/clauses/language.rb +23 -0
  22. data/lib/redi_search/search/clauses/limit.rb +27 -0
  23. data/lib/redi_search/search/clauses/no_content.rb +17 -0
  24. data/lib/redi_search/search/clauses/no_stop_words.rb +17 -0
  25. data/lib/redi_search/search/clauses/or.rb +23 -0
  26. data/lib/redi_search/search/clauses/return.rb +23 -0
  27. data/lib/redi_search/search/clauses/slop.rb +23 -0
  28. data/lib/redi_search/search/clauses/sort_by.rb +25 -0
  29. data/lib/redi_search/search/clauses/verbatim.rb +17 -0
  30. data/lib/redi_search/search/clauses/where.rb +66 -0
  31. data/lib/redi_search/search/clauses/with_scores.rb +17 -0
  32. data/lib/redi_search/search/result.rb +46 -0
  33. data/lib/redi_search/search/term.rb +4 -4
  34. data/lib/redi_search/spellcheck.rb +30 -29
  35. data/lib/redi_search/spellcheck/result.rb +44 -0
  36. data/lib/redi_search/version.rb +1 -1
  37. metadata +101 -31
  38. data/.gitignore +0 -11
  39. data/.rubocop.yml +0 -1757
  40. data/.travis.yml +0 -23
  41. data/Gemfile +0 -17
  42. data/Rakefile +0 -12
  43. data/bin/console +0 -8
  44. data/bin/publish +0 -58
  45. data/bin/setup +0 -8
  46. data/bin/test +0 -7
  47. data/lib/redi_search/document/converter.rb +0 -26
  48. data/lib/redi_search/error.rb +0 -6
  49. data/lib/redi_search/result/collection.rb +0 -22
  50. data/lib/redi_search/search/and_clause.rb +0 -15
  51. data/lib/redi_search/search/boolean_clause.rb +0 -72
  52. data/lib/redi_search/search/highlight_clause.rb +0 -43
  53. data/lib/redi_search/search/or_clause.rb +0 -21
  54. data/lib/redi_search/search/where_clause.rb +0 -66
  55. data/redi_search.gemspec +0 -48
@@ -41,10 +41,10 @@ module RediSearch
41
41
  def stringify_query
42
42
  @term.to_s.
43
43
  tr("`", "\`").
44
- then { |str| "#{'%' * fuzziness}#{str}#{'%' * fuzziness}" }.
45
- then { |str| "#{optional_operator}#{str}" }.
46
- then { |str| "#{str}#{prefix_operator}" }.
47
- then { |str| "`#{str}`" }
44
+ yield_self { |str| "#{'%' * fuzziness}#{str}#{'%' * fuzziness}" }.
45
+ yield_self { |str| "#{optional_operator}#{str}" }.
46
+ yield_self { |str| "#{str}#{prefix_operator}" }.
47
+ yield_self { |str| "`#{str}`" }
48
48
  end
49
49
 
50
50
  def stringify_range
@@ -1,52 +1,53 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "redi_search/lazily_load"
4
+ require "redi_search/spellcheck/result"
5
+
3
6
  module RediSearch
4
7
  class Spellcheck
5
- include Enumerable
8
+ include LazilyLoad
9
+ include ActiveModel::Validations
10
+
11
+ validates :distance, numericality: {
12
+ greater_than: 0, less_than: 5
13
+ }
6
14
 
7
- def initialize(index, query, distance: 1)
15
+ def initialize(index, terms, distance: 1)
8
16
  @index = index
9
- @query = query
17
+ @terms = terms
10
18
  @distance = distance
11
- @loaded = false
12
19
  end
13
20
 
14
- #:nocov:
15
- def pretty_print(printer)
16
- execute unless loaded?
21
+ private
17
22
 
18
- printer.pp(records)
19
- rescue Redis::CommandError => e
20
- printer.pp(e.message)
21
- end
22
- #:nocov:
23
+ attr_reader :documents
24
+ attr_accessor :index, :terms, :distance
23
25
 
24
- def loaded?
25
- @loaded
26
+ def command
27
+ ["SPELLCHECK", index.name, terms, "DISTANCE", distance]
26
28
  end
27
29
 
28
- def to_a
29
- execute unless loaded?
30
-
31
- @records
30
+ def parsed_terms
31
+ terms.split(Regexp.union(",.<>{}[]\"':;!@#$%^&*()-+=~\s".split("")))
32
32
  end
33
33
 
34
- delegate :count, :each, to: :to_a
35
-
36
- private
34
+ def execute
35
+ validate!
37
36
 
38
- attr_reader :records
39
- attr_accessor :index, :query, :distance
37
+ @loaded = true
40
38
 
41
- def command
42
- ["SPELLCHECK", index.name, query, "DISTANCE", distance]
39
+ RediSearch.client.call!(*command).yield_self do |response|
40
+ parse_response(response)
41
+ end
43
42
  end
44
43
 
45
- def execute
46
- @loaded = true
44
+ def parse_response(response)
45
+ suggestions = response.map do |suggestion|
46
+ suggestion[1..2]
47
+ end.to_h
47
48
 
48
- RediSearch.client.call!(*command).then do |results|
49
- @records = results
49
+ @documents = parsed_terms.map do |term|
50
+ Result.new(term, suggestions[term] || [])
50
51
  end
51
52
  end
52
53
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RediSearch
4
+ class Spellcheck
5
+ Suggestion = Struct.new(:score, :suggestion)
6
+
7
+ class Result
8
+ attr_reader :term, :suggestions
9
+
10
+ def initialize(term, suggestions)
11
+ @term = term
12
+ @suggestions = suggestions.map do |suggestion|
13
+ Suggestion.new(suggestion[0].to_f, suggestion[1])
14
+ end
15
+ end
16
+
17
+ #:nocov:
18
+ def inspect
19
+ inspection = %w(term suggestions).map do |field_name|
20
+ "#{field_name}: #{public_send(field_name)}"
21
+ end.compact.join(", ")
22
+
23
+ "#<#{self.class} #{inspection}>"
24
+ end
25
+
26
+ def pretty_print(printer) # rubocop:disable Metrics/MethodLength
27
+ printer.object_address_group(self) do
28
+ printer.seplist(
29
+ %w(term suggestions), proc { printer.text "," }
30
+ ) do |field_name|
31
+ printer.breakable " "
32
+ printer.group(1) do
33
+ printer.text field_name
34
+ printer.text ":"
35
+ printer.breakable
36
+ printer.pp public_send(field_name)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ #:nocov:
42
+ end
43
+ end
44
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RediSearch
4
- VERSION = "0.1.0"
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,57 +1,123 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redi_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-12 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '5.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.1'
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: activesupport
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
37
  - - ">="
18
38
  - !ruby/object:Gem::Version
19
- version: '0'
39
+ version: '5.1'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6.1'
20
43
  type: :runtime
21
44
  prerelease: false
22
45
  version_requirements: !ruby/object:Gem::Requirement
23
46
  requirements:
24
47
  - - ">="
25
48
  - !ruby/object:Gem::Version
26
- version: '0'
49
+ version: '5.1'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6.1'
27
53
  - !ruby/object:Gem::Dependency
28
54
  name: redis
29
55
  requirement: !ruby/object:Gem::Requirement
30
56
  requirements:
31
57
  - - ">="
32
58
  - !ruby/object:Gem::Version
33
- version: '0'
59
+ version: '4.0'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '5.0'
34
63
  type: :runtime
35
64
  prerelease: false
36
65
  version_requirements: !ruby/object:Gem::Requirement
37
66
  requirements:
38
67
  - - ">="
39
68
  - !ruby/object:Gem::Version
40
- version: '0'
69
+ version: '4.0'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '5.0'
41
73
  - !ruby/object:Gem::Dependency
42
- name: bundler
74
+ name: appraisal
43
75
  requirement: !ruby/object:Gem::Requirement
44
76
  requirements:
45
77
  - - "~>"
46
78
  - !ruby/object:Gem::Version
47
- version: '1.17'
79
+ version: '2.2'
48
80
  type: :development
49
81
  prerelease: false
50
82
  version_requirements: !ruby/object:Gem::Requirement
51
83
  requirements:
52
84
  - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '2.2'
87
+ - !ruby/object:Gem::Dependency
88
+ name: bundler
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '1.17'
94
+ - - "<"
95
+ - !ruby/object:Gem::Version
96
+ version: '3'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
53
102
  - !ruby/object:Gem::Version
54
103
  version: '1.17'
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: '3'
107
+ - !ruby/object:Gem::Dependency
108
+ name: minitest
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '5.0'
114
+ type: :development
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '5.0'
55
121
  - !ruby/object:Gem::Dependency
56
122
  name: rake
57
123
  requirement: !ruby/object:Gem::Requirement
@@ -67,34 +133,25 @@ dependencies:
67
133
  - !ruby/object:Gem::Version
68
134
  version: '12.0'
69
135
  description:
70
- email:
71
- - npezza93@gmail.com
136
+ email: npezza93@gmail.com
72
137
  executables: []
73
138
  extensions: []
74
139
  extra_rdoc_files: []
75
140
  files:
76
- - ".gitignore"
77
- - ".rubocop.yml"
78
- - ".travis.yml"
79
141
  - CODE_OF_CONDUCT.md
80
- - Gemfile
81
142
  - LICENSE.txt
82
143
  - README.md
83
- - Rakefile
84
- - bin/console
85
- - bin/publish
86
- - bin/setup
87
- - bin/test
88
144
  - lib/redi_search.rb
145
+ - lib/redi_search/add.rb
146
+ - lib/redi_search/alter.rb
89
147
  - lib/redi_search/client.rb
90
148
  - lib/redi_search/configuration.rb
149
+ - lib/redi_search/create.rb
91
150
  - lib/redi_search/document.rb
92
- - lib/redi_search/document/converter.rb
93
- - lib/redi_search/error.rb
94
151
  - lib/redi_search/index.rb
152
+ - lib/redi_search/lazily_load.rb
95
153
  - lib/redi_search/log_subscriber.rb
96
154
  - lib/redi_search/model.rb
97
- - lib/redi_search/result/collection.rb
98
155
  - lib/redi_search/schema.rb
99
156
  - lib/redi_search/schema/field.rb
100
157
  - lib/redi_search/schema/geo_field.rb
@@ -102,23 +159,36 @@ files:
102
159
  - lib/redi_search/schema/tag_field.rb
103
160
  - lib/redi_search/schema/text_field.rb
104
161
  - lib/redi_search/search.rb
105
- - lib/redi_search/search/and_clause.rb
106
- - lib/redi_search/search/boolean_clause.rb
107
162
  - lib/redi_search/search/clauses.rb
108
- - lib/redi_search/search/highlight_clause.rb
109
- - lib/redi_search/search/or_clause.rb
163
+ - lib/redi_search/search/clauses/and.rb
164
+ - lib/redi_search/search/clauses/application_clause.rb
165
+ - lib/redi_search/search/clauses/boolean.rb
166
+ - lib/redi_search/search/clauses/highlight.rb
167
+ - lib/redi_search/search/clauses/in_order.rb
168
+ - lib/redi_search/search/clauses/language.rb
169
+ - lib/redi_search/search/clauses/limit.rb
170
+ - lib/redi_search/search/clauses/no_content.rb
171
+ - lib/redi_search/search/clauses/no_stop_words.rb
172
+ - lib/redi_search/search/clauses/or.rb
173
+ - lib/redi_search/search/clauses/return.rb
174
+ - lib/redi_search/search/clauses/slop.rb
175
+ - lib/redi_search/search/clauses/sort_by.rb
176
+ - lib/redi_search/search/clauses/verbatim.rb
177
+ - lib/redi_search/search/clauses/where.rb
178
+ - lib/redi_search/search/clauses/with_scores.rb
179
+ - lib/redi_search/search/result.rb
110
180
  - lib/redi_search/search/term.rb
111
- - lib/redi_search/search/where_clause.rb
112
181
  - lib/redi_search/spellcheck.rb
182
+ - lib/redi_search/spellcheck/result.rb
113
183
  - lib/redi_search/version.rb
114
- - redi_search.gemspec
115
184
  homepage: https://github.com/npezza93/redi_search
116
185
  licenses:
117
186
  - MIT
118
187
  metadata:
188
+ github_repo: ssh://github.com/npezza93/redi_search
119
189
  homepage_uri: https://github.com/npezza93/redi_search
120
190
  source_code_uri: https://github.com/npezza93/redi_search
121
- changelog_uri: https://github.com/npezza93/redi_search/blob/master/changelog.md
191
+ changelog_uri: https://github.com/npezza93/redi_search/releases
122
192
  post_install_message:
123
193
  rdoc_options: []
124
194
  require_paths:
@@ -127,7 +197,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
197
  requirements:
128
198
  - - ">="
129
199
  - !ruby/object:Gem::Version
130
- version: '0'
200
+ version: 2.5.0
131
201
  required_rubygems_version: !ruby/object:Gem::Requirement
132
202
  requirements:
133
203
  - - ">="
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
10
- *.sqlite3
11
- *.log
data/.rubocop.yml DELETED
@@ -1,1757 +0,0 @@
1
- require: rubocop-performance
2
- AllCops:
3
- Exclude:
4
- - vendor/**/*
5
- - Gemfile.lock
6
- - db/schema.rb
7
- - node_modules/**/*
8
- - tmp/**/*
9
- - test/dummy/db/schema.rb
10
- TargetRubyVersion: 2.6
11
-
12
- # Department Bundler
13
- Bundler/DuplicatedGem:
14
- Description: Checks for duplicate gem entries in Gemfile.
15
- Enabled: true
16
-
17
- Bundler/InsecureProtocolSource:
18
- Description: The source `:gemcutter`, `:rubygems` and `:rubyforge` are deprecated because HTTP requests are insecure. Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
19
- Enabled: true
20
-
21
- Bundler/OrderedGems:
22
- Description: Gems within groups in the Gemfile should be alphabetically sorted.
23
- Enabled: true
24
-
25
- # Department Gemspec
26
- Gemspec/OrderedDependencies:
27
- Description: Dependencies in the gemspec should be alphabetically sorted.
28
- Enabled: true
29
-
30
- # Department Layout
31
- Layout/AccessModifierIndentation:
32
- Description: Check indentation of private/protected visibility modifiers.
33
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected
34
- Enabled: false
35
-
36
- Layout/AlignArray:
37
- Description: Align the elements of an array literal if they span more than one line.
38
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays
39
- Enabled: true
40
-
41
- Layout/AlignHash:
42
- Description: Align the elements of a hash literal if they span more than one line.
43
- Enabled: true
44
-
45
- Layout/AlignParameters:
46
- Description: Align the parameters of a method call if they span more than one line.
47
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-double-indent
48
- Enabled: true
49
-
50
- Layout/BlockEndNewline:
51
- Description: Put end statement of multiline block on its own line.
52
- Enabled: true
53
-
54
- Layout/CaseIndentation:
55
- Description: Indentation of when in a case/when/[else/]end.
56
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-when-to-case
57
- Enabled: true
58
-
59
- Layout/ClosingParenthesisIndentation:
60
- Description: Checks the indentation of hanging closing parentheses.
61
- Enabled: false
62
-
63
- Layout/CommentIndentation:
64
- Description: Indentation of comments.
65
- Enabled: false
66
-
67
- Layout/DotPosition:
68
- Description: Checks the position of the dot in multi-line method calls.
69
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
70
- Enabled: true
71
- EnforcedStyle: trailing
72
-
73
- Layout/ElseAlignment:
74
- Description: Align elses and elsifs correctly.
75
- Enabled: true
76
-
77
- Layout/EmptyLineBetweenDefs:
78
- Description: Use empty lines between defs.
79
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-between-methods
80
- Enabled: true
81
-
82
- Layout/EmptyLines:
83
- Description: Don't use several empty lines in a row.
84
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#two-or-more-empty-lines
85
- Enabled: true
86
-
87
- Layout/EmptyLinesAroundAccessModifier:
88
- Description: Keep blank lines around access modifiers.
89
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-around-access-modifier
90
- Enabled: false
91
-
92
- Layout/EmptyLinesAroundBeginBody:
93
- Description: Keeps track of empty lines around begin-end bodies.
94
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-around-bodies
95
- Enabled: false
96
-
97
- Layout/EmptyLinesAroundBlockBody:
98
- Description: Keeps track of empty lines around block bodies.
99
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-around-bodies
100
- Enabled: false
101
-
102
- Layout/EmptyLinesAroundClassBody:
103
- Description: Keeps track of empty lines around class bodies.
104
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-around-bodies
105
- Enabled: false
106
-
107
- Layout/EmptyLinesAroundExceptionHandlingKeywords:
108
- Description: Keeps track of empty lines around exception handling keywords.
109
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-around-bodies
110
- Enabled: false
111
-
112
- Layout/EmptyLinesAroundModuleBody:
113
- Description: Keeps track of empty lines around module bodies.
114
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-around-bodies
115
- Enabled: false
116
-
117
- Layout/EmptyLinesAroundMethodBody:
118
- Description: Keeps track of empty lines around method bodies.
119
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-around-bodies
120
- Enabled: false
121
-
122
- Layout/EndOfLine:
123
- Description: Use Unix-style line endings.
124
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#crlf
125
- Enabled: false
126
-
127
- Layout/ExtraSpacing:
128
- Description: Do not use unnecessary spacing.
129
- Enabled: true
130
-
131
- Layout/FirstArrayElementLineBreak:
132
- Description: Checks for a line break before the first element in a multi-line array.
133
- Enabled: false
134
-
135
- Layout/FirstHashElementLineBreak:
136
- Description: Checks for a line break before the first element in a multi-line hash.
137
- Enabled: false
138
-
139
- Layout/FirstMethodArgumentLineBreak:
140
- Description: Checks for a line break before the first argument in a multi-line method call.
141
- Enabled: false
142
-
143
- Layout/FirstMethodParameterLineBreak:
144
- Description: Checks for a line break before the first parameter in a multi-line method parameter definition.
145
- Enabled: false
146
-
147
- Layout/InitialIndentation:
148
- Description: Checks the indentation of the first non-blank non-comment line in a file.
149
- Enabled: false
150
-
151
- Layout/IndentFirstArgument:
152
- Description: Checks the indentation of the first parameter in a method call.
153
- Enabled: false
154
-
155
- Layout/IndentationConsistency:
156
- Description: Keep indentation straight.
157
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
158
- Enabled: false
159
-
160
- Layout/IndentationWidth:
161
- Description: Use 2 spaces for indentation.
162
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
163
- Enabled: true
164
-
165
- Layout/IndentFirstArrayElement:
166
- Description: Checks the indentation of the first element in an array literal.
167
- Enabled: false
168
-
169
- Layout/IndentAssignment:
170
- Description: Checks the indentation of the first line of the right-hand-side of a multi-line assignment.
171
- Enabled: true
172
-
173
- Layout/IndentFirstHashElement:
174
- Description: Checks the indentation of the first key in a hash literal.
175
- Enabled: false
176
-
177
- Layout/IndentHeredoc:
178
- Description: This cops checks the indentation of the here document bodies.
179
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#squiggly-heredocs
180
- Enabled: true
181
-
182
- Layout/SpaceInLambdaLiteral:
183
- Description: Checks for spaces in lambda literals.
184
- Enabled: true
185
-
186
- Layout/LeadingCommentSpace:
187
- Description: Comments should start with a space.
188
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-space
189
- Enabled: true
190
-
191
- Layout/MultilineArrayBraceLayout:
192
- Description: Checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.
193
- Enabled: true
194
-
195
- Layout/MultilineAssignmentLayout:
196
- Description: Check for a newline after the assignment operator in multi-line assignments.
197
- StyleGuide: https://github.com/bbatsov/ruby-style-guid#indent-conditional-assignment
198
- Enabled: false
199
-
200
- Layout/MultilineBlockLayout:
201
- Description: Ensures newlines after multiline block do statements.
202
- Enabled: true
203
-
204
- Layout/MultilineHashBraceLayout:
205
- Description: Checks that the closing brace in a hash literal is either on the same line as the last hash element, or a new line.
206
- Enabled: true
207
-
208
- Layout/MultilineMethodCallBraceLayout:
209
- Description: Checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.
210
- Enabled: true
211
-
212
- Layout/MultilineMethodCallIndentation:
213
- Description: Checks indentation of method calls with the dot operator that span more than one line.
214
- Enabled: true
215
-
216
- Layout/MultilineMethodDefinitionBraceLayout:
217
- Description: Checks that the closing brace in a method definition is either on the same line as the last method parameter, or a new line.
218
- Enabled: true
219
-
220
- Layout/MultilineOperationIndentation:
221
- Description: Checks indentation of binary operations that span more than one line.
222
- Enabled: false
223
-
224
- Layout/EmptyLineAfterMagicComment:
225
- Description: Add an empty line after magic comments to separate them from code.
226
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code
227
- Enabled: true
228
-
229
- Layout/RescueEnsureAlignment:
230
- Description: Align rescues and ensures correctly.
231
- Enabled: false
232
-
233
- Layout/SpaceBeforeFirstArg:
234
- Description: Checks that exactly one space is used between a method name and the first argument for method calls without parentheses.
235
- Enabled: true
236
-
237
- Layout/SpaceAfterColon:
238
- Description: Use spaces after colons.
239
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
240
- Enabled: true
241
-
242
- Layout/SpaceAfterComma:
243
- Description: Use spaces after commas.
244
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
245
- Enabled: true
246
-
247
- Layout/SpaceAfterMethodName:
248
- Description: Do not put a space between a method name and the opening parenthesis in a method definition.
249
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#parens-no-spaces
250
- Enabled: true
251
-
252
- Layout/SpaceAfterNot:
253
- Description: Tracks redundant space after the ! operator.
254
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-space-bang
255
- Enabled: false
256
-
257
- Layout/SpaceAfterSemicolon:
258
- Description: Use spaces after semicolons.
259
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
260
- Enabled: true
261
-
262
- Layout/SpaceBeforeBlockBraces:
263
- Description: Checks that the left block brace has or doesn't have space before it.
264
- Enabled: false
265
-
266
- Layout/SpaceBeforeComma:
267
- Description: No spaces before commas.
268
- Enabled: false
269
-
270
- Layout/SpaceBeforeComment:
271
- Description: Checks for missing space between code and a comment on the same line.
272
- Enabled: false
273
-
274
- Layout/SpaceBeforeSemicolon:
275
- Description: No spaces before semicolons.
276
- Enabled: false
277
-
278
- Layout/SpaceInsideBlockBraces:
279
- Description: Checks that block braces have or don't have surrounding space. For blocks taking parameters, checks that the left brace has or doesn't have trailing space.
280
- Enabled: false
281
-
282
- Layout/SpaceAroundBlockParameters:
283
- Description: Checks the spacing inside and after block parameters pipes.
284
- Enabled: true
285
-
286
- Layout/SpaceAroundEqualsInParameterDefault:
287
- Description: Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.
288
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-around-equals
289
- Enabled: true
290
-
291
- Layout/SpaceAroundKeyword:
292
- Description: Use a space around keywords if appropriate.
293
- Enabled: true
294
-
295
- Layout/SpaceAroundOperators:
296
- Description: Use a single space around operators.
297
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
298
- Enabled: true
299
-
300
- Layout/SpaceInsideArrayPercentLiteral:
301
- Description: No unnecessary additional spaces between elements in %i/%w literals.
302
- Enabled: true
303
-
304
- Layout/SpaceInsidePercentLiteralDelimiters:
305
- Description: No unnecessary spaces inside delimiters of %i/%w/%x literals.
306
- Enabled: true
307
-
308
- Layout/SpaceInsideHashLiteralBraces:
309
- Description: Use spaces inside hash literal braces - or don't.
310
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
311
- Enabled: true
312
-
313
- Layout/SpaceInsideParens:
314
- Description: No spaces after ( or before ).
315
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-spaces-braces
316
- Enabled: true
317
-
318
- Layout/SpaceInsideRangeLiteral:
319
- Description: No spaces inside range literals.
320
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-space-inside-range-literals
321
- Enabled: true
322
-
323
- Layout/SpaceInsideStringInterpolation:
324
- Description: Checks for padding/surrounding spaces inside string interpolation.
325
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#string-interpolation
326
- Enabled: false
327
-
328
- Layout/Tab:
329
- Description: No hard tabs.
330
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
331
- Enabled: false
332
-
333
- Layout/TrailingBlankLines:
334
- Description: Checks trailing blank lines and final newline.
335
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#newline-eof
336
- Enabled: false
337
-
338
- Layout/TrailingWhitespace:
339
- Description: Avoid trailing whitespace.
340
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-whitespace
341
- Enabled: false
342
-
343
- # Department Lint
344
- Lint/AmbiguousBlockAssociation:
345
- Description: Checks for ambiguous block association with method when param passed without parentheses.
346
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#syntax
347
- Enabled: false
348
-
349
- Lint/AmbiguousOperator:
350
- Description: Checks for ambiguous operators in the first argument of a method invocation without parentheses.
351
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#method-invocation-parens
352
- Enabled: true
353
-
354
- Lint/AmbiguousRegexpLiteral:
355
- Description: Checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.
356
- Enabled: true
357
-
358
- Lint/AssignmentInCondition:
359
- Description: Don't use assignment in conditions.
360
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
361
- Enabled: true
362
-
363
- Layout/BlockAlignment:
364
- Description: Align block ends correctly.
365
- Enabled: true
366
-
367
- Lint/BooleanSymbol:
368
- Description: Check for `:true` and `:false` symbols.
369
- Enabled: true
370
-
371
- Lint/CircularArgumentReference:
372
- Description: Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument.
373
- Enabled: true
374
-
375
- Layout/ConditionPosition:
376
- Description: Checks for condition placed in a confusing position relative to the keyword.
377
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#same-line-condition
378
- Enabled: true
379
-
380
- Lint/Debugger:
381
- Description: Check for debugger calls.
382
- Enabled: true
383
-
384
- Layout/DefEndAlignment:
385
- Description: Align ends corresponding to defs correctly.
386
- Enabled: true
387
-
388
- Lint/DeprecatedClassMethods:
389
- Description: Check for deprecated class method calls.
390
- Enabled: true
391
-
392
- Lint/DuplicateCaseCondition:
393
- Description: Do not repeat values in case conditionals.
394
- Enabled: true
395
-
396
- Lint/DuplicateMethods:
397
- Description: Check for duplicate method definitions.
398
- Enabled: true
399
-
400
- Lint/DuplicatedKey:
401
- Description: Check for duplicate keys in hash literals.
402
- Enabled: true
403
-
404
- Lint/EachWithObjectArgument:
405
- Description: Check for immutable argument given to each_with_object.
406
- Enabled: true
407
-
408
- Lint/ElseLayout:
409
- Description: Check for odd code arrangement in an else block.
410
- Enabled: true
411
-
412
- Lint/EmptyEnsure:
413
- Description: Checks for empty ensure block.
414
- Enabled: true
415
- AutoCorrect: false
416
-
417
- Lint/EmptyExpression:
418
- Description: Checks for empty expressions.
419
- Enabled: true
420
-
421
- Lint/EmptyInterpolation:
422
- Description: Checks for empty string interpolation.
423
- Enabled: true
424
-
425
- Lint/EmptyWhen:
426
- Description: Checks for `when` branches with empty bodies.
427
- Enabled: true
428
-
429
- Layout/EndAlignment:
430
- Description: Align ends correctly.
431
- Enabled: true
432
-
433
- Lint/EndInMethod:
434
- Description: END blocks should not be placed inside method definitions.
435
- Enabled: true
436
-
437
- Lint/EnsureReturn:
438
- Description: Do not use return in an ensure block.
439
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-return-ensure
440
- Enabled: true
441
-
442
- Lint/FloatOutOfRange:
443
- Description: Catches floating-point literals too large or small for Ruby to represent.
444
- Enabled: true
445
-
446
- Lint/FormatParameterMismatch:
447
- Description: The number of parameters to format/sprint must match the fields.
448
- Enabled: true
449
-
450
- Lint/HandleExceptions:
451
- Description: Don't suppress exception.
452
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
453
- Enabled: true
454
-
455
- Lint/ImplicitStringConcatenation:
456
- Description: Checks for adjacent string literals on the same line, which could better be represented as a single string literal.
457
- Enabled: true
458
-
459
- Lint/IneffectiveAccessModifier:
460
- Description: Checks for attempts to use `private` or `protected` to set the visibility of a class method, which does not work.
461
- Enabled: true
462
-
463
- Lint/InheritException:
464
- Description: Avoid inheriting from the `Exception` class.
465
- Enabled: true
466
-
467
- Lint/InterpolationCheck:
468
- Description: Raise warning for interpolation in single q strs
469
- Enabled: true
470
-
471
- Lint/LiteralAsCondition:
472
- Description: Checks of literals used in conditions.
473
- Enabled: true
474
-
475
- Lint/LiteralInInterpolation:
476
- Description: Checks for literals used in interpolation.
477
- Enabled: true
478
-
479
- Lint/Loop:
480
- Description: Use Kernel#loop with break rather than begin/end/until or begin/end/while for post-loop tests.
481
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#loop-with-break
482
- Enabled: true
483
-
484
- Lint/MultipleCompare:
485
- Description: Use `&&` operator to compare multiple value.
486
- Enabled: true
487
-
488
- Lint/NestedMethodDefinition:
489
- Description: Do not use nested method definitions.
490
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-methods
491
- Enabled: true
492
-
493
- Lint/NextWithoutAccumulator:
494
- Description: Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
495
- Enabled: true
496
-
497
- Lint/NonLocalExitFromIterator:
498
- Description: Do not use return in iterator to cause non-local exit.
499
- Enabled: true
500
-
501
- Lint/ParenthesesAsGroupedExpression:
502
- Description: Checks for method calls with a space before the opening parenthesis.
503
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#parens-no-spaces
504
- Enabled: true
505
-
506
- Lint/PercentStringArray:
507
- Description: Checks for unwanted commas and quotes in %w/%W literals.
508
- Enabled: true
509
-
510
- Lint/PercentSymbolArray:
511
- Description: Checks for unwanted commas and colons in %i/%I literals.
512
- Enabled: true
513
-
514
- Lint/RandOne:
515
- Description: Checks for `rand(1)` calls. Such calls always return `0` and most likely a mistake.
516
- Enabled: true
517
-
518
- Lint/RedundantWithIndex:
519
- Description: Checks for redundant `with_index`.
520
- Enabled: true
521
-
522
- Lint/RedundantWithObject:
523
- Description: Checks for redundant `with_object`.
524
- Enabled: true
525
-
526
- Lint/RegexpAsCondition:
527
- Description: Do not use regexp literal as a condition. The regexp literal matches `$_` implicitly.
528
- Enabled: true
529
-
530
- Lint/RequireParentheses:
531
- Description: Use parentheses in the method call to avoid confusion about precedence.
532
- Enabled: true
533
-
534
- Lint/RescueException:
535
- Description: Avoid rescuing the Exception class.
536
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-blind-rescues
537
- Enabled: true
538
-
539
- Lint/RescueType:
540
- Description: Avoid rescuing from non constants that could result in a `TypeError`.
541
- Enabled: true
542
-
543
- Lint/SafeNavigationChain:
544
- Description: Do not chain ordinary method call after safe navigation operator.
545
- Enabled: true
546
-
547
- Lint/ScriptPermission:
548
- Description: Grant script file execute permission.
549
- Enabled: true
550
-
551
- Lint/ShadowedException:
552
- Description: Avoid rescuing a higher level exception before a lower level exception.
553
- Enabled: true
554
-
555
- Lint/ShadowingOuterLocalVariable:
556
- Description: Do not use the same name as outer local variable for block arguments or block local variables.
557
- Enabled: true
558
-
559
- Lint/StringConversionInInterpolation:
560
- Description: Checks for Object#to_s usage in string interpolation.
561
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-to-s
562
- Enabled: true
563
-
564
- Lint/Syntax:
565
- Description: Checks syntax error
566
- Enabled: true
567
-
568
- Lint/UnderscorePrefixedVariableName:
569
- Description: Do not use prefix `_` for a variable that is used.
570
- Enabled: true
571
-
572
- Lint/UnifiedInteger:
573
- Description: Use Integer instead of Fixnum or Bignum
574
- Enabled: true
575
-
576
- Lint/UnneededRequireStatement:
577
- Description: Checks for unnecessary `require` statement.
578
- Enabled: true
579
-
580
- Lint/UnneededSplatExpansion:
581
- Description: Checks for splat unnecessarily being called on literals
582
- Enabled: true
583
-
584
- Lint/UnusedBlockArgument:
585
- Description: Checks for unused block arguments.
586
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
587
- Enabled: true
588
-
589
- Lint/UnusedMethodArgument:
590
- Description: Checks for unused method arguments.
591
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
592
- Enabled: true
593
-
594
- Lint/UnreachableCode:
595
- Description: Unreachable code.
596
- Enabled: true
597
-
598
- Lint/UriEscapeUnescape:
599
- Description: '`URI.escape` method is obsolete and should not be used. Instead, use `CGI.escape`, `URI.encode_www_form` or `URI.encode_www_form_component` depending on your specific use case. Also `URI.unescape` method is obsolete and should not be used. Instead, use `CGI.unescape`, `URI.decode_www_form` or `URI.decode_www_form_component` depending on your specific use case.'
600
- Enabled: true
601
-
602
- Lint/UriRegexp:
603
- Description: Use `URI::DEFAULT_PARSER.make_regexp` instead of `URI.regexp`.
604
- Enabled: true
605
-
606
- Lint/UselessAccessModifier:
607
- Description: Checks for useless access modifiers.
608
- Enabled: true
609
- ContextCreatingMethods: []
610
- MethodCreatingMethods: []
611
-
612
- Lint/UselessAssignment:
613
- Description: Checks for useless assignment to a local variable.
614
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
615
- Enabled: true
616
-
617
- Lint/UselessComparison:
618
- Description: Checks for comparison of something with itself.
619
- Enabled: true
620
-
621
- Lint/UselessElseWithoutRescue:
622
- Description: Checks for useless `else` in `begin..end` without `rescue`.
623
- Enabled: true
624
-
625
- Lint/ReturnInVoidContext:
626
- Description: Checks for return in void context.
627
- Enabled: true
628
-
629
- Lint/UselessSetterCall:
630
- Description: Checks for useless setter call to a local variable.
631
- Enabled: true
632
-
633
- Lint/Void:
634
- Description: Possible use of operator/literal/variable in void context.
635
- Enabled: true
636
-
637
- # Department Metrics
638
- Metrics/AbcSize:
639
- Description: A calculated magnitude based on number of assignments, branches, and conditions.
640
- Reference: http://c2.com/cgi/wiki?AbcMetric
641
- Enabled: true
642
- Max: 15
643
-
644
- Metrics/BlockLength:
645
- Description: Avoid long blocks with many lines.
646
- Enabled: true
647
- Exclude:
648
- - Rakefile
649
- - "**/*.rake"
650
- - spec/**/*.rb
651
- - 'config/routes.rb'
652
- - 'config/environments/*.rb'
653
-
654
- Metrics/BlockNesting:
655
- Description: Avoid excessive block nesting
656
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count
657
- Enabled: true
658
- Max: 4
659
-
660
- Metrics/ClassLength:
661
- Description: Avoid classes longer than 100 lines of code.
662
- Enabled: true
663
- Max: 100
664
-
665
- Metrics/CyclomaticComplexity:
666
- Description: A complexity metric that is strongly correlated to the number of test cases needed to validate a method.
667
- Enabled: true
668
-
669
- Metrics/LineLength:
670
- Description: Limit lines to 80 characters.
671
- StyleGuide: '#80-character-limits'
672
- Enabled: true
673
- Exclude:
674
- - 'db/**/*'
675
-
676
- Metrics/MethodLength:
677
- Description: Avoid methods longer than 10 lines of code.
678
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
679
- Enabled: true
680
- Max: 10
681
- Exclude:
682
- - 'db/**/*'
683
-
684
- Metrics/ModuleLength:
685
- Description: Avoid modules longer than 100 lines of code.
686
- Enabled: true
687
- Max: 100
688
-
689
- Metrics/ParameterLists:
690
- Description: Avoid parameter lists longer than three or four parameters.
691
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
692
- Enabled: false
693
-
694
- Metrics/PerceivedComplexity:
695
- Description: A complexity metric geared towards measuring complexity for a human reader.
696
- Enabled: true
697
-
698
- # Department Naming
699
- Naming/AccessorMethodName:
700
- Description: Check the naming of accessor methods for get_/set_.
701
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#accessor_mutator_method_names
702
- Enabled: false
703
-
704
- Naming/AsciiIdentifiers:
705
- Description: Use only ascii symbols in identifiers.
706
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#english-identifiers
707
- Enabled: false
708
-
709
- Naming/ClassAndModuleCamelCase:
710
- Description: Use CamelCase for classes and modules.
711
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#camelcase-classes
712
- Enabled: true
713
-
714
- Naming/ConstantName:
715
- Description: Constants should use SCREAMING_SNAKE_CASE.
716
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#screaming-snake-case
717
- Enabled: true
718
-
719
- Naming/FileName:
720
- Description: Use snake_case for source file names.
721
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
722
- Enabled: true
723
-
724
- Naming/HeredocDelimiterCase:
725
- Description: Use configured case for heredoc delimiters.
726
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#heredoc-delimiters
727
- Enabled: true
728
-
729
- Naming/HeredocDelimiterNaming:
730
- Description: Use descriptive heredoc delimiters.
731
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#heredoc-delimiters
732
- Enabled: true
733
-
734
- Naming/MethodName:
735
- Description: Use the configured style when naming methods.
736
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars
737
- Enabled: false
738
-
739
- Naming/PredicateName:
740
- Description: Check the names of predicate methods.
741
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
742
- Enabled: true
743
-
744
- Naming/BinaryOperatorParameterName:
745
- Description: When defining binary operators, name the argument other.
746
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#other-arg
747
- Enabled: true
748
-
749
- Naming/VariableName:
750
- Description: Use the configured style when naming variables.
751
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars
752
- Enabled: true
753
-
754
- Naming/VariableNumber:
755
- Description: Use the configured style when numbering variables.
756
- Enabled: true
757
-
758
- Naming/MemoizedInstanceVariableName:
759
- Enabled: true
760
- Exclude:
761
- - app/controllers/*.rb
762
- # Department Performance
763
- Performance/Caller:
764
- Description: Use `caller(n..n)` instead of `caller`.
765
- Enabled: true
766
-
767
- Performance/Casecmp:
768
- Description: Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
769
- Reference: https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code
770
- Enabled: true
771
-
772
- Performance/CaseWhenSplat:
773
- Description: Place `when` conditions that use splat at the end of the list of `when` branches.
774
- Enabled: true
775
-
776
- Performance/Count:
777
- Description: Use `count` instead of `select...size`, `reject...size`, `select...count`, `reject...count`, `select...length`, and `reject...length`.
778
- SafeMode: true
779
- Enabled: true
780
-
781
- Performance/Detect:
782
- Description: Use `detect` instead of `select.first`, `find_all.first`, `select.last`, and `find_all.last`.
783
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
784
- SafeMode: true
785
- Enabled: true
786
-
787
- Performance/DoubleStartEndWith:
788
- Description: Use `str.{start,end}_with?(x, ..., y, ...)` instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
789
- Enabled: true
790
-
791
- Performance/EndWith:
792
- Description: Use `end_with?` instead of a regex match anchored to the end of a string.
793
- Reference: https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end
794
- AutoCorrect: false
795
- Enabled: true
796
-
797
- Performance/FixedSize:
798
- Description: Do not compute the size of statically sized objects except in constants
799
- Enabled: true
800
-
801
- Performance/FlatMap:
802
- Description: Use `Enumerable#flat_map` instead of `Enumerable#map...Array#flatten(1)` or `Enumberable#collect..Array#flatten(1)`
803
- Reference: https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code
804
- Enabled: true
805
- EnabledForFlattenWithoutParams: false
806
-
807
- Performance/RangeInclude:
808
- Description: Use `Range#cover?` instead of `Range#include?`.
809
- Reference: https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code
810
- Enabled: true
811
-
812
- Performance/RedundantBlockCall:
813
- Description: Use `yield` instead of `block.call`.
814
- Reference: https://github.com/JuanitoFatas/fast-ruby#proccall-vs-yield-code
815
- Enabled: true
816
-
817
- Performance/RedundantMatch:
818
- Description: Use `=~` instead of `String#match` or `Regexp#match` in a context where the returned `MatchData` is not needed.
819
- Enabled: true
820
-
821
- Performance/RedundantMerge:
822
- Description: Use Hash#[]=, rather than Hash#merge! with a single key-value pair.
823
- Reference: https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code
824
- Enabled: true
825
-
826
- Style/RedundantSortBy:
827
- Description: Use `sort` instead of `sort_by { |x| x }`.
828
- Enabled: true
829
-
830
- Performance/RegexpMatch:
831
- Description: Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`, `Regexp#===`, or `=~` when `MatchData` is not used.
832
- Enabled: true
833
-
834
- Performance/ReverseEach:
835
- Description: Use `reverse_each` instead of `reverse.each`.
836
- Reference: https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code
837
- Enabled: true
838
-
839
- Style/Sample:
840
- Description: Use `sample` instead of `shuffle.first`, `shuffle.last`, and `shuffle[Integer]`.
841
- Reference: https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code
842
- Enabled: true
843
-
844
- Performance/Size:
845
- Description: Use `size` instead of `count` for counting the number of elements in `Array` and `Hash`.
846
- Reference: https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code
847
- Enabled: true
848
-
849
- Performance/CompareWithBlock:
850
- Description: Use `sort_by(&:foo)` instead of `sort { |a, b| a.foo <=> b.foo }`.
851
- Enabled: true
852
-
853
- Performance/StartWith:
854
- Description: Use `start_with?` instead of a regex match anchored to the beginning of a string.
855
- Reference: https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end
856
- AutoCorrect: false
857
- Enabled: true
858
-
859
- Performance/StringReplacement:
860
- Description: Use `tr` instead of `gsub` when you are replacing the same number of characters. Use `delete` instead of `gsub` when you are deleting characters.
861
- Reference: https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code
862
- Enabled: true
863
-
864
- Performance/TimesMap:
865
- Description: Checks for .times.map calls.
866
- AutoCorrect: false
867
- Enabled: true
868
-
869
- Performance/UnfreezeString:
870
- Description: Use unary plus to get an unfrozen string literal.
871
- Enabled: true
872
-
873
- Performance/UriDefaultParser:
874
- Description: Use `URI::DEFAULT_PARSER` instead of `URI::Parser.new`.
875
- Enabled: true
876
-
877
- # Department Rails
878
- Rails/ActionFilter:
879
- Description: Enforces consistent use of action filter methods.
880
- Enabled: false
881
-
882
- Rails/ApplicationJob:
883
- Description: Check that jobs subclass ApplicationJob.
884
- Enabled: true
885
-
886
- Rails/ApplicationRecord:
887
- Description: Check that models subclass ApplicationRecord.
888
- Enabled: true
889
-
890
- Rails/ActiveSupportAliases:
891
- Description: 'Avoid ActiveSupport aliases of standard ruby methods: `String#starts_with?`, `String#ends_with?`, `Array#append`, `Array#prepend`.'
892
- Enabled: true
893
-
894
- Rails/Blank:
895
- Description: Enforce using `blank?` and `present?`.
896
- Enabled: true
897
- NilOrEmpty: true
898
- NotPresent: true
899
- UnlessPresent: true
900
-
901
- Rails/Date:
902
- Description: Checks the correct usage of date aware methods, such as Date.today, Date.current etc.
903
- Enabled: true
904
-
905
- Rails/Delegate:
906
- Description: Prefer delegate method for delegations.
907
- Enabled: true
908
-
909
- Rails/DelegateAllowBlank:
910
- Description: Do not use allow_blank as an option to delegate.
911
- Enabled: true
912
-
913
- Rails/DynamicFindBy:
914
- Description: Use `find_by` instead of dynamic `find_by_*`.
915
- StyleGuide: https://github.com/bbatsov/rails-style-guide#find_by
916
- Enabled: true
917
-
918
- Rails/EnumUniqueness:
919
- Description: Avoid duplicate integers in hash-syntax `enum` declaration.
920
- Enabled: true
921
-
922
- Rails/Exit:
923
- Description: Favor `fail`, `break`, `return`, etc. over `exit` in application or library code outside of Rake files to avoid exits during unit testing or running in production.
924
- Enabled: true
925
-
926
- Rails/FilePath:
927
- Description: Use `Rails.root.join` for file path joining.
928
- Enabled: true
929
-
930
- Rails/FindBy:
931
- Description: Prefer find_by over where.first.
932
- StyleGuide: https://github.com/bbatsov/rails-style-guide#find_by
933
- Enabled: true
934
-
935
- Rails/FindEach:
936
- Description: Prefer all.find_each over all.find.
937
- StyleGuide: https://github.com/bbatsov/rails-style-guide#find-each
938
- Enabled: true
939
-
940
- Rails/HasAndBelongsToMany:
941
- Description: Prefer has_many :through to has_and_belongs_to_many.
942
- StyleGuide: https://github.com/bbatsov/rails-style-guide#has-many-through
943
- Enabled: true
944
-
945
- Rails/HasManyOrHasOneDependent:
946
- Description: Define the dependent option to the has_many and has_one associations.
947
- StyleGuide: https://github.com/bbatsov/rails-style-guide#has_many-has_one-dependent-option
948
- Enabled: true
949
-
950
- Rails/HttpPositionalArguments:
951
- Description: Use keyword arguments instead of positional arguments in http method calls.
952
- Enabled: true
953
-
954
- Rails/NotNullColumn:
955
- Description: Do not add a NOT NULL column without a default value
956
- Enabled: true
957
-
958
- Rails/Output:
959
- Description: Checks for calls to puts, print, etc.
960
- Enabled: true
961
-
962
- Rails/OutputSafety:
963
- Description: The use of `html_safe` or `raw` may be a security risk.
964
- Enabled: true
965
-
966
- Rails/PluralizationGrammar:
967
- Description: Checks for incorrect grammar when using methods like `3.day.ago`.
968
- Enabled: true
969
-
970
- Rails/Present:
971
- Description: Enforce using `blank?` and `present?`.
972
- Enabled: true
973
- NotNilAndNotEmpty: true
974
- NotBlank: true
975
- UnlessBlank: true
976
-
977
- Rails/ReadWriteAttribute:
978
- Description: Checks for read_attribute(:attr) and write_attribute(:attr, val).
979
- StyleGuide: https://github.com/bbatsov/rails-style-guide#read-attribute
980
- Enabled: false
981
-
982
- Rails/RelativeDateConstant:
983
- Description: Do not assign relative date to constants.
984
- Enabled: true
985
-
986
- Rails/RequestReferer:
987
- Description: Use consistent syntax for request.referer.
988
- Enabled: true
989
-
990
- Rails/ReversibleMigration:
991
- Description: Checks whether the change method of the migration file is reversible.
992
- StyleGuide: https://github.com/bbatsov/rails-style-guide#reversible-migration
993
- Reference: http://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html
994
- Enabled: true
995
-
996
- Rails/SafeNavigation:
997
- Description: Use Ruby's safe navigation operator (`&.`) instead of `try!`
998
- Enabled: true
999
-
1000
- Rails/SaveBang:
1001
- Description: Identifies possible cases where Active Record save! or related should be used.
1002
- StyleGuide: https://github.com/bbatsov/rails-style-guide#save-bang
1003
- Enabled: false
1004
-
1005
- Rails/ScopeArgs:
1006
- Description: Checks the arguments of ActiveRecord scopes.
1007
- Enabled: true
1008
-
1009
- Rails/TimeZone:
1010
- Description: Checks the correct usage of time zone aware methods.
1011
- StyleGuide: https://github.com/bbatsov/rails-style-guide#time
1012
- Reference: http://danilenko.org/2012/7/6/rails_timezones
1013
- Enabled: true
1014
-
1015
- Rails/UniqBeforePluck:
1016
- Description: Prefer the use of uniq or distinct before pluck.
1017
- Enabled: true
1018
-
1019
- Rails/UnknownEnv:
1020
- Description: Use correct environment name.
1021
- Enabled: true
1022
-
1023
- Rails/SkipsModelValidations:
1024
- Description: Use methods that skips model validations with caution. See reference for more information.
1025
- Reference: http://guides.rubyonrails.org/active_record_validations.html#skipping-validations
1026
- Enabled: true
1027
-
1028
- Rails/Validation:
1029
- Description: Use validates :attribute, hash of validations.
1030
- Enabled: true
1031
-
1032
- # Department Security
1033
- Security/Eval:
1034
- Description: The use of eval represents a serious security risk.
1035
- Enabled: true
1036
-
1037
- Security/JSONLoad:
1038
- Description: Prefer usage of `JSON.parse` over `JSON.load` due to potential security issues. See reference for more information.
1039
- Reference: http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load
1040
- Enabled: true
1041
- AutoCorrect: false
1042
-
1043
- Security/MarshalLoad:
1044
- Description: Avoid using of `Marshal.load` or `Marshal.restore` due to potential security issues. See reference for more information.
1045
- Reference: http://ruby-doc.org/core-2.3.3/Marshal.html#module-Marshal-label-Security+considerations
1046
- Enabled: true
1047
-
1048
- Security/YAMLLoad:
1049
- Description: Prefer usage of `YAML.safe_load` over `YAML.load` due to potential security issues. See reference for more information.
1050
- Reference: https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security
1051
- Enabled: true
1052
-
1053
- Security/Open:
1054
- Exclude:
1055
- - db/migrate/*.rb
1056
- # Department Style
1057
- Style/Alias:
1058
- Description: Use alias instead of alias_method.
1059
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
1060
- Enabled: false
1061
-
1062
- Style/AndOr:
1063
- Description: Use &&/|| instead of and/or.
1064
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
1065
- Enabled: true
1066
-
1067
- Style/ArrayJoin:
1068
- Description: Use Array#join instead of Array#*.
1069
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#array-join'
1070
- Enabled: false
1071
-
1072
- Style/AsciiComments:
1073
- Description: Use only ascii symbols in comments.
1074
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#english-comments
1075
- Enabled: false
1076
-
1077
- Style/Attr:
1078
- Description: Checks for uses of Module#attr.
1079
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#attr
1080
- Enabled: true
1081
-
1082
- Style/AutoResourceCleanup:
1083
- Description: Suggests the usage of an auto resource cleanup version of a method (if available).
1084
- Enabled: false
1085
-
1086
- Style/BeginBlock:
1087
- Description: Avoid the use of BEGIN blocks.
1088
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-BEGIN-blocks
1089
- Enabled: true
1090
-
1091
- Style/BarePercentLiterals:
1092
- Description: Checks if usage of %() or %Q() matches configuration.
1093
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-q-shorthand
1094
- Enabled: true
1095
-
1096
- Style/BlockComments:
1097
- Description: Do not use block comments.
1098
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-block-comments
1099
- Enabled: false
1100
-
1101
- Style/BlockDelimiters:
1102
- Description: Avoid using {...} for multi-line blocks (multiline chaining is always ugly). Prefer {...} over do...end for single-line blocks.
1103
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks
1104
- Enabled: true
1105
-
1106
- Style/BracesAroundHashParameters:
1107
- Description: Enforce braces style around hash parameters.
1108
- Enabled: false
1109
-
1110
- Style/CaseEquality:
1111
- Description: Avoid explicit use of the case equality operator(===).
1112
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-case-equality
1113
- Enabled: false
1114
-
1115
- Style/CharacterLiteral:
1116
- Description: Checks for uses of character literals.
1117
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-character-literals
1118
- Enabled: false
1119
-
1120
- Style/ClassAndModuleChildren:
1121
- Description: Checks style of children classes and modules.
1122
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#namespace-definition
1123
- Enabled: false
1124
-
1125
- Style/ClassCheck:
1126
- Description: Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.
1127
- Enabled: true
1128
-
1129
- Style/ClassMethods:
1130
- Description: Use self when defining module/class methods.
1131
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#def-self-class-methods
1132
- Enabled: false
1133
-
1134
- Style/ClassVars:
1135
- Description: Avoid the use of class variables.
1136
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-class-vars
1137
- Enabled: false
1138
-
1139
- Style/CollectionMethods:
1140
- Description: Preferred collection methods.
1141
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
1142
- Enabled: false
1143
-
1144
- Style/ColonMethodCall:
1145
- Description: 'Do not use :: for method call.'
1146
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#double-colons
1147
- Enabled: true
1148
-
1149
- Style/CommandLiteral:
1150
- Description: Use `` or %x around command literals.
1151
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-x
1152
- Enabled: false
1153
-
1154
- Style/CommentAnnotation:
1155
- Description: Checks formatting of special comments (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
1156
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#annotate-keywords
1157
- Enabled: false
1158
-
1159
- Style/CommentedKeyword:
1160
- Description: Do not place comments on the same line as certain keywords.
1161
- Enabled: false
1162
-
1163
- Style/ConditionalAssignment:
1164
- Description: Use the return value of `if` and `case` statements for assignment to a variable and variable comparison instead of assigning that variable inside of each branch.
1165
- Enabled: true
1166
-
1167
- Style/Copyright:
1168
- Description: Include a copyright notice in each file before any code.
1169
- Enabled: false
1170
-
1171
- Style/DateTime:
1172
- Description: Use Date or Time over DateTime.
1173
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#date--time
1174
- Enabled: false
1175
-
1176
- Style/DefWithParentheses:
1177
- Description: Use def with parentheses when there are arguments.
1178
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#method-parens
1179
- Enabled: true
1180
-
1181
- Style/Dir:
1182
- Description: Use the `__dir__` method to retrieve the canonicalized absolute path to the current file.
1183
- Enabled: true
1184
-
1185
- Style/Documentation:
1186
- Description: Document classes and non-namespace modules.
1187
- Enabled: false
1188
- Exclude:
1189
- - 'spec/**/*'
1190
- - 'test/**/*'
1191
-
1192
- Style/DocumentationMethod:
1193
- Description: Public methods.
1194
- Enabled: false
1195
- Exclude:
1196
- - 'spec/**/*'
1197
- - 'test/**/*'
1198
-
1199
- Style/DoubleNegation:
1200
- Description: Checks for uses of double negation (!!).
1201
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
1202
- Enabled: true
1203
-
1204
- Style/EachForSimpleLoop:
1205
- Description: Use `Integer#times` for a simple loop which iterates a fixed number of times.
1206
- Enabled: true
1207
-
1208
- Style/EachWithObject:
1209
- Description: Prefer `each_with_object` over `inject` or `reduce`.
1210
- Enabled: false
1211
-
1212
- Style/EmptyElse:
1213
- Description: Avoid empty else-clauses.
1214
- Enabled: true
1215
-
1216
- Style/EmptyCaseCondition:
1217
- Description: Avoid empty condition in case statements.
1218
- Enabled: true
1219
-
1220
- Style/EmptyLiteral:
1221
- Description: Prefer literals to Array.new/Hash.new/String.new.
1222
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
1223
- Enabled: false
1224
-
1225
- Style/EmptyMethod:
1226
- Description: Checks the formatting of empty method definitions.
1227
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
1228
- Enabled: false
1229
-
1230
- Style/EndBlock:
1231
- Description: Avoid the use of END blocks.
1232
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-END-blocks
1233
- Enabled: false
1234
-
1235
- Style/Encoding:
1236
- Description: Use UTF-8 as the source file encoding.
1237
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#utf-8
1238
- Enabled: true
1239
-
1240
- Style/EvenOdd:
1241
- Description: Favor the use of Integer#even? && Integer#odd?
1242
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#predicate-methods
1243
- Enabled: true
1244
-
1245
- Style/FrozenStringLiteralComment:
1246
- Description: Add the frozen_string_literal comment to the top of files to help transition from Ruby 2.3.0 to Ruby 3.0.
1247
- Enabled: true
1248
-
1249
- Lint/FlipFlop:
1250
- Description: Checks for flip flops
1251
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-flip-flops
1252
- Enabled: true
1253
-
1254
- Style/For:
1255
- Description: Checks use of for or each in multiline loops.
1256
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-for-loops
1257
- Enabled: true
1258
-
1259
- Style/FormatString:
1260
- Description: Enforce the use of Kernel#sprintf, Kernel#format or String#%.
1261
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#sprintf
1262
- Enabled: false
1263
-
1264
- Style/FormatStringToken:
1265
- Description: Use a consistent style for format string tokens.
1266
- Enabled: true
1267
-
1268
- Style/GlobalVars:
1269
- Description: Do not introduce global variables.
1270
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#instance-vars
1271
- Reference: http://www.zenspider.com/Languages/Ruby/QuickRef.html
1272
- Enabled: true
1273
-
1274
- Style/GuardClause:
1275
- Description: Check for conditionals that can be replaced with guard clauses
1276
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
1277
- Enabled: true
1278
-
1279
- Style/HashSyntax:
1280
- Description: 'Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1, :b => 2 }.'
1281
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-literals
1282
- Enabled: true
1283
-
1284
- Style/IfInsideElse:
1285
- Description: Finds if nodes inside else, which can be converted to elsif.
1286
- Enabled: true
1287
-
1288
- Style/IfUnlessModifier:
1289
- Description: Favor modifier if/unless usage when you have a single-line body.
1290
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
1291
- Enabled: true
1292
-
1293
- Style/IfUnlessModifierOfIfUnless:
1294
- Description: Avoid modifier if/unless usage on conditionals.
1295
- Enabled: true
1296
-
1297
- Style/IfWithSemicolon:
1298
- Description: Do not use if x; .... Use the ternary operator instead.
1299
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs
1300
- Enabled: true
1301
-
1302
- Style/IdenticalConditionalBranches:
1303
- Description: Checks that conditional statements do not have an identical line at the end of each branch, which can validly be moved out of the conditional.
1304
- Enabled: true
1305
-
1306
- Style/InfiniteLoop:
1307
- Description: Use Kernel#loop for infinite loops.
1308
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#infinite-loop
1309
- Enabled: true
1310
-
1311
- Style/InlineComment:
1312
- Description: Avoid trailing inline comments.
1313
- Enabled: false
1314
-
1315
- Style/InverseMethods:
1316
- Description: Use the inverse method instead of `!.method` if an inverse method is defined.
1317
- Enabled: true
1318
-
1319
- Style/ImplicitRuntimeError:
1320
- Description: Use `raise` or `fail` with an explicit exception class and message, rather than just a message.
1321
- Enabled: false
1322
-
1323
- Style/Lambda:
1324
- Description: Use the new lambda literal syntax for single-line blocks.
1325
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#lambda-multi-line
1326
- Enabled: true
1327
-
1328
- Style/LambdaCall:
1329
- Description: Use lambda.call(...) instead of lambda.(...).
1330
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#proc-call
1331
- Enabled: false
1332
-
1333
- Style/LineEndConcatenation:
1334
- Description: Use \ instead of + or << to concatenate two string literals at line end.
1335
- Enabled: true
1336
-
1337
- Style/MethodCallWithoutArgsParentheses:
1338
- Description: Do not use parentheses for method calls with no arguments.
1339
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#method-invocation-parens
1340
- Enabled: true
1341
-
1342
- Style/MethodCallWithArgsParentheses:
1343
- Description: Use parentheses for method calls with arguments.
1344
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#method-invocation-parens
1345
- Enabled: false
1346
-
1347
- Style/MethodCalledOnDoEndBlock:
1348
- Description: Avoid chaining a method call on a do...end block.
1349
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks
1350
- Enabled: false
1351
-
1352
- Style/MethodDefParentheses:
1353
- Description: Checks if the method definitions have or don't have parentheses.
1354
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#method-parens
1355
- Enabled: true
1356
-
1357
- Style/MethodMissingSuper:
1358
- Enabled: true
1359
-
1360
- Style/MissingRespondToMissing:
1361
- Enabled: true
1362
-
1363
- Style/MinMax:
1364
- Description: Use `Enumerable#minmax` instead of `Enumerable#min` and `Enumerable#max` in conjunction.'
1365
- Enabled: true
1366
-
1367
- Style/MissingElse:
1368
- Description: Require if/case expressions to have an else branches. If enabled, it is recommended that Style/UnlessElse and Style/EmptyElse be enabled. This will conflict with Style/EmptyElse if Style/EmptyElse is configured to style "both"
1369
- Enabled: false
1370
- EnforcedStyle: both
1371
- SupportedStyles:
1372
- - if
1373
- - case
1374
- - both
1375
-
1376
- Style/MixinGrouping:
1377
- Description: Checks for grouping of mixins in `class` and `module` bodies.
1378
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#mixin-grouping
1379
- Enabled: true
1380
-
1381
- Style/ModuleFunction:
1382
- Description: Checks for usage of `extend self` in modules.
1383
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
1384
- Enabled: true
1385
-
1386
- Style/MultilineBlockChain:
1387
- Description: Avoid multi-line chains of blocks.
1388
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks
1389
- Enabled: false
1390
-
1391
- Style/MultilineIfThen:
1392
- Description: Do not use then for multi-line if/unless.
1393
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-then
1394
- Enabled: true
1395
-
1396
- Style/MultilineIfModifier:
1397
- Description: Only use if/unless modifiers on single line statements.
1398
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-multiline-if-modifiers
1399
- Enabled: true
1400
-
1401
- Style/MultilineMemoization:
1402
- Description: Wrap multiline memoizations in a `begin` and `end` block.
1403
- Enabled: true
1404
-
1405
- Style/MultilineTernaryOperator:
1406
- Description: 'Avoid multi-line ?: (the ternary operator); use if/unless instead.'
1407
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-multiline-ternary
1408
- Enabled: true
1409
-
1410
- Style/MultipleComparison:
1411
- Description: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead.
1412
- Enabled: true
1413
-
1414
- Style/MutableConstant:
1415
- Description: Do not assign mutable objects to constants.
1416
- Enabled: true
1417
-
1418
- Style/NegatedIf:
1419
- Description: Favor unless over if for negative conditions (or control flow or).
1420
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#unless-for-negatives
1421
- Enabled: true
1422
-
1423
- Style/NegatedWhile:
1424
- Description: Favor until over while for negative conditions.
1425
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#until-for-negatives
1426
- Enabled: true
1427
-
1428
- Style/NestedModifier:
1429
- Description: Avoid using nested modifiers.
1430
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-modifiers
1431
- Enabled: true
1432
-
1433
- Style/NestedParenthesizedCalls:
1434
- Description: Parenthesize method calls which are nested inside the argument list of another parenthesized method call.
1435
- Enabled: true
1436
-
1437
- Style/NestedTernaryOperator:
1438
- Description: Use one expression per branch in a ternary operator.
1439
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-ternary
1440
- Enabled: true
1441
-
1442
- Style/Next:
1443
- Description: Use `next` to skip iteration instead of a condition at the end.
1444
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
1445
- Enabled: true
1446
-
1447
- Style/NilComparison:
1448
- Description: 'Prefer x.nil? to x == nil.'
1449
- StyleGuide: '#predicate-methods'
1450
- Enabled: true
1451
-
1452
- Style/NonNilCheck:
1453
- Description: Checks for redundant nil checks.
1454
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-non-nil-checks
1455
- Enabled: true
1456
-
1457
- Style/Not:
1458
- Description: Use ! instead of not.
1459
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#bang-not-not
1460
- Enabled: true
1461
-
1462
- Style/NumericLiterals:
1463
- Description: Add underscores to large numeric literals to improve their readability.
1464
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics
1465
- Enabled: true
1466
-
1467
- Style/NumericLiteralPrefix:
1468
- Description: Use smallcase prefixes for numeric literals.
1469
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#numeric-literal-prefixes
1470
- Enabled: true
1471
-
1472
- Style/NumericPredicate:
1473
- Description: Checks for the use of predicate- or comparison methods for numeric comparisons.
1474
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#predicate-methods
1475
- AutoCorrect: false
1476
- Enabled: true
1477
-
1478
- Style/OneLineConditional:
1479
- Description: Favor the ternary operator(?:) over if/then/else/end constructs.
1480
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
1481
- Enabled: false
1482
-
1483
- Style/OptionalArguments:
1484
- Description: Checks for optional arguments that do not appear at the end of the argument list
1485
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#optional-arguments
1486
- Enabled: false
1487
-
1488
- Style/OptionHash:
1489
- Description: Don't use option hashes when you can use keyword arguments.
1490
- Enabled: false
1491
-
1492
- Style/OrAssignment:
1493
- Description: Recommend usage of double pipe equals (||=) where applicable.
1494
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#double-pipe-for-uninit
1495
- Enabled: true
1496
-
1497
- Style/ParallelAssignment:
1498
- Description: Check for simple usages of parallel assignment. It will only warn when the number of variables matches on both sides of the assignment.
1499
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#parallel-assignment
1500
- Enabled: false
1501
-
1502
- Style/ParenthesesAroundCondition:
1503
- Description: Don't use parentheses around the condition of an if/unless/while.
1504
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-parens-around-condition
1505
- Enabled: true
1506
-
1507
- Style/PercentLiteralDelimiters:
1508
- Description: Use `%`-literal delimiters consistently
1509
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
1510
- Enabled: true
1511
- PreferredDelimiters:
1512
- default: ()
1513
- '%i': '()'
1514
- '%I': '()'
1515
- '%r': '{}'
1516
- '%w': '()'
1517
- '%W': '()'
1518
-
1519
- Style/PercentQLiterals:
1520
- Description: Checks if uses of %Q/%q match the configured preference.
1521
- Enabled: true
1522
-
1523
- Style/PerlBackrefs:
1524
- Description: Avoid Perl-style regex back references.
1525
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
1526
- Enabled: false
1527
-
1528
- Style/PreferredHashMethods:
1529
- Description: Checks use of `has_key?` and `has_value?` Hash methods.
1530
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-key
1531
- Enabled: true
1532
-
1533
- Style/Proc:
1534
- Description: Use proc instead of Proc.new.
1535
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#proc
1536
- Enabled: true
1537
-
1538
- Style/RaiseArgs:
1539
- Description: Checks the arguments passed to raise/fail.
1540
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
1541
- Enabled: false
1542
-
1543
- Style/RedundantBegin:
1544
- Description: Don't use begin blocks when they are not needed.
1545
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#begin-implicit
1546
- Enabled: true
1547
-
1548
- Style/RedundantConditional:
1549
- Description: Don't return true/false from a conditional.
1550
- Enabled: true
1551
-
1552
- Style/RedundantException:
1553
- Description: Checks for an obsolete RuntimeException argument in raise/fail.
1554
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-explicit-runtimeerror
1555
- Enabled: true
1556
-
1557
- Style/RedundantFreeze:
1558
- Description: Checks usages of Object#freeze on immutable objects.
1559
- Enabled: true
1560
-
1561
- Style/RedundantParentheses:
1562
- Description: Checks for parentheses that seem not to serve any purpose.
1563
- Enabled: true
1564
-
1565
- Style/RedundantReturn:
1566
- Description: Don't use return where it's not required.
1567
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-explicit-return
1568
- Enabled: true
1569
-
1570
- Style/RedundantSelf:
1571
- Description: Don't use self where it's not needed.
1572
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-self-unless-required
1573
- Enabled: true
1574
-
1575
- Style/RegexpLiteral:
1576
- Description: Use / or %r around regular expressions.
1577
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-r
1578
- Enabled: false
1579
-
1580
- Style/RescueModifier:
1581
- Description: Avoid using rescue in its modifier form.
1582
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers
1583
- Enabled: false
1584
-
1585
- Style/RescueStandardError:
1586
- Description: Avoid rescuing without specifying an error class.
1587
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-blind-rescues'
1588
- Enabled: true
1589
-
1590
- Style/ReturnNil:
1591
- Description: Use return instead of return nil.
1592
- Enabled: false
1593
-
1594
- Style/SafeNavigation:
1595
- Description: This cop transforms usages of a method call safeguarded by a check for the existance of the object to safe navigation (`&.`).
1596
- Enabled: true
1597
-
1598
- Style/SelfAssignment:
1599
- Description: Checks for places where self-assignment shorthand should have been used.
1600
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#self-assignment
1601
- Enabled: true
1602
-
1603
- Style/Semicolon:
1604
- Description: Don't use semicolons to terminate expressions.
1605
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-semicolon
1606
- Enabled: true
1607
-
1608
- Style/Send:
1609
- Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.
1610
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
1611
- Enabled: false
1612
-
1613
- Style/SignalException:
1614
- Description: Checks for proper usage of fail and raise.
1615
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-raise-over-fail
1616
- Enabled: true
1617
-
1618
- Style/SingleLineBlockParams:
1619
- Description: Enforces the names of some block params.
1620
- Enabled: false
1621
-
1622
- Style/SingleLineMethods:
1623
- Description: Avoid single-line methods.
1624
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
1625
- Enabled: false
1626
-
1627
- Style/SpecialGlobalVars:
1628
- Description: Avoid Perl-style global variables.
1629
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
1630
- Enabled: false
1631
-
1632
- Style/StabbyLambdaParentheses:
1633
- Description: Check for the usage of parentheses around stabby lambda arguments.
1634
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#stabby-lambda-with-args
1635
- Enabled: true
1636
-
1637
- Style/StderrPuts:
1638
- Description: Use `warn` instead of `$stderr.puts`.
1639
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#warn
1640
- Enabled: true
1641
-
1642
- Style/StringLiterals:
1643
- Description: Checks if uses of quotes match the configured preference.
1644
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
1645
- EnforcedStyle: double_quotes
1646
- Enabled: true
1647
-
1648
- Style/StringLiteralsInInterpolation:
1649
- Description: Checks if uses of quotes inside expressions in interpolated strings match the configured preference.
1650
- Enabled: true
1651
-
1652
- Style/StringMethods:
1653
- Description: Checks if configured preferred methods are used over non-preferred.
1654
- Enabled: false
1655
-
1656
- Style/StructInheritance:
1657
- Description: Checks for inheritance from Struct.new.
1658
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-extend-struct-new
1659
- Enabled: false
1660
-
1661
- Style/SymbolArray:
1662
- Description: Use %i or %I for arrays of symbols.
1663
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-i
1664
- Enabled: true
1665
-
1666
- Style/SymbolLiteral:
1667
- Description: Use plain symbols instead of string symbols when possible.
1668
- Enabled: false
1669
-
1670
- Style/SymbolProc:
1671
- Description: Use symbols as procs instead of blocks when possible.
1672
- Enabled: false
1673
-
1674
- Style/TernaryParentheses:
1675
- Description: Checks for use of parentheses around ternary conditions.
1676
- Enabled: true
1677
-
1678
- Style/MixinUsage:
1679
- Description: Checks that `include`, `extend` and `prepend` exists at the top level.
1680
- Enabled: true
1681
-
1682
- Style/TrailingCommaInArguments:
1683
- Description: Checks for trailing comma in argument lists.
1684
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-params-comma'
1685
- Enabled: false
1686
-
1687
- Style/TrailingCommaInArrayLiteral:
1688
- Description: Checks for trailing comma in array and hash literals.'
1689
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
1690
- Enabled: false
1691
-
1692
- Style/TrailingCommaInHashLiteral:
1693
- Description: Checks for trailing comma in array and hash literals.'
1694
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
1695
- Enabled: false
1696
-
1697
- Style/TrivialAccessors:
1698
- Description: Prefer attr_* methods to trivial readers/writers.
1699
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#attr_family
1700
- Enabled: false
1701
-
1702
- Style/UnlessElse:
1703
- Description: Do not use unless with else. Rewrite these with the positive case first.
1704
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-else-with-unless
1705
- Enabled: true
1706
-
1707
- Style/UnneededCapitalW:
1708
- Description: Checks for %W when interpolation is not needed.
1709
- Enabled: false
1710
-
1711
- Style/UnneededInterpolation:
1712
- Description: Checks for strings that are just an interpolated expression.
1713
- Enabled: true
1714
-
1715
- Style/UnneededPercentQ:
1716
- Description: Checks for %q/%Q when single quotes or double quotes would do.
1717
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-q
1718
- Enabled: false
1719
-
1720
- Style/TrailingUnderscoreVariable:
1721
- Description: Checks for the usage of unneeded trailing underscores at the end of parallel variable assignment.
1722
- AllowNamedUnderscoreVariables: true
1723
- Enabled: false
1724
-
1725
- Style/VariableInterpolation:
1726
- Description: Don't interpolate global, instance and class variables directly in strings.
1727
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
1728
- Enabled: true
1729
-
1730
- Style/WhenThen:
1731
- Description: Use when x then ... for one-line cases.
1732
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
1733
- Enabled: true
1734
-
1735
- Style/WhileUntilDo:
1736
- Description: Checks for redundant do after while or until.
1737
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-multiline-while-do
1738
- Enabled: true
1739
-
1740
- Style/WhileUntilModifier:
1741
- Description: Favor modifier while/until usage when you have a single-line body.
1742
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier
1743
- Enabled: true
1744
-
1745
- Style/WordArray:
1746
- Description: Use %w or %W for arrays of words.
1747
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-w
1748
- Enabled: true
1749
-
1750
- Style/YodaCondition:
1751
- Description: Do not use literals as the first operand of a comparison.
1752
- Reference: https://en.wikipedia.org/wiki/Yoda_conditions
1753
- Enabled: true
1754
-
1755
- Style/ZeroLengthPredicate:
1756
- Description: Use #empty? when testing for objects of length 0.
1757
- Enabled: true