rspec_api_blueprint_matchers 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +33 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +26 -0
  5. data/.ruby-version +1 -0
  6. data/Rakefile +2 -1
  7. data/config/rubocop/.lint_rubocop.yml +749 -0
  8. data/config/rubocop/.metrics_rubocop.yml +94 -0
  9. data/config/rubocop/.performance_rubocop.yml +323 -0
  10. data/config/rubocop/.rails_rubocop.yml +256 -0
  11. data/config/rubocop/.style_rubocop.yml +2299 -0
  12. data/docker-compose.yml +17 -0
  13. data/lib/rspec_api_blueprint_matchers.rb +1 -0
  14. data/lib/rspec_apib/config.rb +1 -0
  15. data/lib/rspec_apib/elements/annotation.rb +1 -0
  16. data/lib/rspec_apib/elements/array.rb +1 -0
  17. data/lib/rspec_apib/elements/asset.rb +1 -0
  18. data/lib/rspec_apib/elements/base.rb +11 -10
  19. data/lib/rspec_apib/elements/category.rb +2 -1
  20. data/lib/rspec_apib/elements/copy.rb +2 -1
  21. data/lib/rspec_apib/elements/data_structure.rb +2 -0
  22. data/lib/rspec_apib/elements/href_variables.rb +3 -2
  23. data/lib/rspec_apib/elements/http_headers.rb +5 -4
  24. data/lib/rspec_apib/elements/http_message_payload.rb +3 -2
  25. data/lib/rspec_apib/elements/http_request.rb +16 -10
  26. data/lib/rspec_apib/elements/http_response.rb +3 -1
  27. data/lib/rspec_apib/elements/http_transaction.rb +4 -3
  28. data/lib/rspec_apib/elements/member.rb +3 -2
  29. data/lib/rspec_apib/elements/object.rb +2 -1
  30. data/lib/rspec_apib/elements/parse_result.rb +1 -0
  31. data/lib/rspec_apib/elements/resource.rb +1 -0
  32. data/lib/rspec_apib/elements/source_map.rb +1 -0
  33. data/lib/rspec_apib/elements/string.rb +1 -0
  34. data/lib/rspec_apib/elements/templated_href.rb +1 -0
  35. data/lib/rspec_apib/elements/transition.rb +1 -0
  36. data/lib/rspec_apib/elements.rb +1 -0
  37. data/lib/rspec_apib/extractors/http_transaction.rb +1 -0
  38. data/lib/rspec_apib/extractors/resource.rb +1 -0
  39. data/lib/rspec_apib/extractors.rb +1 -0
  40. data/lib/rspec_apib/parser.rb +2 -1
  41. data/lib/rspec_apib/request.rb +7 -10
  42. data/lib/rspec_apib/response.rb +2 -2
  43. data/lib/rspec_apib/rspec.rb +4 -3
  44. data/lib/rspec_apib/transaction_coverage_report.rb +4 -3
  45. data/lib/rspec_apib/transaction_coverage_validator.rb +4 -3
  46. data/lib/rspec_apib/transaction_validator.rb +1 -0
  47. data/lib/rspec_apib/transcluder.rb +2 -2
  48. data/lib/rspec_apib/version.rb +2 -1
  49. data/lib/rspec_apib.rb +2 -1
  50. data/lib/transcluder.rb +1 -0
  51. data/rspec_api_blueprint_matchers.gemspec +6 -4
  52. metadata +25 -2
@@ -0,0 +1,94 @@
1
+ # Metrics::AbcSize
2
+ # (Assignment Branch Condition)
3
+ #
4
+ # Checks that the ABC size of methods is not higher thatn the configured maximum
5
+
6
+ Metrics/AbcSize:
7
+ Max: 15
8
+
9
+ # Metrics::BlockLength
10
+ #
11
+ # Checks if the length of a block exceeds some maximum value.
12
+ # Comment lines are ignored
13
+
14
+ Metrics/BlockLength:
15
+ CountComments: false
16
+ Max: 25
17
+ Exclude:
18
+ - 'Rakefile'
19
+ - '**/*.rake'
20
+ - 'spec/**/*.rb'
21
+
22
+ # Metrics::BlockNesting
23
+ #
24
+ # Checks for excessive nesting of conditional and looping constructs
25
+
26
+ Metrics/BlockNesting:
27
+ Max: 3
28
+
29
+ # Metrics::ClassLength
30
+ #
31
+ # Checks if the length of a class exceeds some maximum value.
32
+ # This can be used to ensure 'one responsibility per class" rule.
33
+
34
+ Metrics/ClassLength:
35
+ CountComments: false
36
+ Max: 100
37
+
38
+ # Metrics::CyclomaticComplexity
39
+ #
40
+ # Checks that the cyclomatic complexity of methods is not higher than the configured maximum.
41
+ # (Cyclomatic complexity is the number of linearly independent paths through a method)
42
+
43
+ Metrics/CyclomaticComplexity:
44
+ Max: 6
45
+
46
+ # Metrics::LineLength
47
+ #
48
+ # Checks the length of lines in the source code.
49
+
50
+ Metrics/LineLength:
51
+ Max: 160
52
+ AllowHereDoc: true
53
+ AllowURI: true
54
+ URISchemes:
55
+ -http
56
+ -https
57
+ Exclude:
58
+ - "spec/**/*"
59
+ - "views/**/*"
60
+ - "public/**/*"
61
+
62
+ # Metrics::MethodLength
63
+ #
64
+ # Checks if the length of the method exceeds some maximum value.
65
+
66
+ Metrics/MethodLength:
67
+ CountComments: false
68
+ Max: 10
69
+
70
+ # Metrics::ModuleLength
71
+ #
72
+ # Checks if the length of a module exceeds some maximum value.
73
+
74
+ Metrics/ModuleLength:
75
+ CountComments: false
76
+ Max: 100
77
+
78
+ # Metrics::ParameterLists
79
+ #
80
+ # Checks for methods with too many parameters.
81
+
82
+ Metrics/ParameterLists:
83
+ Max: 5
84
+ CountKeywordArgs: true
85
+
86
+
87
+ # Metrics::PerceivedComplexity
88
+ #
89
+ # Tries to product a complexity score that's a measure of the complexity
90
+ # the reader experiences when looking at a method.
91
+
92
+ Metrics/PerceivedComplexity:
93
+ Max: 7
94
+
@@ -0,0 +1,323 @@
1
+ # Performance::CaseWhenSplat
2
+ #
3
+ # Place `when` conditions that use splat at the end of the list of `when` branches.
4
+ #
5
+ # bad:
6
+ #
7
+ # case foo
8
+ # when *condition
9
+ # bar
10
+ # when baz
11
+ # foobar
12
+ # end
13
+ #
14
+ # good:
15
+ #
16
+ # case foo
17
+ # when baz
18
+ # foobar
19
+ # when *condition
20
+ # bar
21
+ # end
22
+
23
+ Performance/CaseWhenSplat:
24
+ Enabled: true
25
+
26
+ # Performance::Casecmp
27
+ #
28
+ # Identifies places where a case-insensitive string comparison can better be implemented
29
+ # using `casecmp`
30
+ #
31
+ # bad: str.downcase == 'abc'
32
+ #
33
+ # good: str.casecmp('abc').zero?
34
+
35
+ Performance/Casecmp:
36
+ Enabled: true
37
+
38
+ # Performance::CompareWithBlock
39
+ #
40
+ # Identifies place where `sort{ |a, b| a.foo <=> b.foo }` can be replaced by `sort_by(&:foo)`.
41
+ # This cop also checks `max` and `min` methods.
42
+ #
43
+ # bad: array.sort { |a, b| a.foo <=> b.foo }
44
+ #
45
+ # good: array.sort_by(&:foo)
46
+
47
+ Performance/CompareWithBlock:
48
+ Enabled: true
49
+
50
+ # Performance::Count
51
+ #
52
+ # Identifies usages of `count` on an `Enumerable` that follow calls to `select` or `reject`.
53
+ # Querying logic can instead be passed to the `count` call.
54
+ #
55
+ # Example:
56
+ # Model.where(id: [1, 2, 3].select { |m| m.method == true }.size
57
+ # becomes ->
58
+ # Model.where(id: [1, 2, 3].to_a.count { |m| m.method == true }
59
+
60
+ Performance/Count:
61
+ Enabled: true
62
+
63
+ # Performance::Detect
64
+ #
65
+ # Identify usages of `select.first`, `select.last`, `find_all.first` and `find_all.last` and
66
+ # change them to use `detect` instead
67
+ # `ActiveRecord` compatibility: `ActiveRecord` does not implement a `detect` method and `find`
68
+ # has its own meaning
69
+ #
70
+ # bad:
71
+ #
72
+ # [].select { |item| true }.first
73
+ # [].find_all { |item| true ).last
74
+ #
75
+ # good:
76
+ #
77
+ # [].detect { |item| true }
78
+ # [].reverse.detect { |item| true }
79
+
80
+ Performance/Detect:
81
+ Enabled: true
82
+
83
+ # Performance::DoubleStartEndWith
84
+ #
85
+ # Checks for double `#start_with?` or `#end_with?` calls separated by `||`.
86
+ #
87
+ # bad: str.start_with?("a") || str.start_with?(Some::CONST)
88
+ #
89
+ # good: str.start_with?("a", Some::CONST)
90
+
91
+ Performance/DoubleStartEndWith:
92
+ Enabled: true
93
+
94
+ # Performance::EndWith
95
+ #
96
+ # Identifies unnecessary use of a regex where `String#end_with?` would suffice
97
+ #
98
+ # bad:
99
+ #
100
+ # 'abc' =~ /bc\Z/
101
+ # 'abc'.match(/bc\Z/)
102
+ #
103
+ # good:
104
+ #
105
+ # 'abc' =~ /ab/
106
+ # 'abc' =~ /\w*\Z/
107
+
108
+ Performance::EndWith:
109
+ Enabled: true
110
+
111
+ # Performance::FixedSize
112
+ #
113
+ # Do not compute the size of statically sized objects.
114
+
115
+ Performance::FixedSize:
116
+ Enabled: true
117
+
118
+ # Lint::FlatMap
119
+ #
120
+ # Used of identify usages of flatten with map and collect
121
+ #
122
+ # bad:
123
+ #
124
+ # [1, 2, 3, 4].map { |e| [e, e] }.flatten(1)
125
+ # [1, 2, 3, 4].collect { |e| [e, e] }.flatten(1)
126
+ #
127
+ # good:
128
+ #
129
+ # [1, 2, 3, 4].flat_map { |e| [e, e] }
130
+ # [1, 2, 3, 4].map { |e| [e, e] }.flatten
131
+ # [1, 2, 3, 4].collect { |e| [e, e] }.flatten
132
+
133
+ Performance/FlatMap:
134
+ Enabled: true
135
+
136
+ # Performance::HashEachMethods
137
+ #
138
+ # Checks for uses of `each_key` and `each_value` Hash methods.
139
+ #
140
+ # bad:
141
+ #
142
+ # hash.keys.each { |k| p k }
143
+ # hash.values.each { |v| p v }
144
+ #
145
+ # good:
146
+ #
147
+ # hash.each_key { |k| p k }
148
+ # hash.each_value { |v| p v }
149
+
150
+ Performance/HashEachMethods:
151
+ Enabled: true
152
+
153
+ # Performance::LstripRstrip
154
+ #
155
+ # Identifies places where `lstrip.rstrip` can be replaced by `strip`
156
+ #
157
+ # bad:
158
+ #
159
+ # 'abc'.lstrip.rstrip
160
+ # 'abc'.rstrip.lstrip
161
+ #
162
+ # good:
163
+ #
164
+ # 'abc'.strip
165
+
166
+ Performance/LstripRstrip:
167
+ Enabled: true
168
+
169
+ # Performance::RangeInclude
170
+ #
171
+ # Identifies uses of `Range#include?`, which iterates over each item in a `Range`
172
+ # to see if a specified item is there. `Range#cover?` simply compares the target item
173
+ # with the beginning and end points of the `Range`.
174
+ #
175
+ # Example: ('a'..'z').cover?('yellow')
176
+
177
+ Performance/RangeInclude:
178
+ Enabled: true
179
+
180
+ # Performance::RedundantBlockCall
181
+ #
182
+ # Identifies the use of a `&block` parameter and `block.call` where `yield` would do just as well.
183
+ #
184
+ # bad:
185
+ #
186
+ # def method(&block)
187
+ # block.call
188
+ # end
189
+ #
190
+ # good:
191
+ #
192
+ # def method
193
+ # yield
194
+ # end
195
+
196
+ Performance/RedundantBlockCall:
197
+ Enabled: true
198
+
199
+ # Performance::RedundantMatch
200
+ #
201
+ # Identifies use of `Regexp#match` or `String#match` in a context where the integral return
202
+ # value of `=~` would do just well
203
+ #
204
+ # bad:
205
+ #
206
+ # do_something if str.match(/regex/)
207
+ # while regex.match('str')
208
+ # do_something
209
+ # end
210
+ #
211
+ # good:
212
+ #
213
+ # method(str.match(/regex/)
214
+ # return regex.match('str')
215
+
216
+ Performance/RedundantMatch:
217
+ Enabled: true
218
+
219
+ # Performance::RedundantMerge
220
+ #
221
+ # Identifies places where `Hash#merge!` can be replaced by `Hash#[]=`.
222
+ #
223
+ # Examples:
224
+ #
225
+ # hash.merge!(a: 1)
226
+ # hash.merge!({key: 'value'})
227
+ # hash.merge1({ :a => 1, :b=> 2})
228
+
229
+ Performance/RedundantMerge:
230
+ Enabled: false
231
+
232
+ # Performance::RedundantSortBy
233
+ #
234
+ # Identifies places where `sort_by{ ... }` can be replaced by `sort`.
235
+ #
236
+ # bad:
237
+ #
238
+ # array.sort_by { |x| x }
239
+ # array.sort_by do |var|
240
+ # var
241
+ # end
242
+ #
243
+ # good:
244
+ #
245
+ # array.sort
246
+
247
+ Performance/RedundantSortBy:
248
+ Enabled: true
249
+
250
+ # Performance::ReverseEach
251
+ #
252
+ # Identify usages of `reverse.each` and change them to use `reverse_each` instead.
253
+ #
254
+ # bad: [].reverse.each
255
+ #
256
+ # good: [].reverse_each
257
+
258
+ Performance/ReverseEach:
259
+ Enabled: true
260
+
261
+ # Performance::Sample
262
+ #
263
+ # Identify usages of `shuffle.first`, `shuffle.last` and `shuffle[]` and change them to
264
+ # use `sample` instead
265
+ #
266
+ # bad: [1, 2, 3].shuffle.first
267
+ #
268
+ # good: [1, 2, 3].sample
269
+
270
+ Performance/Sample:
271
+ Enabled: true
272
+
273
+ # Performance::Size
274
+ #
275
+ # Identify usages of `count` on an `Array` and `Hash` and change them to `size`.
276
+ #
277
+ # bad: [1, 2, 3].count
278
+ #
279
+ # good: [1, 2, 3].size
280
+
281
+ Performance/Size:
282
+ Enabled: true
283
+
284
+ # Performance::StartWith
285
+ #
286
+ # Identifies unnecessary use of a regex where `String#start_with?` would suffice
287
+ #
288
+ # bad: 'abc' =~ /\Aab/
289
+ #
290
+ # good: 'abc' =~ /ab/
291
+
292
+ Performance/StartWith:
293
+ Enabled: true
294
+
295
+ # Performance::StringReplacement
296
+ #
297
+ # Identifies places where `gsub` can be replaced by `tr` or `delete`
298
+ #
299
+ # bad: 'abc'.gsub('b', 'd')
300
+ #
301
+ # good: 'abc'.tr('b', 'd')
302
+
303
+ Performance/StringReplacement:
304
+ Enabled: true
305
+
306
+ # Performance::TimesMap
307
+ #
308
+ # Checks for .times.map calls. In most cases this can be replaced with an explicit array creation.
309
+ #
310
+ # bad:
311
+ #
312
+ # 9.times.map do |i|
313
+ # i.to_s
314
+ # end
315
+ #
316
+ # good:
317
+ #
318
+ # Array.new(9) do |i|
319
+ # i.to_s
320
+ # end
321
+
322
+ Performance/TimesMap:
323
+ Enabled: true
@@ -0,0 +1,256 @@
1
+ Rails:
2
+ Enabled: true
3
+
4
+ # Rails::ActionFilter
5
+ #
6
+ # Enforces the consistent use of action filter methods.
7
+ # This is configurable and can enforce user of
8
+ # older something_filter methods of newer something_action methods
9
+
10
+ Rails/ActionFilter:
11
+ EnforcedStyle: action
12
+
13
+ # Rails::Date
14
+ #
15
+ # Checks for the correct use of Date methods
16
+ #
17
+ # bad:
18
+ #
19
+ # Date.today
20
+ # date.to_time
21
+
22
+ Rails/Date:
23
+ EnforcedStyle: flexible
24
+
25
+ # Rails::Delegate
26
+ #
27
+ # Looks for delegations, that could have been created automatically with delegate method
28
+ #
29
+ # bad:
30
+ #
31
+ # def bar
32
+ # foo.bar
33
+ # end
34
+ #
35
+ # good:
36
+ #
37
+ # delegate :bar, to: :foo
38
+ #
39
+
40
+ Rails/Delegate:
41
+ Enabled: true
42
+
43
+ # Rails::DelegateAllowBlank
44
+ #
45
+ # Looks for delegations that pass :allow_blank as an option instead of :allow_nil.
46
+
47
+ Rails/DelegateAllowBlank:
48
+ Enabled: true
49
+
50
+ # Rails::DynamicFindBy
51
+ #
52
+ # Checks dynamic `find_by_*` methods. Use `find_by` instead of dynamic method.
53
+ # (When retrieve a single record by some attributes, prefer `find_by`)
54
+ # For more info: https://github.com/bbatsov/rails-style-guide#find_by
55
+ #
56
+ # bad: User.find_by_name(name)
57
+ #
58
+ # good: User.find_by(name: name)
59
+ #
60
+
61
+ Rails/DynamicFindBy:
62
+ Whitelist:
63
+ - find_by_sql
64
+
65
+ # Rails::EnumUniqueness
66
+ #
67
+ # Looks for duplicate values in enum decorations.
68
+ #
69
+ # bad: enum status { active: 0, archived: 0 }
70
+ #
71
+ # good: enum status { active: 0, archived: 1 }
72
+
73
+ Rails/EnumUniqueness:
74
+ Enabled: true
75
+
76
+ # Rails::Exit
77
+ #
78
+ # Enforces that 'exit' calls are not used withing a rails app.
79
+
80
+ Rails/Exit:
81
+ Enabled: true
82
+
83
+ # Rails::FindBy
84
+ #
85
+ # Used to identify usages of `where.first` and change them to use `find_by` instead
86
+ #
87
+ # bad: User.where(name: 'Prasanna').first
88
+ #
89
+ # good: User.find_by(name: 'Prasanna')
90
+
91
+ Rails/FindBy:
92
+ Enabled: true
93
+
94
+ # Rails::FindEach
95
+ #
96
+ # Used to identify usages of `all.each` and change them to use `all.find_each` instead.
97
+ #
98
+ # bad: User.all.each
99
+ #
100
+ # good: User.all.find_each
101
+
102
+ Rails/FindEach:
103
+ Enabled: true
104
+
105
+ # Rails::HasAndBelongsToMany
106
+ #
107
+ # Checks for the use of the has_and_belongs_to_many macro
108
+ # Prefer 'has_many :through'
109
+
110
+ Rails/HasAndBelongsToMany:
111
+ Enabled: true
112
+
113
+ # Rails::HttpPositionalArguments
114
+ #
115
+ # Identifies usages of http methods like 'get', 'post', 'put', 'path' without the usage
116
+ # of keyword arguments in tests and change them to keyword arguments.
117
+ #
118
+ # bad: get :new, { user_id: 1 }
119
+ #
120
+ # good: get :new, params: { user_id: 1 }
121
+
122
+ Rails/HttpPositionalArugments:
123
+ Enabled: false
124
+
125
+ # Rails::NotNullColumn
126
+ #
127
+ # Checks for add_column call with NOT NULL constraint in migration file.
128
+ #
129
+ # bad: add_column :users, :name, :string, null: false
130
+ #
131
+ # good: add_column :users, :name, :string, null: false, default: ''
132
+
133
+ Rails/NotNullColumn:
134
+ Enabled: false
135
+
136
+ # Rails::Output
137
+ #
138
+ # Checks for the use of output calls like print and puts
139
+
140
+ Rails/Output:
141
+ Enabled: true
142
+
143
+ # Rails::OutputSafety
144
+ #
145
+ # Checks for the use of output safety calls like html_safe and raw
146
+ #
147
+ # bad: "<p>#{text}></p>".html_safe
148
+ #
149
+ # good: content_tag(:p, text)
150
+
151
+ Rails/OutputSafety:
152
+ Enabled: true
153
+
154
+ # Rails::PluralizationGrammar
155
+ #
156
+ # Checks for correct grammar when using ActiveSupport`s core extensions to the numeric classes.
157
+ #
158
+ # bad:
159
+ #
160
+ # 3.day.ago
161
+ # 1.months.ago
162
+ #
163
+ # good:
164
+ #
165
+ # 3.days.ago
166
+ # 1.month.ago
167
+
168
+ Rails/PluralizationGrammar:
169
+ Enabled: true
170
+
171
+ # Rails::ReadWriteGrammar
172
+ #
173
+ # Checks for the use of the read_attribute or write_attribute methods.
174
+ #
175
+ # bad:
176
+ #
177
+ # x = read_attribute(:attr)
178
+ # write_attribute(:attr, val)
179
+ #
180
+ # good:
181
+ #
182
+ # x = self[:attr]
183
+ # self[:attr] = val
184
+
185
+ Rails/ReadWriteGrammer:
186
+ Enabled: true
187
+
188
+ # Rails::RequestReferrer
189
+ #
190
+ # Checks for consistent uses of request.referrer
191
+
192
+ Rails/ReadWriteGrammer:
193
+ EnforcedStyle: referer
194
+
195
+ # Rails::SafeNavigation
196
+ #
197
+ # Converts usages of `try!` to `&.`. It can also be configured to convert `try`.
198
+ # It will convert code to use navigation if the target Ruby version is set to 2.3+
199
+
200
+ Rails/SafeNavigation:
201
+ ConvertTry: false
202
+
203
+ # Rails::SafeBang
204
+ #
205
+ # Identifies possible cases where Active Record save! or related should be used
206
+ # instead of save because the model might have failed to save and an excpetion is better
207
+ # then unhandled failure
208
+ #
209
+ # bad: user.save
210
+ #
211
+ # good: user.save!
212
+
213
+ Rails/SafeBang:
214
+ Enabled: true
215
+
216
+ # Rails::ScopeArgs
217
+ #
218
+ # Checks for scope class where it was passed a method (usually a scope) instead of a lambda/proc.
219
+ #
220
+ # bad: scope :something, where(something: true)
221
+ #
222
+ # good: scope :something, -> { where(something: true) }
223
+
224
+ Rails/ScopeArgs:
225
+ Enabled: true
226
+
227
+ # Rails::Timezone
228
+ #
229
+ # Checks for the use of Time methods without zone
230
+ #
231
+ # bad:
232
+ #
233
+ # Time.now
234
+ # Time.parse('2015-03-02 19:05:37')
235
+
236
+ Rails/Timezone:
237
+ EnforcedStyle: flexible
238
+
239
+ # Rails::UniqBeforePluck
240
+ #
241
+ # Prefer the use of uniq (or distinct), before pluck instead of after.
242
+ #
243
+ # bad: Model.pluck(:id).uniq
244
+ #
245
+ # good: Model.uniq.pluck(:id)
246
+
247
+ Rails/UniqBeforePluck:
248
+ EnforcedMode: conservative
249
+ AutoCorrect: true
250
+
251
+ # Rails::Validation
252
+ #
253
+ # Checks for the use of old-style attribute validation macros.
254
+
255
+ Rails/Validation:
256
+ Enabled: true