rubocop 0.18.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubocop might be problematic. Click here for more details.

Files changed (398) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +65 -1
  4. data/Gemfile +0 -3
  5. data/LICENSE.txt +1 -1
  6. data/README.md +179 -77
  7. data/Rakefile +8 -0
  8. data/config/default.yml +151 -14
  9. data/config/enabled.yml +65 -8
  10. data/lib/rubocop.rb +19 -4
  11. data/lib/rubocop/cli.rb +2 -1
  12. data/lib/rubocop/comment_config.rb +97 -0
  13. data/lib/rubocop/config.rb +1 -1
  14. data/lib/rubocop/config_loader.rb +3 -2
  15. data/lib/rubocop/config_store.rb +6 -2
  16. data/lib/rubocop/cop/commissioner.rb +2 -2
  17. data/lib/rubocop/cop/cop.rb +22 -26
  18. data/lib/rubocop/cop/lint/ambiguous_operator.rb +2 -2
  19. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +1 -1
  20. data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -1
  21. data/lib/rubocop/cop/lint/block_alignment.rb +6 -6
  22. data/lib/rubocop/cop/lint/condition_position.rb +1 -1
  23. data/lib/rubocop/cop/lint/debugger.rb +1 -1
  24. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +60 -0
  25. data/lib/rubocop/cop/lint/else_layout.rb +1 -1
  26. data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
  27. data/lib/rubocop/cop/lint/end_alignment.rb +14 -12
  28. data/lib/rubocop/cop/lint/end_in_method.rb +1 -1
  29. data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
  30. data/lib/rubocop/cop/lint/eval.rb +1 -1
  31. data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -1
  32. data/lib/rubocop/cop/lint/literal_in_condition.rb +13 -2
  33. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +28 -0
  34. data/lib/rubocop/cop/lint/loop.rb +4 -4
  35. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
  36. data/lib/rubocop/cop/lint/require_parentheses.rb +6 -6
  37. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
  38. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +2 -2
  39. data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +30 -0
  40. data/lib/rubocop/cop/lint/syntax.rb +5 -5
  41. data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
  42. data/lib/rubocop/cop/lint/useless_assignment.rb +5 -5
  43. data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
  44. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  45. data/lib/rubocop/cop/lint/void.rb +5 -5
  46. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +8 -5
  47. data/lib/rubocop/cop/mixin/code_length.rb +2 -2
  48. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +7 -7
  49. data/lib/rubocop/cop/mixin/configurable_max.rb +1 -1
  50. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  51. data/lib/rubocop/cop/mixin/if_then_else.rb +1 -1
  52. data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
  53. data/lib/rubocop/cop/mixin/parser_diagnostic.rb +2 -2
  54. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +3 -2
  55. data/lib/rubocop/cop/mixin/space_inside.rb +1 -1
  56. data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -0
  57. data/lib/rubocop/cop/mixin/string_help.rb +4 -4
  58. data/lib/rubocop/cop/{offence.rb → offense.rb} +7 -7
  59. data/lib/rubocop/cop/rails/action_filter.rb +73 -0
  60. data/lib/rubocop/cop/rails/default_scope.rb +1 -1
  61. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +1 -1
  62. data/lib/rubocop/cop/rails/output.rb +1 -10
  63. data/lib/rubocop/cop/rails/read_attribute.rb +1 -1
  64. data/lib/rubocop/cop/rails/scope_args.rb +33 -0
  65. data/lib/rubocop/cop/rails/validation.rb +1 -1
  66. data/lib/rubocop/cop/style/access_modifier_indentation.rb +1 -1
  67. data/lib/rubocop/cop/style/accessor_method_name.rb +2 -2
  68. data/lib/rubocop/cop/style/alias.rb +2 -2
  69. data/lib/rubocop/cop/style/align_array.rb +1 -1
  70. data/lib/rubocop/cop/style/align_hash.rb +29 -2
  71. data/lib/rubocop/cop/style/align_parameters.rb +16 -2
  72. data/lib/rubocop/cop/style/and_or.rb +2 -2
  73. data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
  74. data/lib/rubocop/cop/style/ascii_identifiers.rb +1 -1
  75. data/lib/rubocop/cop/style/attr.rb +1 -1
  76. data/lib/rubocop/cop/style/begin_block.rb +1 -1
  77. data/lib/rubocop/cop/style/block_comments.rb +1 -1
  78. data/lib/rubocop/cop/style/block_nesting.rb +1 -1
  79. data/lib/rubocop/cop/style/blocks.rb +2 -2
  80. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +2 -2
  81. data/lib/rubocop/cop/style/case_equality.rb +1 -1
  82. data/lib/rubocop/cop/style/case_indentation.rb +2 -2
  83. data/lib/rubocop/cop/style/character_literal.rb +2 -2
  84. data/lib/rubocop/cop/style/class_and_module_camel_case.rb +1 -1
  85. data/lib/rubocop/cop/style/class_and_module_children.rb +69 -0
  86. data/lib/rubocop/cop/style/class_methods.rb +1 -1
  87. data/lib/rubocop/cop/style/class_vars.rb +3 -3
  88. data/lib/rubocop/cop/style/collection_methods.rb +4 -4
  89. data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
  90. data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
  91. data/lib/rubocop/cop/style/constant_name.rb +1 -1
  92. data/lib/rubocop/cop/style/cyclomatic_complexity.rb +2 -2
  93. data/lib/rubocop/cop/style/def_parentheses.rb +2 -2
  94. data/lib/rubocop/cop/style/documentation.rb +1 -1
  95. data/lib/rubocop/cop/style/dot_position.rb +10 -11
  96. data/lib/rubocop/cop/style/double_negation.rb +40 -0
  97. data/lib/rubocop/cop/style/empty_line_between_defs.rb +8 -1
  98. data/lib/rubocop/cop/style/empty_lines.rb +3 -2
  99. data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +1 -1
  100. data/lib/rubocop/cop/style/empty_lines_around_body.rb +1 -1
  101. data/lib/rubocop/cop/style/empty_literal.rb +3 -3
  102. data/lib/rubocop/cop/style/encoding.rb +1 -1
  103. data/lib/rubocop/cop/style/end_block.rb +1 -1
  104. data/lib/rubocop/cop/style/end_of_line.rb +2 -2
  105. data/lib/rubocop/cop/style/even_odd.rb +2 -2
  106. data/lib/rubocop/cop/style/favor_join.rb +1 -1
  107. data/lib/rubocop/cop/style/file_name.rb +29 -0
  108. data/lib/rubocop/cop/style/final_newline.rb +1 -1
  109. data/lib/rubocop/cop/style/flip_flop.rb +2 -2
  110. data/lib/rubocop/cop/style/for.rb +2 -2
  111. data/lib/rubocop/cop/style/format_string.rb +66 -0
  112. data/lib/rubocop/cop/style/global_vars.rb +2 -2
  113. data/lib/rubocop/cop/style/hash_methods.rb +1 -1
  114. data/lib/rubocop/cop/style/hash_syntax.rb +3 -3
  115. data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -1
  116. data/lib/rubocop/cop/style/indent_array.rb +41 -0
  117. data/lib/rubocop/cop/style/indent_hash.rb +119 -0
  118. data/lib/rubocop/cop/style/indentation_consistency.rb +3 -11
  119. data/lib/rubocop/cop/style/indentation_width.rb +44 -23
  120. data/lib/rubocop/cop/style/lambda.rb +2 -2
  121. data/lib/rubocop/cop/style/lambda_call.rb +3 -3
  122. data/lib/rubocop/cop/style/leading_comment_space.rb +1 -1
  123. data/lib/rubocop/cop/style/line_end_concatenation.rb +7 -3
  124. data/lib/rubocop/cop/style/line_length.rb +2 -2
  125. data/lib/rubocop/cop/style/method_call_parentheses.rb +2 -2
  126. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -2
  127. data/lib/rubocop/cop/style/method_def_parentheses.rb +9 -7
  128. data/lib/rubocop/cop/style/module_function.rb +1 -1
  129. data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
  130. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
  131. data/lib/rubocop/cop/style/nested_ternary_operator.rb +2 -2
  132. data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
  133. data/lib/rubocop/cop/style/not.rb +1 -1
  134. data/lib/rubocop/cop/style/numeric_literals.rb +5 -5
  135. data/lib/rubocop/cop/style/op_method.rb +2 -2
  136. data/lib/rubocop/cop/style/parameter_lists.rb +1 -1
  137. data/lib/rubocop/cop/style/parentheses_around_condition.rb +5 -4
  138. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +143 -0
  139. data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
  140. data/lib/rubocop/cop/style/predicate_name.rb +1 -1
  141. data/lib/rubocop/cop/style/proc.rb +1 -1
  142. data/lib/rubocop/cop/style/raise_args.rb +2 -2
  143. data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
  144. data/lib/rubocop/cop/style/redundant_exception.rb +1 -1
  145. data/lib/rubocop/cop/style/redundant_return.rb +1 -1
  146. data/lib/rubocop/cop/style/redundant_self.rb +2 -2
  147. data/lib/rubocop/cop/style/regexp_literal.rb +45 -19
  148. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
  149. data/lib/rubocop/cop/style/self_assignment.rb +73 -0
  150. data/lib/rubocop/cop/style/semicolon.rb +12 -8
  151. data/lib/rubocop/cop/style/signal_exception.rb +2 -2
  152. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  153. data/lib/rubocop/cop/style/single_line_methods.rb +38 -1
  154. data/lib/rubocop/cop/style/space_after_colon.rb +3 -3
  155. data/lib/rubocop/cop/style/space_after_comma.rb +1 -1
  156. data/lib/rubocop/cop/style/space_after_control_keyword.rb +1 -1
  157. data/lib/rubocop/cop/style/space_after_method_name.rb +11 -3
  158. data/lib/rubocop/cop/style/space_after_not.rb +1 -1
  159. data/lib/rubocop/cop/style/space_after_semicolon.rb +1 -1
  160. data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +41 -6
  161. data/lib/rubocop/cop/style/space_around_operators.rb +4 -4
  162. data/lib/rubocop/cop/style/space_before_block_braces.rb +63 -0
  163. data/lib/rubocop/cop/style/space_before_modifier_keyword.rb +1 -1
  164. data/lib/rubocop/cop/style/{space_around_block_braces.rb → space_inside_block_braces.rb} +15 -24
  165. data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +14 -7
  166. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  167. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  168. data/lib/rubocop/cop/style/symbol_array.rb +1 -1
  169. data/lib/rubocop/cop/style/tab.rb +1 -1
  170. data/lib/rubocop/cop/style/trailing_blank_lines.rb +2 -2
  171. data/lib/rubocop/cop/style/trailing_comma.rb +4 -4
  172. data/lib/rubocop/cop/style/trailing_whitespace.rb +1 -1
  173. data/lib/rubocop/cop/style/trivial_accessors.rb +2 -2
  174. data/lib/rubocop/cop/style/unless_else.rb +1 -1
  175. data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
  176. data/lib/rubocop/cop/style/when_then.rb +1 -1
  177. data/lib/rubocop/cop/style/while_until_do.rb +1 -1
  178. data/lib/rubocop/cop/style/while_until_modifier.rb +2 -1
  179. data/lib/rubocop/cop/style/word_array.rb +2 -2
  180. data/lib/rubocop/cop/team.rb +24 -7
  181. data/lib/rubocop/cop/util.rb +3 -3
  182. data/lib/rubocop/cop/variable_inspector.rb +25 -13
  183. data/lib/rubocop/cop/variable_inspector/assignment.rb +1 -1
  184. data/lib/rubocop/cop/variable_inspector/reference.rb +1 -1
  185. data/lib/rubocop/cop/variable_inspector/scope.rb +1 -1
  186. data/lib/rubocop/cop/variable_inspector/variable.rb +2 -2
  187. data/lib/rubocop/cop/variable_inspector/variable_table.rb +1 -1
  188. data/lib/rubocop/file_inspector.rb +12 -13
  189. data/lib/rubocop/formatter/base_formatter.rb +4 -4
  190. data/lib/rubocop/formatter/clang_style_formatter.rb +2 -2
  191. data/lib/rubocop/formatter/disabled_config_formatter.rb +12 -12
  192. data/lib/rubocop/formatter/emacs_style_formatter.rb +3 -2
  193. data/lib/rubocop/formatter/file_list_formatter.rb +4 -4
  194. data/lib/rubocop/formatter/formatter_set.rb +2 -1
  195. data/lib/rubocop/formatter/fuubar_style_formatter.rb +76 -0
  196. data/lib/rubocop/formatter/json_formatter.rb +17 -16
  197. data/lib/rubocop/formatter/offense_count_formatter.rb +54 -0
  198. data/lib/rubocop/formatter/progress_formatter.rb +16 -16
  199. data/lib/rubocop/formatter/simple_text_formatter.rb +25 -25
  200. data/lib/rubocop/options.rb +8 -7
  201. data/lib/rubocop/processed_source.rb +3 -2
  202. data/lib/rubocop/source_parser.rb +1 -59
  203. data/lib/rubocop/version.rb +3 -3
  204. data/relnotes/0.19.0.md +70 -0
  205. data/rubocop-todo.yml +6 -6
  206. data/rubocop.gemspec +2 -1
  207. data/spec/rubocop/cli_spec.rb +431 -268
  208. data/spec/rubocop/comment_config_spec.rb +103 -0
  209. data/spec/rubocop/config_loader_spec.rb +4 -4
  210. data/spec/rubocop/cop/commissioner_spec.rb +7 -7
  211. data/spec/rubocop/cop/cop_spec.rb +17 -17
  212. data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +16 -16
  213. data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +5 -5
  214. data/spec/rubocop/cop/lint/assignment_in_condition_spec.rb +19 -19
  215. data/spec/rubocop/cop/lint/block_alignment_spec.rb +52 -52
  216. data/spec/rubocop/cop/lint/condition_position_spec.rb +7 -7
  217. data/spec/rubocop/cop/lint/debugger_spec.rb +10 -10
  218. data/spec/rubocop/cop/lint/deprecated_class_methods_spec.rb +33 -0
  219. data/spec/rubocop/cop/lint/else_layout_spec.rb +7 -7
  220. data/spec/rubocop/cop/lint/empty_ensure_spec.rb +4 -4
  221. data/spec/rubocop/cop/lint/end_alignment_spec.rb +33 -34
  222. data/spec/rubocop/cop/lint/end_in_method_spec.rb +5 -5
  223. data/spec/rubocop/cop/lint/ensure_return_spec.rb +4 -4
  224. data/spec/rubocop/cop/lint/eval_spec.rb +8 -8
  225. data/spec/rubocop/cop/lint/handle_exceptions_spec.rb +4 -4
  226. data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +3 -3
  227. data/spec/rubocop/cop/lint/literal_in_condition_spec.rb +65 -10
  228. data/spec/rubocop/cop/lint/literal_in_interpolation_spec.rb +21 -0
  229. data/spec/rubocop/cop/lint/loop_spec.rb +6 -6
  230. data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +14 -14
  231. data/spec/rubocop/cop/lint/require_parentheses_spec.rb +15 -15
  232. data/spec/rubocop/cop/lint/rescue_exception_spec.rb +21 -21
  233. data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +16 -16
  234. data/spec/rubocop/cop/lint/string_conversion_in_interpolation_spec.rb +27 -0
  235. data/spec/rubocop/cop/lint/syntax_spec.rb +11 -11
  236. data/spec/rubocop/cop/lint/unreachable_code_spec.rb +8 -8
  237. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +207 -169
  238. data/spec/rubocop/cop/lint/useless_comparison_spec.rb +5 -5
  239. data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +4 -4
  240. data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +17 -17
  241. data/spec/rubocop/cop/lint/void_spec.rb +8 -8
  242. data/spec/rubocop/cop/{offence_spec.rb → offense_spec.rb} +17 -17
  243. data/spec/rubocop/cop/rails/action_filter_spec.rb +69 -0
  244. data/spec/rubocop/cop/rails/default_scope_spec.rb +9 -9
  245. data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +2 -2
  246. data/spec/rubocop/cop/rails/output_spec.rb +8 -18
  247. data/spec/rubocop/cop/rails/read_attribute_spec.rb +2 -2
  248. data/spec/rubocop/cop/rails/scope_args_spec.rb +25 -0
  249. data/spec/rubocop/cop/rails/validation_spec.rb +3 -3
  250. data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +38 -38
  251. data/spec/rubocop/cop/style/accessor_method_name_spec.rb +14 -14
  252. data/spec/rubocop/cop/style/alias_spec.rb +11 -11
  253. data/spec/rubocop/cop/style/align_array_spec.rb +23 -7
  254. data/spec/rubocop/cop/style/align_hash_spec.rb +111 -30
  255. data/spec/rubocop/cop/style/align_parameters_spec.rb +260 -187
  256. data/spec/rubocop/cop/style/and_or_spec.rb +6 -6
  257. data/spec/rubocop/cop/style/ascii_comments_spec.rb +3 -3
  258. data/spec/rubocop/cop/style/ascii_identifiers_spec.rb +5 -5
  259. data/spec/rubocop/cop/style/attr_spec.rb +2 -2
  260. data/spec/rubocop/cop/style/begin_block_spec.rb +2 -2
  261. data/spec/rubocop/cop/style/block_comments_spec.rb +3 -3
  262. data/spec/rubocop/cop/style/block_nesting_spec.rb +26 -26
  263. data/spec/rubocop/cop/style/blocks_spec.rb +8 -8
  264. data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +8 -8
  265. data/spec/rubocop/cop/style/case_equality_spec.rb +2 -2
  266. data/spec/rubocop/cop/style/case_indentation_spec.rb +21 -21
  267. data/spec/rubocop/cop/style/character_literal_spec.rb +6 -6
  268. data/spec/rubocop/cop/style/class_and_module_camel_case_spec.rb +4 -4
  269. data/spec/rubocop/cop/style/class_and_module_children_spec.rb +129 -0
  270. data/spec/rubocop/cop/style/class_length_spec.rb +9 -9
  271. data/spec/rubocop/cop/style/class_methods_spec.rb +8 -8
  272. data/spec/rubocop/cop/style/class_vars_spec.rb +4 -4
  273. data/spec/rubocop/cop/style/collection_methods_spec.rb +6 -6
  274. data/spec/rubocop/cop/style/colon_method_call_spec.rb +16 -16
  275. data/spec/rubocop/cop/style/comment_annotation_spec.rb +16 -16
  276. data/spec/rubocop/cop/style/constant_name_spec.rb +12 -12
  277. data/spec/rubocop/cop/style/cyclomatic_complexity_spec.rb +16 -16
  278. data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +6 -6
  279. data/spec/rubocop/cop/style/documentation_spec.rb +14 -14
  280. data/spec/rubocop/cop/style/dot_position_spec.rb +23 -26
  281. data/spec/rubocop/cop/style/double_negation_spec.rb +22 -0
  282. data/spec/rubocop/cop/style/empty_line_between_defs_spec.rb +22 -14
  283. data/spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb +4 -4
  284. data/spec/rubocop/cop/style/empty_lines_around_body_spec.rb +20 -20
  285. data/spec/rubocop/cop/style/empty_lines_spec.rb +17 -6
  286. data/spec/rubocop/cop/style/empty_literal_spec.rb +20 -20
  287. data/spec/rubocop/cop/style/encoding_spec.rb +5 -5
  288. data/spec/rubocop/cop/style/end_block_spec.rb +2 -2
  289. data/spec/rubocop/cop/style/end_of_line_spec.rb +4 -4
  290. data/spec/rubocop/cop/style/even_odd_spec.rb +18 -18
  291. data/spec/rubocop/cop/style/favor_join_spec.rb +7 -7
  292. data/spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb +7 -7
  293. data/spec/rubocop/cop/style/favor_until_over_negated_while_spec.rb +3 -3
  294. data/spec/rubocop/cop/style/file_name_spec.rb +71 -0
  295. data/spec/rubocop/cop/style/final_newline_spec.rb +4 -4
  296. data/spec/rubocop/cop/style/flip_flop_spec.rb +4 -4
  297. data/spec/rubocop/cop/style/for_spec.rb +13 -13
  298. data/spec/rubocop/cop/style/format_string_spec.rb +136 -0
  299. data/spec/rubocop/cop/style/global_vars_spec.rb +7 -7
  300. data/spec/rubocop/cop/style/hash_methods_spec.rb +6 -6
  301. data/spec/rubocop/cop/style/hash_syntax_spec.rb +11 -11
  302. data/spec/rubocop/cop/style/if_unless_modifier_spec.rb +29 -11
  303. data/spec/rubocop/cop/style/if_with_semicolon_spec.rb +1 -1
  304. data/spec/rubocop/cop/style/indent_array_spec.rb +136 -0
  305. data/spec/rubocop/cop/style/indent_hash_spec.rb +238 -0
  306. data/spec/rubocop/cop/style/indentation_consistency_spec.rb +69 -49
  307. data/spec/rubocop/cop/style/indentation_width_spec.rb +264 -128
  308. data/spec/rubocop/cop/style/lambda_call_spec.rb +14 -14
  309. data/spec/rubocop/cop/style/lambda_spec.rb +7 -7
  310. data/spec/rubocop/cop/style/leading_comment_space_spec.rb +15 -15
  311. data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +11 -4
  312. data/spec/rubocop/cop/style/line_length_spec.rb +5 -5
  313. data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +5 -5
  314. data/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb +9 -9
  315. data/spec/rubocop/cop/style/method_def_parentheses_spec.rb +19 -19
  316. data/spec/rubocop/cop/style/method_length_spec.rb +17 -17
  317. data/spec/rubocop/cop/style/method_name_spec.rb +21 -21
  318. data/spec/rubocop/cop/style/module_function_spec.rb +3 -3
  319. data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +13 -13
  320. data/spec/rubocop/cop/style/multiline_if_then_spec.rb +10 -10
  321. data/spec/rubocop/cop/style/multiline_ternary_operator_spec.rb +3 -3
  322. data/spec/rubocop/cop/style/nested_ternary_operator_spec.rb +3 -3
  323. data/spec/rubocop/cop/style/nil_comparison_spec.rb +7 -7
  324. data/spec/rubocop/cop/style/not_spec.rb +6 -11
  325. data/spec/rubocop/cop/style/numeric_literals_spec.rb +8 -8
  326. data/spec/rubocop/cop/style/one_line_conditional_spec.rb +1 -1
  327. data/spec/rubocop/cop/style/op_method_spec.rb +13 -13
  328. data/spec/rubocop/cop/style/parameter_lists_spec.rb +6 -6
  329. data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +11 -10
  330. data/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb +250 -0
  331. data/spec/rubocop/cop/style/perl_backrefs_spec.rb +2 -2
  332. data/spec/rubocop/cop/style/predicate_name_spec.rb +3 -3
  333. data/spec/rubocop/cop/style/proc_spec.rb +4 -4
  334. data/spec/rubocop/cop/style/raise_args_spec.rb +20 -20
  335. data/spec/rubocop/cop/style/redundant_begin_spec.rb +6 -6
  336. data/spec/rubocop/cop/style/redundant_exception_spec.rb +6 -6
  337. data/spec/rubocop/cop/style/redundant_return_spec.rb +22 -22
  338. data/spec/rubocop/cop/style/redundant_self_spec.rb +14 -14
  339. data/spec/rubocop/cop/style/regexp_literal_spec.rb +88 -67
  340. data/spec/rubocop/cop/style/rescue_modifier_spec.rb +17 -17
  341. data/spec/rubocop/cop/style/self_assignment_spec.rb +43 -0
  342. data/spec/rubocop/cop/style/semicolon_spec.rb +31 -17
  343. data/spec/rubocop/cop/style/signal_exception_spec.rb +29 -29
  344. data/spec/rubocop/cop/style/single_line_block_params_spec.rb +6 -6
  345. data/spec/rubocop/cop/style/single_line_methods_spec.rb +44 -6
  346. data/spec/rubocop/cop/style/space_after_colon_spec.rb +1 -1
  347. data/spec/rubocop/cop/style/space_after_comma_spec.rb +3 -3
  348. data/spec/rubocop/cop/style/space_after_control_keyword_spec.rb +12 -12
  349. data/spec/rubocop/cop/style/space_after_method_name_spec.rb +8 -8
  350. data/spec/rubocop/cop/style/space_after_not_spec.rb +3 -3
  351. data/spec/rubocop/cop/style/space_after_semicolon_spec.rb +1 -1
  352. data/spec/rubocop/cop/style/space_around_equals_in_parameter_default_spec.rb +63 -21
  353. data/spec/rubocop/cop/style/space_around_operators_spec.rb +24 -24
  354. data/spec/rubocop/cop/style/space_before_block_braces_spec.rb +72 -0
  355. data/spec/rubocop/cop/style/space_before_modifier_keyword_spec.rb +4 -4
  356. data/spec/rubocop/cop/style/{space_around_block_braces_spec.rb → space_inside_block_braces_spec.rb} +39 -41
  357. data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +1 -1
  358. data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +15 -15
  359. data/spec/rubocop/cop/style/space_inside_parens_spec.rb +1 -1
  360. data/spec/rubocop/cop/style/special_global_vars_spec.rb +10 -10
  361. data/spec/rubocop/cop/style/string_literals_spec.rb +31 -31
  362. data/spec/rubocop/cop/style/symbol_array_spec.rb +9 -9
  363. data/spec/rubocop/cop/style/tab_spec.rb +3 -3
  364. data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +3 -3
  365. data/spec/rubocop/cop/style/trailing_comma_spec.rb +32 -32
  366. data/spec/rubocop/cop/style/trailing_whitespace_spec.rb +5 -5
  367. data/spec/rubocop/cop/style/trivial_accessors_spec.rb +39 -39
  368. data/spec/rubocop/cop/style/unless_else_spec.rb +1 -1
  369. data/spec/rubocop/cop/style/variable_interpolation_spec.rb +12 -12
  370. data/spec/rubocop/cop/style/variable_name_spec.rb +21 -21
  371. data/spec/rubocop/cop/style/when_then_spec.rb +1 -1
  372. data/spec/rubocop/cop/style/while_until_do_spec.rb +8 -8
  373. data/spec/rubocop/cop/style/while_until_modifier_spec.rb +25 -7
  374. data/spec/rubocop/cop/style/word_array_spec.rb +23 -23
  375. data/spec/rubocop/cop/team_spec.rb +14 -14
  376. data/spec/rubocop/file_inspector_spec.rb +14 -12
  377. data/spec/rubocop/formatter/base_formatter_spec.rb +19 -19
  378. data/spec/rubocop/formatter/clang_style_formatter_spec.rb +14 -14
  379. data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +7 -7
  380. data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +7 -7
  381. data/spec/rubocop/formatter/file_list_formatter_spec.rb +4 -4
  382. data/spec/rubocop/formatter/fuubar_style_formatter_spec.rb +129 -0
  383. data/spec/rubocop/formatter/json_formatter_spec.rb +23 -19
  384. data/spec/rubocop/formatter/offense_count_formatter_spec.rb +77 -0
  385. data/spec/rubocop/formatter/progress_formatter_spec.rb +27 -27
  386. data/spec/rubocop/formatter/simple_text_formatter_spec.rb +16 -16
  387. data/spec/rubocop/options_spec.rb +7 -8
  388. data/spec/rubocop/source_parser_spec.rb +0 -54
  389. data/spec/spec_helper.rb +11 -7
  390. data/spec/support/file_helper.rb +1 -1
  391. data/spec/support/mri_syntax_checker.rb +4 -4
  392. data/spec/support/shared_examples.rb +6 -6
  393. data/spec/support/statement_modifier_helper.rb +3 -3
  394. metadata +76 -16
  395. data/lib/rubocop/cop/style/favor_sprintf.rb +0 -26
  396. data/lib/rubocop/formatter/offence_count_formatter.rb +0 -49
  397. data/spec/rubocop/cop/style/favor_sprintf_spec.rb +0 -47
  398. data/spec/rubocop/formatter/offence_count_formatter_spec.rb +0 -52
@@ -18,12 +18,12 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
18
18
  ]
19
19
  end
20
20
 
21
- it 'registers an offence' do
21
+ it 'registers an offense' do
22
22
  inspect_source(cop, source)
23
- expect(cop.offences.size).to eq(1)
24
- expect(cop.offences.first.message)
23
+ expect(cop.offenses.size).to eq(1)
24
+ expect(cop.offenses.first.message)
25
25
  .to include('Shadowing outer local variable - foo')
26
- expect(cop.offences.first.line).to eq(4)
26
+ expect(cop.offenses.first.line).to eq(4)
27
27
  end
28
28
 
29
29
  include_examples 'mimics MRI 2.1'
@@ -42,12 +42,12 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
42
42
  ]
43
43
  end
44
44
 
45
- it 'registers an offence' do
45
+ it 'registers an offense' do
46
46
  inspect_source(cop, source)
47
- expect(cop.offences.size).to eq(1)
48
- expect(cop.offences.first.message)
47
+ expect(cop.offenses.size).to eq(1)
48
+ expect(cop.offenses.first.message)
49
49
  .to include('Shadowing outer local variable - foo')
50
- expect(cop.offences.first.line).to eq(4)
50
+ expect(cop.offenses.first.line).to eq(4)
51
51
  end
52
52
 
53
53
  include_examples 'mimics MRI 2.1'
@@ -68,12 +68,12 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
68
68
  ]
69
69
  end
70
70
 
71
- it 'registers an offence' do
71
+ it 'registers an offense' do
72
72
  inspect_source(cop, source)
73
- expect(cop.offences.size).to eq(1)
74
- expect(cop.offences.first.message)
73
+ expect(cop.offenses.size).to eq(1)
74
+ expect(cop.offenses.first.message)
75
75
  .to include('Shadowing outer local variable - foo')
76
- expect(cop.offences.first.line).to eq(4)
76
+ expect(cop.offenses.first.line).to eq(4)
77
77
  end
78
78
 
79
79
  include_examples 'mimics MRI 2.1'
@@ -93,12 +93,12 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
93
93
  ]
94
94
  end
95
95
 
96
- it 'registers an offence' do
96
+ it 'registers an offense' do
97
97
  inspect_source(cop, source)
98
- expect(cop.offences.size).to eq(1)
99
- expect(cop.offences.first.message)
98
+ expect(cop.offenses.size).to eq(1)
99
+ expect(cop.offenses.first.message)
100
100
  .to include('Shadowing outer local variable - foo')
101
- expect(cop.offences.first.line).to eq(4)
101
+ expect(cop.offenses.first.line).to eq(4)
102
102
  end
103
103
 
104
104
  include_examples 'mimics MRI 2.1', 'shadowing'
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Rubocop::Cop::Lint::StringConversionInInterpolation do
6
+ subject(:cop) { described_class.new }
7
+
8
+ it 'registers an offense for #to_s in interpolation' do
9
+ inspect_source(cop, '"this is the #{result.to_s}"')
10
+ expect(cop.offenses.size).to eq(1)
11
+ end
12
+
13
+ it 'detects #to_s in an interpolation with several expressions' do
14
+ inspect_source(cop, '"this is the #{top; result.to_s}"')
15
+ expect(cop.offenses.size).to eq(1)
16
+ end
17
+
18
+ it 'accepts #to_s with arguments in an interpolation' do
19
+ inspect_source(cop, '"this is a #{result.to_s(8)}"')
20
+ expect(cop.offenses).to be_empty
21
+ end
22
+
23
+ it 'accepts interpolation without #to_s' do
24
+ inspect_source(cop, '"this is the #{result}"')
25
+ expect(cop.offenses).to be_empty
26
+ end
27
+ end
@@ -3,32 +3,32 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Rubocop::Cop::Lint::Syntax do
6
- describe '.offence_from_diagnostic' do
7
- subject(:offence) { described_class.offence_from_diagnostic(diagnostic) }
6
+ describe '.offense_from_diagnostic' do
7
+ subject(:offense) { described_class.offense_from_diagnostic(diagnostic) }
8
8
  let(:diagnostic) { Parser::Diagnostic.new(level, reason, args, location) }
9
9
  let(:level) { :warning }
10
10
  let(:reason) { :odd_hash }
11
11
  let(:args) { [] }
12
12
  let(:location) { double('location').as_null_object }
13
13
 
14
- it 'returns an offence' do
15
- expect(offence).to be_a(Rubocop::Cop::Offence)
14
+ it 'returns an offense' do
15
+ expect(offense).to be_a(Rubocop::Cop::Offense)
16
16
  end
17
17
 
18
- it "sets diagnostic's level to offence's severity" do
19
- expect(offence.severity).to eq(level)
18
+ it "sets diagnostic's level to offense's severity" do
19
+ expect(offense.severity).to eq(level)
20
20
  end
21
21
 
22
- it "sets diagnostic's message to offence's message" do
23
- expect(offence.message).to eq('odd number of entries for a hash')
22
+ it "sets diagnostic's message to offense's message" do
23
+ expect(offense.message).to eq('odd number of entries for a hash')
24
24
  end
25
25
 
26
- it "sets diagnostic's location to offence's location" do
27
- expect(offence.location).to eq(location)
26
+ it "sets diagnostic's location to offense's location" do
27
+ expect(offense.location).to eq(location)
28
28
  end
29
29
 
30
30
  it 'sets Syntax as a cop name' do
31
- expect(offence.cop_name).to eq('Syntax')
31
+ expect(offense.cop_name).to eq('Syntax')
32
32
  end
33
33
  end
34
34
  end
@@ -6,13 +6,13 @@ describe Rubocop::Cop::Lint::UnreachableCode do
6
6
  subject(:cop) { described_class.new }
7
7
 
8
8
  described_class::NODE_TYPES.each do |t|
9
- it "registers an offence for #{t} before other statements" do
9
+ it "registers an offense for #{t} before other statements" do
10
10
  inspect_source(cop,
11
11
  ['foo = 5',
12
12
  "#{t}",
13
13
  'bar'
14
14
  ])
15
- expect(cop.offences.size).to eq(1)
15
+ expect(cop.offenses.size).to eq(1)
16
16
  end
17
17
 
18
18
  it "accepts code with conditional #{t}" do
@@ -21,7 +21,7 @@ describe Rubocop::Cop::Lint::UnreachableCode do
21
21
  "#{t} if test",
22
22
  'bar'
23
23
  ])
24
- expect(cop.offences).to be_empty
24
+ expect(cop.offenses).to be_empty
25
25
  end
26
26
 
27
27
  it "accepts #{t} as the final expression" do
@@ -29,18 +29,18 @@ describe Rubocop::Cop::Lint::UnreachableCode do
29
29
  ['foo = 5',
30
30
  "#{t} if test"
31
31
  ])
32
- expect(cop.offences).to be_empty
32
+ expect(cop.offenses).to be_empty
33
33
  end
34
34
  end
35
35
 
36
36
  described_class::FLOW_COMMANDS.each do |t|
37
- it "registers an offence for #{t} before other statements" do
37
+ it "registers an offense for #{t} before other statements" do
38
38
  inspect_source(cop,
39
39
  ['foo = 5',
40
40
  "#{t} something",
41
41
  'bar'
42
42
  ])
43
- expect(cop.offences.size).to eq(1)
43
+ expect(cop.offenses.size).to eq(1)
44
44
  end
45
45
 
46
46
  it "accepts code with conditional #{t}" do
@@ -49,7 +49,7 @@ describe Rubocop::Cop::Lint::UnreachableCode do
49
49
  "#{t} something if test",
50
50
  'bar'
51
51
  ])
52
- expect(cop.offences).to be_empty
52
+ expect(cop.offenses).to be_empty
53
53
  end
54
54
 
55
55
  it "accepts #{t} as the final expression" do
@@ -57,7 +57,7 @@ describe Rubocop::Cop::Lint::UnreachableCode do
57
57
  ['foo = 5',
58
58
  "#{t} something if test"
59
59
  ])
60
- expect(cop.offences).to be_empty
60
+ expect(cop.offenses).to be_empty
61
61
  end
62
62
  end
63
63
  end
@@ -20,12 +20,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
20
20
  ]
21
21
  end
22
22
 
23
- it 'registers an offence' do
23
+ it 'registers an offense' do
24
24
  inspect_source(cop, source)
25
- expect(cop.offences.size).to eq(1)
26
- expect(cop.offences.first.message)
25
+ expect(cop.offenses.size).to eq(1)
26
+ expect(cop.offenses.first.message)
27
27
  .to eq('Useless assignment to variable - foo')
28
- expect(cop.offences.first.line).to eq(5)
28
+ expect(cop.offenses.first.line).to eq(5)
29
29
  expect(cop.highlights).to eq(['foo'])
30
30
  end
31
31
 
@@ -48,12 +48,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
48
48
  ]
49
49
  end
50
50
 
51
- it 'registers an offence' do
51
+ it 'registers an offense' do
52
52
  inspect_source(cop, source)
53
- expect(cop.offences.size).to eq(1)
54
- expect(cop.offences.first.message)
53
+ expect(cop.offenses.size).to eq(1)
54
+ expect(cop.offenses.first.message)
55
55
  .to eq('Useless assignment to variable - foo')
56
- expect(cop.offences.first.line).to eq(5)
56
+ expect(cop.offenses.first.line).to eq(5)
57
57
  expect(cop.highlights).to eq(['foo'])
58
58
  end
59
59
 
@@ -77,12 +77,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
77
77
  ]
78
78
  end
79
79
 
80
- it 'registers an offence' do
80
+ it 'registers an offense' do
81
81
  inspect_source(cop, source)
82
- expect(cop.offences.size).to eq(1)
83
- expect(cop.offences.first.message)
82
+ expect(cop.offenses.size).to eq(1)
83
+ expect(cop.offenses.first.message)
84
84
  .to eq('Useless assignment to variable - foo')
85
- expect(cop.offences.first.line).to eq(6)
85
+ expect(cop.offenses.first.line).to eq(6)
86
86
  expect(cop.highlights).to eq(['foo'])
87
87
  end
88
88
 
@@ -104,12 +104,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
104
104
  ]
105
105
  end
106
106
 
107
- it 'registers an offence' do
107
+ it 'registers an offense' do
108
108
  inspect_source(cop, source)
109
- expect(cop.offences.size).to eq(1)
110
- expect(cop.offences.first.message)
109
+ expect(cop.offenses.size).to eq(1)
110
+ expect(cop.offenses.first.message)
111
111
  .to eq('Useless assignment to variable - foo')
112
- expect(cop.offences.first.line).to eq(5)
112
+ expect(cop.offenses.first.line).to eq(5)
113
113
  expect(cop.highlights).to eq(['foo'])
114
114
  end
115
115
 
@@ -133,12 +133,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
133
133
  ]
134
134
  end
135
135
 
136
- it 'registers an offence' do
136
+ it 'registers an offense' do
137
137
  inspect_source(cop, source)
138
- expect(cop.offences.size).to eq(1)
139
- expect(cop.offences.first.message)
138
+ expect(cop.offenses.size).to eq(1)
139
+ expect(cop.offenses.first.message)
140
140
  .to eq('Useless assignment to variable - foo')
141
- expect(cop.offences.first.line).to eq(6)
141
+ expect(cop.offenses.first.line).to eq(6)
142
142
  expect(cop.highlights).to eq(['foo'])
143
143
  end
144
144
 
@@ -162,12 +162,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
162
162
  ]
163
163
  end
164
164
 
165
- it 'registers an offence' do
165
+ it 'registers an offense' do
166
166
  inspect_source(cop, source)
167
- expect(cop.offences.size).to eq(1)
168
- expect(cop.offences.first.message)
167
+ expect(cop.offenses.size).to eq(1)
168
+ expect(cop.offenses.first.message)
169
169
  .to eq('Useless assignment to variable - foo')
170
- expect(cop.offences.first.line).to eq(6)
170
+ expect(cop.offenses.first.line).to eq(6)
171
171
  expect(cop.highlights).to eq(['foo'])
172
172
  end
173
173
 
@@ -189,12 +189,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
189
189
  ]
190
190
  end
191
191
 
192
- it 'registers an offence' do
192
+ it 'registers an offense' do
193
193
  inspect_source(cop, source)
194
- expect(cop.offences.size).to eq(1)
195
- expect(cop.offences.first.message)
194
+ expect(cop.offenses.size).to eq(1)
195
+ expect(cop.offenses.first.message)
196
196
  .to eq('Useless assignment to variable - foo')
197
- expect(cop.offences.first.line).to eq(5)
197
+ expect(cop.offenses.first.line).to eq(5)
198
198
  expect(cop.highlights).to eq(['foo'])
199
199
  end
200
200
 
@@ -210,12 +210,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
210
210
  ]
211
211
  end
212
212
 
213
- it 'registers an offence' do
213
+ it 'registers an offense' do
214
214
  inspect_source(cop, source)
215
- expect(cop.offences.size).to eq(1)
216
- expect(cop.offences.first.message)
215
+ expect(cop.offenses.size).to eq(1)
216
+ expect(cop.offenses.first.message)
217
217
  .to eq('Useless assignment to variable - foo')
218
- expect(cop.offences.first.line).to eq(1)
218
+ expect(cop.offenses.first.line).to eq(1)
219
219
  expect(cop.highlights).to eq(['foo'])
220
220
  end
221
221
 
@@ -230,12 +230,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
230
230
  ]
231
231
  end
232
232
 
233
- it 'registers an offence' do
233
+ it 'registers an offense' do
234
234
  inspect_source(cop, source)
235
- expect(cop.offences.size).to eq(1)
236
- expect(cop.offences.first.message)
235
+ expect(cop.offenses.size).to eq(1)
236
+ expect(cop.offenses.first.message)
237
237
  .to eq('Useless assignment to variable - foo. Use just operator ||.')
238
- expect(cop.offences.first.line).to eq(1)
238
+ expect(cop.offenses.first.line).to eq(1)
239
239
  expect(cop.highlights).to eq(['foo'])
240
240
  end
241
241
  end
@@ -253,17 +253,17 @@ describe Rubocop::Cop::Lint::UselessAssignment do
253
253
  ]
254
254
  end
255
255
 
256
- it 'registers offences for each asignment' do
256
+ it 'registers offenses for each asignment' do
257
257
  inspect_source(cop, source)
258
- expect(cop.offences.size).to eq(2)
258
+ expect(cop.offenses.size).to eq(2)
259
259
 
260
- expect(cop.offences[0].message)
260
+ expect(cop.offenses[0].message)
261
261
  .to eq('Useless assignment to variable - foo')
262
- expect(cop.offences[0].line).to eq(2)
262
+ expect(cop.offenses[0].line).to eq(2)
263
263
 
264
- expect(cop.offences[1].message)
264
+ expect(cop.offenses[1].message)
265
265
  .to eq('Useless assignment to variable - foo')
266
- expect(cop.offences[1].line).to eq(4)
266
+ expect(cop.offenses[1].line).to eq(4)
267
267
 
268
268
  expect(cop.highlights).to eq(%w(foo foo))
269
269
  end
@@ -281,12 +281,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
281
281
  ]
282
282
  end
283
283
 
284
- it 'registers an offence for the non-re-referenced assignment' do
284
+ it 'registers an offense for the non-re-referenced assignment' do
285
285
  inspect_source(cop, source)
286
- expect(cop.offences.size).to eq(1)
287
- expect(cop.offences.first.message)
286
+ expect(cop.offenses.size).to eq(1)
287
+ expect(cop.offenses.first.message)
288
288
  .to eq('Useless assignment to variable - foo')
289
- expect(cop.offences.first.line).to eq(4)
289
+ expect(cop.offenses.first.line).to eq(4)
290
290
  expect(cop.highlights).to eq(['foo'])
291
291
  end
292
292
  end
@@ -303,12 +303,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
303
303
  ]
304
304
  end
305
305
 
306
- it 'registers an offence for the unreferenced assignment' do
306
+ it 'registers an offense for the unreferenced assignment' do
307
307
  inspect_source(cop, source)
308
- expect(cop.offences.size).to eq(1)
309
- expect(cop.offences.first.message)
308
+ expect(cop.offenses.size).to eq(1)
309
+ expect(cop.offenses.first.message)
310
310
  .to eq('Useless assignment to variable - foo')
311
- expect(cop.offences.first.line).to eq(2)
311
+ expect(cop.offenses.first.line).to eq(2)
312
312
  expect(cop.highlights).to eq(['foo'])
313
313
  end
314
314
  end
@@ -362,12 +362,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
362
362
  ]
363
363
  end
364
364
 
365
- it 'registers an offence for the declaration' do
365
+ it 'registers an offense for the declaration' do
366
366
  inspect_source(cop, source)
367
- expect(cop.offences.size).to eq(1)
368
- expect(cop.offences.first.message)
367
+ expect(cop.offenses.size).to eq(1)
368
+ expect(cop.offenses.first.message)
369
369
  .to eq('Useless assignment to variable - foo')
370
- expect(cop.offences.first.line).to eq(1)
370
+ expect(cop.offenses.first.line).to eq(1)
371
371
  expect(cop.highlights).to eq(['foo'])
372
372
  end
373
373
 
@@ -383,12 +383,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
383
383
  ]
384
384
  end
385
385
 
386
- it 'registers offences for the assignment' do
386
+ it 'registers offenses for the assignment' do
387
387
  inspect_source(cop, source)
388
- expect(cop.offences.size).to eq(1)
389
- expect(cop.offences.first.message)
388
+ expect(cop.offenses.size).to eq(1)
389
+ expect(cop.offenses.first.message)
390
390
  .to eq('Useless assignment to variable - foo')
391
- expect(cop.offences.first.line).to eq(2)
391
+ expect(cop.offenses.first.line).to eq(2)
392
392
  expect(cop.highlights).to eq(['foo'])
393
393
  end
394
394
  end
@@ -404,12 +404,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
404
404
  ]
405
405
  end
406
406
 
407
- it 'registers an offence' do
407
+ it 'registers an offense' do
408
408
  inspect_source(cop, source)
409
- expect(cop.offences.size).to eq(1)
410
- expect(cop.offences.first.message)
409
+ expect(cop.offenses.size).to eq(1)
410
+ expect(cop.offenses.first.message)
411
411
  .to eq('Useless assignment to variable - foo')
412
- expect(cop.offences.first.line).to eq(3)
412
+ expect(cop.offenses.first.line).to eq(3)
413
413
  expect(cop.highlights).to eq(['foo'])
414
414
  end
415
415
 
@@ -460,6 +460,23 @@ describe Rubocop::Cop::Lint::UselessAssignment do
460
460
  include_examples 'mimics MRI 2.1'
461
461
  end
462
462
 
463
+ context 'when a setter is invoked with operator assignment in loop body' do
464
+ let(:source) do
465
+ [
466
+ 'def some_method',
467
+ ' obj = {}',
468
+ '',
469
+ ' while obj[:count] < 100',
470
+ ' obj[:count] += 1',
471
+ ' end',
472
+ 'end'
473
+ ]
474
+ end
475
+
476
+ include_examples 'accepts'
477
+ include_examples 'mimics MRI 2.1'
478
+ end
479
+
463
480
  context "when a variable is reassigned in loop body but won't " \
464
481
  'be referenced either next iteration or loop condition' do
465
482
  let(:source) do
@@ -478,12 +495,14 @@ describe Rubocop::Cop::Lint::UselessAssignment do
478
495
  ]
479
496
  end
480
497
 
481
- it 'registers an offence' do
498
+ it 'registers an offense' do
499
+ pending 'Requires an advanced logic that checks whether the return ' \
500
+ 'value of an operator assignment is used or not.'
482
501
  inspect_source(cop, source)
483
- expect(cop.offences.size).to eq(1)
484
- expect(cop.offences.first.message)
502
+ expect(cop.offenses.size).to eq(1)
503
+ expect(cop.offenses.first.message)
485
504
  .to eq('Useless assignment to variable - foo')
486
- expect(cop.offences.first.line).to eq(7)
505
+ expect(cop.offenses.first.line).to eq(7)
487
506
  expect(cop.highlights).to eq(['foo'])
488
507
  end
489
508
  end
@@ -502,12 +521,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
502
521
  ]
503
522
  end
504
523
 
505
- it 'registers an offence' do
524
+ it 'registers an offense' do
506
525
  inspect_source(cop, source)
507
- expect(cop.offences.size).to eq(1)
508
- expect(cop.offences.first.message)
526
+ expect(cop.offenses.size).to eq(1)
527
+ expect(cop.offenses.first.message)
509
528
  .to eq('Useless assignment to variable - foo')
510
- expect(cop.offences.first.line).to eq(5)
529
+ expect(cop.offenses.first.line).to eq(5)
511
530
  expect(cop.highlights).to eq(['foo'])
512
531
  end
513
532
  end
@@ -527,12 +546,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
527
546
  ]
528
547
  end
529
548
 
530
- it 'registers an offence' do
549
+ it 'registers an offense' do
531
550
  inspect_source(cop, source)
532
- expect(cop.offences.size).to eq(1)
533
- expect(cop.offences.first.message)
551
+ expect(cop.offenses.size).to eq(1)
552
+ expect(cop.offenses.first.message)
534
553
  .to eq('Useless assignment to variable - foo')
535
- expect(cop.offences.first.line).to eq(6)
554
+ expect(cop.offenses.first.line).to eq(6)
536
555
  expect(cop.highlights).to eq(['foo'])
537
556
  end
538
557
  end
@@ -549,12 +568,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
549
568
  ]
550
569
  end
551
570
 
552
- it 'registers an offence' do
571
+ it 'registers an offense' do
553
572
  inspect_source(cop, source)
554
- expect(cop.offences.size).to eq(1)
555
- expect(cop.offences.first.message)
573
+ expect(cop.offenses.size).to eq(1)
574
+ expect(cop.offenses.first.message)
556
575
  .to eq('Useless assignment to variable - foo')
557
- expect(cop.offences.first.line).to eq(3)
576
+ expect(cop.offenses.first.line).to eq(3)
558
577
  expect(cop.highlights).to eq(['foo'])
559
578
  end
560
579
 
@@ -576,12 +595,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
576
595
  ]
577
596
  end
578
597
 
579
- it 'registers an offence for the unreferenced assignment' do
598
+ it 'registers an offense for the unreferenced assignment' do
580
599
  inspect_source(cop, source)
581
- expect(cop.offences.size).to eq(1)
582
- expect(cop.offences.first.message)
600
+ expect(cop.offenses.size).to eq(1)
601
+ expect(cop.offenses.first.message)
583
602
  .to eq('Useless assignment to variable - foo')
584
- expect(cop.offences.first.line).to eq(3)
603
+ expect(cop.offenses.first.line).to eq(3)
585
604
  expect(cop.highlights).to eq(['foo'])
586
605
  end
587
606
  end
@@ -641,12 +660,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
641
660
  ]
642
661
  end
643
662
 
644
- it 'registers an offence for the unreferenced assignment' do
663
+ it 'registers an offense for the unreferenced assignment' do
645
664
  inspect_source(cop, source)
646
- expect(cop.offences.size).to eq(1)
647
- expect(cop.offences.first.message)
665
+ expect(cop.offenses.size).to eq(1)
666
+ expect(cop.offenses.first.message)
648
667
  .to eq('Useless assignment to variable - foo')
649
- expect(cop.offences.first.line).to eq(2)
668
+ expect(cop.offenses.first.line).to eq(2)
650
669
  expect(cop.highlights).to eq(['foo'])
651
670
  end
652
671
  end
@@ -666,18 +685,18 @@ describe Rubocop::Cop::Lint::UselessAssignment do
666
685
  ]
667
686
  end
668
687
 
669
- it 'registers an offence for the assignment in the if branch' do
688
+ it 'registers an offense for the assignment in the if branch' do
670
689
  inspect_source(cop, source)
671
- expect(cop.offences.size).to eq(1)
672
- expect(cop.offences.first.message)
690
+ expect(cop.offenses.size).to eq(1)
691
+ expect(cop.offenses.first.message)
673
692
  .to eq('Useless assignment to variable - foo')
674
- expect(cop.offences.first.line).to eq(3)
693
+ expect(cop.offenses.first.line).to eq(3)
675
694
  expect(cop.highlights).to eq(['foo'])
676
695
  end
677
696
  end
678
697
 
679
698
  context 'when a variable is assigned in branch of modifier if ' \
680
- 'that references the variable in its conditional clause' +
699
+ 'that references the variable in its conditional clause' \
681
700
  'and referenced after the branching' do
682
701
  let(:source) do
683
702
  [
@@ -693,7 +712,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
693
712
  end
694
713
 
695
714
  context 'when a variable is assigned in branch of modifier if ' \
696
- 'that references the variable in its conditional clause' +
715
+ 'that references the variable in its conditional clause' \
697
716
  'and unreferenced' do
698
717
  let(:source) do
699
718
  [
@@ -703,12 +722,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
703
722
  ]
704
723
  end
705
724
 
706
- it 'registers an offence' do
725
+ it 'registers an offense' do
707
726
  inspect_source(cop, source)
708
- expect(cop.offences.size).to eq(1)
709
- expect(cop.offences.first.message)
727
+ expect(cop.offenses.size).to eq(1)
728
+ expect(cop.offenses.first.message)
710
729
  .to eq('Useless assignment to variable - foo')
711
- expect(cop.offences.first.line).to eq(2)
730
+ expect(cop.offenses.first.line).to eq(2)
712
731
  expect(cop.highlights).to eq(['foo'])
713
732
  end
714
733
  end
@@ -740,12 +759,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
740
759
  ]
741
760
  end
742
761
 
743
- it 'registers an offence for the unreferenced assignment' do
762
+ it 'registers an offense for the unreferenced assignment' do
744
763
  inspect_source(cop, source)
745
- expect(cop.offences.size).to eq(1)
746
- expect(cop.offences.first.message)
764
+ expect(cop.offenses.size).to eq(1)
765
+ expect(cop.offenses.first.message)
747
766
  .to eq('Useless assignment to variable - foo')
748
- expect(cop.offences.first.line).to eq(2)
767
+ expect(cop.offenses.first.line).to eq(2)
749
768
  expect(cop.highlights).to eq(['foo'])
750
769
  end
751
770
  end
@@ -815,7 +834,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
815
834
  end
816
835
 
817
836
  context 'when a variable is reassigned with binary operator ' \
818
- 'assignment while assigning to itself in rhs ' +
837
+ 'assignment while assigning to itself in rhs ' \
819
838
  'then referenced' do
820
839
  let(:source) do
821
840
  [
@@ -827,12 +846,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
827
846
  ]
828
847
  end
829
848
 
830
- it 'registers an offence for the assignment in rhs' do
849
+ it 'registers an offense for the assignment in rhs' do
831
850
  inspect_source(cop, source)
832
- expect(cop.offences.size).to eq(1)
833
- expect(cop.offences.first.message)
851
+ expect(cop.offenses.size).to eq(1)
852
+ expect(cop.offenses.first.message)
834
853
  .to eq('Useless assignment to variable - foo')
835
- expect(cop.offences.first.line).to eq(3)
854
+ expect(cop.offenses.first.line).to eq(3)
836
855
  expect(cop.highlights).to eq(['foo'])
837
856
  end
838
857
  end
@@ -862,13 +881,13 @@ describe Rubocop::Cop::Lint::UselessAssignment do
862
881
  ]
863
882
  end
864
883
 
865
- it 'registers an offence' do
884
+ it 'registers an offense' do
866
885
  inspect_source(cop, source)
867
- expect(cop.offences.size).to eq(1)
868
- expect(cop.offences.first.message).to eq(
886
+ expect(cop.offenses.size).to eq(1)
887
+ expect(cop.offenses.first.message).to eq(
869
888
  'Useless assignment to variable - foo. Use just operator ||.'
870
889
  )
871
- expect(cop.offences.first.line).to eq(3)
890
+ expect(cop.offenses.first.line).to eq(3)
872
891
  expect(cop.highlights).to eq(['foo'])
873
892
  end
874
893
  end
@@ -885,12 +904,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
885
904
  ]
886
905
  end
887
906
 
888
- it 'registers an offence' do
907
+ it 'registers an offense' do
889
908
  inspect_source(cop, source)
890
- expect(cop.offences.size).to eq(1)
891
- expect(cop.offences.first.message)
909
+ expect(cop.offenses.size).to eq(1)
910
+ expect(cop.offenses.first.message)
892
911
  .to eq('Useless assignment to variable - foo')
893
- expect(cop.offences.first.line).to eq(3)
912
+ expect(cop.offenses.first.line).to eq(3)
894
913
  expect(cop.highlights).to eq(['foo'])
895
914
  end
896
915
  end
@@ -906,15 +925,15 @@ describe Rubocop::Cop::Lint::UselessAssignment do
906
925
  ]
907
926
  end
908
927
 
909
- it 'registers an offence' do
928
+ it 'registers an offense' do
910
929
  inspect_source(cop, source)
911
- expect(cop.offences.size).to eq(1)
912
- expect(cop.offences.first.message).to eq(
930
+ expect(cop.offenses.size).to eq(1)
931
+ expect(cop.offenses.first.message).to eq(
913
932
  'Useless assignment to variable - bar. ' \
914
- 'Use _ or _bar as a variable name ' +
933
+ 'Use _ or _bar as a variable name ' \
915
934
  "to indicate that it won't be used."
916
935
  )
917
- expect(cop.offences.first.line).to eq(2)
936
+ expect(cop.offenses.first.line).to eq(2)
918
937
  expect(cop.highlights).to eq(['bar'])
919
938
  end
920
939
 
@@ -980,12 +999,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
980
999
  ]
981
1000
  end
982
1001
 
983
- it 'registers an offence' do
1002
+ it 'registers an offense' do
984
1003
  inspect_source(cop, source)
985
- expect(cop.offences.size).to eq(1)
986
- expect(cop.offences.first.message)
1004
+ expect(cop.offenses.size).to eq(1)
1005
+ expect(cop.offenses.first.message)
987
1006
  .to eq('Useless assignment to variable - foo')
988
- expect(cop.offences.first.line).to eq(3)
1007
+ expect(cop.offenses.first.line).to eq(3)
989
1008
  expect(cop.highlights).to eq(['foo'])
990
1009
  end
991
1010
 
@@ -1094,12 +1113,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1094
1113
  ]
1095
1114
  end
1096
1115
 
1097
- it 'registers an offence' do
1116
+ it 'registers an offense' do
1098
1117
  inspect_source(cop, source)
1099
- expect(cop.offences.size).to eq(1)
1100
- expect(cop.offences.first.message)
1118
+ expect(cop.offenses.size).to eq(1)
1119
+ expect(cop.offenses.first.message)
1101
1120
  .to eq('Useless assignment to variable - foo')
1102
- expect(cop.offences.first.line).to eq(6)
1121
+ expect(cop.offenses.first.line).to eq(6)
1103
1122
  expect(cop.highlights).to eq(['foo'])
1104
1123
  end
1105
1124
  end
@@ -1123,12 +1142,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1123
1142
  ]
1124
1143
  end
1125
1144
 
1126
- it 'registers an offence' do
1145
+ it 'registers an offense' do
1127
1146
  inspect_source(cop, source)
1128
- expect(cop.offences.size).to eq(1)
1129
- expect(cop.offences.first.message)
1147
+ expect(cop.offenses.size).to eq(1)
1148
+ expect(cop.offenses.first.message)
1130
1149
  .to eq('Useless assignment to variable - foo')
1131
- expect(cop.offences.first.line).to eq(6)
1150
+ expect(cop.offenses.first.line).to eq(6)
1132
1151
  expect(cop.highlights).to eq(['foo'])
1133
1152
  end
1134
1153
  end
@@ -1150,12 +1169,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1150
1169
  ]
1151
1170
  end
1152
1171
 
1153
- it 'registers an offence' do
1172
+ it 'registers an offense' do
1154
1173
  inspect_source(cop, source)
1155
- expect(cop.offences.size).to eq(1)
1156
- expect(cop.offences.first.message)
1174
+ expect(cop.offenses.size).to eq(1)
1175
+ expect(cop.offenses.first.message)
1157
1176
  .to eq('Useless assignment to variable - foo')
1158
- expect(cop.offences.first.line).to eq(6)
1177
+ expect(cop.offenses.first.line).to eq(6)
1159
1178
  expect(cop.highlights).to eq(['foo'])
1160
1179
  end
1161
1180
  end
@@ -1180,8 +1199,27 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1180
1199
  include_examples 'mimics MRI 2.1'
1181
1200
  end
1182
1201
 
1202
+ context 'when a variable is assigned with operator assignment ' \
1203
+ 'in rescue and would be referenced with retry' do
1204
+ let(:source) do
1205
+ [
1206
+ 'retry_count = 0',
1207
+ '',
1208
+ 'begin',
1209
+ ' do_something',
1210
+ 'rescue',
1211
+ ' fail if (retry_count += 1) > 3',
1212
+ ' retry',
1213
+ 'end'
1214
+ ]
1215
+ end
1216
+
1217
+ include_examples 'accepts'
1218
+ include_examples 'mimics MRI 2.1'
1219
+ end
1220
+
1183
1221
  context 'when a variable is assigned ' \
1184
- 'in main body of begin, rescue and else ' +
1222
+ 'in main body of begin, rescue and else ' \
1185
1223
  'and reassigned in ensure then referenced after the begin' do
1186
1224
  let(:source) do
1187
1225
  [
@@ -1202,14 +1240,14 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1202
1240
  ]
1203
1241
  end
1204
1242
 
1205
- it 'registers offences for each assignment before ensure' do
1243
+ it 'registers offenses for each assignment before ensure' do
1206
1244
  inspect_source(cop, source)
1207
- expect(cop.offences.size).to eq(4)
1245
+ expect(cop.offenses.size).to eq(4)
1208
1246
 
1209
- expect(cop.offences[0].line).to eq(3)
1210
- expect(cop.offences[1].line).to eq(5)
1211
- expect(cop.offences[2].line).to eq(7)
1212
- expect(cop.offences[3].line).to eq(9)
1247
+ expect(cop.offenses[0].line).to eq(3)
1248
+ expect(cop.offenses[1].line).to eq(5)
1249
+ expect(cop.offenses[2].line).to eq(7)
1250
+ expect(cop.offenses[3].line).to eq(9)
1213
1251
  end
1214
1252
  end
1215
1253
 
@@ -1239,12 +1277,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1239
1277
  ]
1240
1278
  end
1241
1279
 
1242
- it 'registers an offence' do
1280
+ it 'registers an offense' do
1243
1281
  inspect_source(cop, source)
1244
- expect(cop.offences.size).to eq(1)
1245
- expect(cop.offences.first.message)
1282
+ expect(cop.offenses.size).to eq(1)
1283
+ expect(cop.offenses.first.message)
1246
1284
  .to eq('Useless assignment to variable - foo')
1247
- expect(cop.offences.first.line).to eq(2)
1285
+ expect(cop.offenses.first.line).to eq(2)
1248
1286
  expect(cop.highlights).to eq(['foo'])
1249
1287
  end
1250
1288
 
@@ -1262,12 +1300,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1262
1300
  ]
1263
1301
  end
1264
1302
 
1265
- it 'registers an offence' do
1303
+ it 'registers an offense' do
1266
1304
  inspect_source(cop, source)
1267
- expect(cop.offences.size).to eq(1)
1268
- expect(cop.offences.first.message)
1305
+ expect(cop.offenses.size).to eq(1)
1306
+ expect(cop.offenses.first.message)
1269
1307
  .to eq('Useless assignment to variable - foo')
1270
- expect(cop.offences.first.line).to eq(2)
1308
+ expect(cop.offenses.first.line).to eq(2)
1271
1309
  expect(cop.highlights).to eq(['foo'])
1272
1310
  end
1273
1311
  end
@@ -1279,12 +1317,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1279
1317
  ]
1280
1318
  end
1281
1319
 
1282
- it 'registers an offence' do
1320
+ it 'registers an offense' do
1283
1321
  inspect_source(cop, source)
1284
- expect(cop.offences.size).to eq(1)
1285
- expect(cop.offences.first.message)
1322
+ expect(cop.offenses.size).to eq(1)
1323
+ expect(cop.offenses.first.message)
1286
1324
  .to eq('Useless assignment to variable - foo')
1287
- expect(cop.offences.first.line).to eq(1)
1325
+ expect(cop.offenses.first.line).to eq(1)
1288
1326
  end
1289
1327
 
1290
1328
  include_examples 'mimics MRI 2.1'
@@ -1300,12 +1338,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1300
1338
  ]
1301
1339
  end
1302
1340
 
1303
- it 'registers an offence' do
1341
+ it 'registers an offense' do
1304
1342
  inspect_source(cop, source)
1305
- expect(cop.offences.size).to eq(1)
1306
- expect(cop.offences.first.message)
1343
+ expect(cop.offenses.size).to eq(1)
1344
+ expect(cop.offenses.first.message)
1307
1345
  .to eq('Useless assignment to variable - foo')
1308
- expect(cop.offences.first.line).to eq(2)
1346
+ expect(cop.offenses.first.line).to eq(2)
1309
1347
  expect(cop.highlights).to eq(["/(?<foo>\w+)/"])
1310
1348
  end
1311
1349
 
@@ -1374,12 +1412,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1374
1412
  ]
1375
1413
  end
1376
1414
 
1377
- it 'registers an offence' do
1415
+ it 'registers an offense' do
1378
1416
  inspect_source(cop, source)
1379
- expect(cop.offences.size).to eq(1)
1380
- expect(cop.offences.first.message)
1417
+ expect(cop.offenses.size).to eq(1)
1418
+ expect(cop.offenses.first.message)
1381
1419
  .to eq('Useless assignment to variable - foo')
1382
- expect(cop.offences.first.line).to eq(2)
1420
+ expect(cop.offenses.first.line).to eq(2)
1383
1421
  expect(cop.highlights).to eq(['foo'])
1384
1422
  end
1385
1423
 
@@ -1505,12 +1543,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1505
1543
  ]
1506
1544
  end
1507
1545
 
1508
- it 'registers an offence' do
1546
+ it 'registers an offense' do
1509
1547
  inspect_source(cop, source)
1510
- expect(cop.offences.size).to eq(1)
1511
- expect(cop.offences.first.message)
1548
+ expect(cop.offenses.size).to eq(1)
1549
+ expect(cop.offenses.first.message)
1512
1550
  .to eq('Useless assignment to variable - foo')
1513
- expect(cop.offences.first.line).to eq(1)
1551
+ expect(cop.offenses.first.line).to eq(1)
1514
1552
  expect(cop.highlights).to eq(['foo'])
1515
1553
  end
1516
1554
 
@@ -1541,12 +1579,12 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1541
1579
  ]
1542
1580
  end
1543
1581
 
1544
- it 'registers an offence' do
1582
+ it 'registers an offense' do
1545
1583
  inspect_source(cop, source)
1546
- expect(cop.offences.size).to eq(1)
1547
- expect(cop.offences.first.message)
1584
+ expect(cop.offenses.size).to eq(1)
1585
+ expect(cop.offenses.first.message)
1548
1586
  .to eq('Useless assignment to variable - foo')
1549
- expect(cop.offences.first.line).to eq(1)
1587
+ expect(cop.offenses.first.line).to eq(1)
1550
1588
  expect(cop.highlights).to eq(['foo'])
1551
1589
  end
1552
1590