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
@@ -3,18 +3,25 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Rubocop::Cop::Style::IndentationWidth do
6
- subject(:cop) { described_class.new }
6
+ subject(:cop) { described_class.new(config) }
7
+ let(:config) do
8
+ Rubocop::Config.new('EndAlignment' => end_alignment_config)
9
+ end
10
+ let(:end_alignment_config) do
11
+ { 'Enabled' => true, 'AlignWith' => 'variable' }
12
+ end
7
13
 
8
14
  context 'with if statement' do
9
- it 'registers an offence for bad indentation of an if body' do
15
+ it 'registers an offense for bad indentation of an if body' do
10
16
  inspect_source(cop,
11
17
  ['if cond',
12
18
  ' func',
13
19
  'end'])
14
20
  expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
21
+ expect(cop.highlights).to eq([' '])
15
22
  end
16
23
 
17
- it 'registers an offence for bad indentation of an else body' do
24
+ it 'registers an offense for bad indentation of an else body' do
18
25
  inspect_source(cop,
19
26
  ['if cond',
20
27
  ' func1',
@@ -22,9 +29,10 @@ describe Rubocop::Cop::Style::IndentationWidth do
22
29
  ' func2',
23
30
  'end'])
24
31
  expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
32
+ expect(cop.highlights).to eq([' '])
25
33
  end
26
34
 
27
- it 'registers an offence for bad indentation of an elsif body' do
35
+ it 'registers an offense for bad indentation of an elsif body' do
28
36
  inspect_source(cop,
29
37
  ['if a1',
30
38
  ' b1',
@@ -36,7 +44,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
36
44
  expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
37
45
  end
38
46
 
39
- it 'registers offence for bad indentation of ternary inside else' do
47
+ it 'registers offense for bad indentation of ternary inside else' do
40
48
  inspect_source(cop,
41
49
  ['if a',
42
50
  ' b',
@@ -45,9 +53,10 @@ describe Rubocop::Cop::Style::IndentationWidth do
45
53
  'end'])
46
54
  expect(cop.messages)
47
55
  .to eq(['Use 2 (not 5) spaces for indentation.'])
56
+ expect(cop.highlights).to eq([' '])
48
57
  end
49
58
 
50
- it 'registers offence for bad indentation of modifier if in else' do
59
+ it 'registers offense for bad indentation of modifier if in else' do
51
60
  inspect_source(cop,
52
61
  ['if a',
53
62
  ' b',
@@ -58,10 +67,31 @@ describe Rubocop::Cop::Style::IndentationWidth do
58
67
  .to eq(['Use 2 (not 3) spaces for indentation.'])
59
68
  end
60
69
 
70
+ it 'autocorrects bad indentation' do
71
+ corrected = autocorrect_source(cop,
72
+ ['if a1',
73
+ ' b1',
74
+ ' b1',
75
+ 'elsif a2',
76
+ ' b2',
77
+ 'else',
78
+ ' c',
79
+ 'end'])
80
+ expect(corrected)
81
+ .to eq ['if a1',
82
+ ' b1',
83
+ ' b1', # Will be corrected by IndentationConsistency.
84
+ 'elsif a2',
85
+ ' b2',
86
+ 'else',
87
+ ' c',
88
+ 'end'].join("\n")
89
+ end
90
+
61
91
  it 'accepts a one line if statement' do
62
92
  inspect_source(cop,
63
93
  ['if cond then func1 else func2 end'])
64
- expect(cop.offences).to be_empty
94
+ expect(cop.offenses).to be_empty
65
95
  end
66
96
 
67
97
  it 'accepts a correctly aligned if/elsif/else/end' do
@@ -73,7 +103,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
73
103
  'else',
74
104
  ' c',
75
105
  'end'])
76
- expect(cop.offences).to be_empty
106
+ expect(cop.offenses).to be_empty
77
107
  end
78
108
 
79
109
  it 'accepts if/elsif/else/end laid out as a table' do
@@ -83,7 +113,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
83
113
  'elsif @io == $stderr then str << "$stderr"',
84
114
  'else str << @io.class.to_s',
85
115
  'end'])
86
- expect(cop.offences).to be_empty
116
+ expect(cop.offenses).to be_empty
87
117
  end
88
118
 
89
119
  it 'accepts if/then/else/end laid out as another table' do
@@ -92,7 +122,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
92
122
  'then ConfigTable.load',
93
123
  'else ConfigTable.new',
94
124
  'end'])
95
- expect(cop.offences).to be_empty
125
+ expect(cop.offenses).to be_empty
96
126
  end
97
127
 
98
128
  it 'accepts an empty if' do
@@ -100,95 +130,201 @@ describe Rubocop::Cop::Style::IndentationWidth do
100
130
  ['if a',
101
131
  'else',
102
132
  'end'])
103
- expect(cop.offences).to be_empty
104
- end
105
-
106
- it 'accepts an if in assignment with end aligned with variable' do
107
- inspect_source(cop,
108
- ['var = if a',
109
- ' 0',
110
- 'end',
111
- '@var = if a',
112
- ' 0',
113
- 'end',
114
- '$var = if a',
115
- ' 0',
116
- 'end',
117
- 'var ||= if a',
118
- ' 0',
119
- 'end',
120
- 'var &&= if a',
121
- ' 0',
122
- 'end',
123
- 'var -= if a',
124
- ' 0',
125
- 'end',
126
- 'VAR = if a',
127
- ' 0',
128
- 'end'])
129
- expect(cop.offences).to be_empty
130
- end
131
-
132
- it 'accepts an if/else in assignment with end aligned with variable' do
133
- inspect_source(cop,
134
- ['var = if a',
135
- ' 0',
136
- 'else',
137
- ' 1',
138
- 'end'])
139
- expect(cop.offences).to be_empty
140
- end
141
-
142
- it 'accepts an if/else in assignment with end aligned with variable ' \
143
- 'and chaining after the end' do
144
- inspect_source(cop,
145
- ['var = if a',
146
- ' 0',
147
- 'else',
148
- ' 1',
149
- 'end.abc.join("")'])
150
- expect(cop.offences).to be_empty
151
- end
152
-
153
- it 'accepts an if/else in assignment with end aligned with variable ' \
154
- 'and chaining with a block after the end' do
155
- inspect_source(cop,
156
- ['var = if a',
157
- ' 0',
158
- 'else',
159
- ' 1',
160
- 'end.abc.tap {}'])
161
- expect(cop.offences).to be_empty
162
- end
163
-
164
- it 'accepts an if in assignment with end aligned with if' do
165
- inspect_source(cop,
166
- ['var = if a',
167
- ' 0',
168
- ' end'])
169
- expect(cop.offences).to be_empty
170
- end
171
-
172
- it 'accepts an if/else in assignment with end aligned with if' do
173
- inspect_source(cop,
174
- ['var = if a',
175
- ' 0',
176
- ' else',
177
- ' 1',
178
- ' end'])
179
- expect(cop.offences).to be_empty
180
- end
181
-
182
- it 'accepts an if/else in assignment on next line with end aligned ' \
183
- 'with if' do
184
- inspect_source(cop,
185
- ['var =',
186
- ' if a',
187
- ' 0',
188
- ' else',
189
- ' 1',
190
- ' end'])
191
- expect(cop.offences).to be_empty
133
+ expect(cop.offenses).to be_empty
134
+ end
135
+
136
+ context 'with assignment' do
137
+ context 'when alignment style is variable' do
138
+ context 'and end is aligned with variable' do
139
+ it 'accepts an if with end aligned with variable' do
140
+ inspect_source(cop,
141
+ ['var = if a',
142
+ ' 0',
143
+ 'end',
144
+ '@var = if a',
145
+ ' 0',
146
+ 'end',
147
+ '$var = if a',
148
+ ' 0',
149
+ 'end',
150
+ 'var ||= if a',
151
+ ' 0',
152
+ 'end',
153
+ 'var &&= if a',
154
+ ' 0',
155
+ 'end',
156
+ 'var -= if a',
157
+ ' 0',
158
+ 'end',
159
+ 'VAR = if a',
160
+ ' 0',
161
+ 'end'])
162
+ expect(cop.offenses).to be_empty
163
+ end
164
+
165
+ it 'accepts an if/else' do
166
+ inspect_source(cop,
167
+ ['var = if a',
168
+ ' 0',
169
+ 'else',
170
+ ' 1',
171
+ 'end'])
172
+ expect(cop.offenses).to be_empty
173
+ end
174
+
175
+ it 'accepts an if/else with chaining after the end' do
176
+ inspect_source(cop,
177
+ ['var = if a',
178
+ ' 0',
179
+ 'else',
180
+ ' 1',
181
+ 'end.abc.join("")'])
182
+ expect(cop.offenses).to be_empty
183
+ end
184
+
185
+ it 'accepts an if/else with chaining with a block after the end' do
186
+ inspect_source(cop,
187
+ ['var = if a',
188
+ ' 0',
189
+ 'else',
190
+ ' 1',
191
+ 'end.abc.tap {}'])
192
+ expect(cop.offenses).to be_empty
193
+ end
194
+ end
195
+
196
+ context 'and end is aligned with keyword' do
197
+ it 'registers an offense for an if' do
198
+ inspect_source(cop,
199
+ ['var = if a',
200
+ ' 0',
201
+ ' end'])
202
+ expect(cop.messages)
203
+ .to eq(['Use 2 (not 8) spaces for indentation.'])
204
+ end
205
+
206
+ it 'registers an offense for a while' do
207
+ inspect_source(cop,
208
+ ['var = while a',
209
+ ' b',
210
+ ' end'])
211
+ expect(cop.messages)
212
+ .to eq(['Use 2 (not 8) spaces for indentation.'])
213
+ end
214
+
215
+ it 'registers an offense for an until' do
216
+ inspect_source(cop,
217
+ ['var = until a',
218
+ ' b',
219
+ ' end'])
220
+ expect(cop.messages)
221
+ .to eq(['Use 2 (not 8) spaces for indentation.'])
222
+ end
223
+ end
224
+ end
225
+
226
+ shared_examples 'assignment and if with keyword alignment' do
227
+ context 'and end is aligned with variable' do
228
+ it 'registers an offense for an if' do
229
+ inspect_source(cop,
230
+ ['var = if a',
231
+ ' 0',
232
+ 'end'])
233
+ expect(cop.messages)
234
+ .to eq(['Use 2 (not -4) spaces for indentation.'])
235
+ end
236
+
237
+ it 'registers an offense for a while' do
238
+ inspect_source(cop,
239
+ ['var = while a',
240
+ ' b',
241
+ 'end'])
242
+ expect(cop.messages)
243
+ .to eq(['Use 2 (not -4) spaces for indentation.'])
244
+ end
245
+
246
+ it 'autocorrects bad indentation' do
247
+ corrected = autocorrect_source(cop,
248
+ ['var = if a',
249
+ ' b',
250
+ 'end',
251
+ '',
252
+ 'var = while a',
253
+ ' b',
254
+ 'end'])
255
+ expect(corrected).to eq ['var = if a',
256
+ ' b',
257
+ 'end', # Not this cop's job to fix end.
258
+ '',
259
+ 'var = while a',
260
+ ' b',
261
+ 'end'].join("\n")
262
+ end
263
+ end
264
+
265
+ context 'and end is aligned with keyword' do
266
+ it 'accepts an if in assignment' do
267
+ inspect_source(cop,
268
+ ['var = if a',
269
+ ' 0',
270
+ ' end'])
271
+ expect(cop.offenses).to be_empty
272
+ end
273
+
274
+ it 'accepts an if/else in assignment' do
275
+ inspect_source(cop,
276
+ ['var = if a',
277
+ ' 0',
278
+ ' else',
279
+ ' 1',
280
+ ' end'])
281
+ expect(cop.offenses).to be_empty
282
+ end
283
+
284
+ it 'accepts an if/else in assignment on next line' do
285
+ inspect_source(cop,
286
+ ['var =',
287
+ ' if a',
288
+ ' 0',
289
+ ' else',
290
+ ' 1',
291
+ ' end'])
292
+ expect(cop.offenses).to be_empty
293
+ end
294
+
295
+ it 'accepts a while in assignment' do
296
+ inspect_source(cop,
297
+ ['var = while a',
298
+ ' b',
299
+ ' end'])
300
+ expect(cop.offenses).to be_empty
301
+ end
302
+
303
+ it 'accepts an until in assignment' do
304
+ inspect_source(cop,
305
+ ['var = until a',
306
+ ' b',
307
+ ' end'])
308
+ expect(cop.offenses).to be_empty
309
+ end
310
+ end
311
+ end
312
+
313
+ context 'when alignment style is keyword by choice' do
314
+ let(:end_alignment_config) do
315
+ { 'Enabled' => true, 'AlignWith' => 'keyword' }
316
+ end
317
+
318
+ include_examples 'assignment and if with keyword alignment'
319
+ end
320
+
321
+ context 'when alignment style is keyword by default' do
322
+ let(:end_alignment_config) do
323
+ { 'Enabled' => false, 'AlignWith' => 'variable' }
324
+ end
325
+
326
+ include_examples 'assignment and if with keyword alignment'
327
+ end
192
328
  end
193
329
 
194
330
  it 'accepts an if/else branches with rescue clauses' do
@@ -200,12 +336,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
200
336
  'else',
201
337
  ' a rescue nil',
202
338
  'end'])
203
- expect(cop.offences).to be_empty
339
+ expect(cop.offenses).to be_empty
204
340
  end
205
341
  end
206
342
 
207
343
  context 'with unless' do
208
- it 'registers an offence for bad indentation of an unless body' do
344
+ it 'registers an offense for bad indentation of an unless body' do
209
345
  inspect_source(cop,
210
346
  ['unless cond',
211
347
  ' func',
@@ -218,12 +354,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
218
354
  ['unless a',
219
355
  'else',
220
356
  'end'])
221
- expect(cop.offences).to be_empty
357
+ expect(cop.offenses).to be_empty
222
358
  end
223
359
  end
224
360
 
225
361
  context 'with case' do
226
- it 'registers an offence for bad indentation in a case/when body' do
362
+ it 'registers an offense for bad indentation in a case/when body' do
227
363
  inspect_source(cop,
228
364
  ['case a',
229
365
  'when b',
@@ -232,7 +368,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
232
368
  expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
233
369
  end
234
370
 
235
- it 'registers an offence for bad indentation in a case/else body' do
371
+ it 'registers an offense for bad indentation in a case/else body' do
236
372
  inspect_source(cop,
237
373
  ['case a',
238
374
  'when b',
@@ -255,7 +391,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
255
391
  'else',
256
392
  ' f',
257
393
  'end'])
258
- expect(cop.offences).to be_empty
394
+ expect(cop.offenses).to be_empty
259
395
  end
260
396
 
261
397
  it 'accepts case/when/else laid out as a table' do
@@ -265,7 +401,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
265
401
  "when 'unless' then cond, _else, body = *sexp",
266
402
  'else cond, body = *sexp',
267
403
  'end'])
268
- expect(cop.offences).to be_empty
404
+ expect(cop.offenses).to be_empty
269
405
  end
270
406
 
271
407
  it 'accepts case/when/else with then beginning a line' do
@@ -274,7 +410,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
274
410
  "when 'if'",
275
411
  'then cond, body, _else = *sexp',
276
412
  'end'])
277
- expect(cop.offences).to be_empty
413
+ expect(cop.offenses).to be_empty
278
414
  end
279
415
 
280
416
  it 'accepts indented when/else plus indented body' do
@@ -290,12 +426,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
290
426
  ' else',
291
427
  " 'plain'",
292
428
  'end'])
293
- expect(cop.offences).to be_empty
429
+ expect(cop.offenses).to be_empty
294
430
  end
295
431
  end
296
432
 
297
433
  context 'with while/until' do
298
- it 'registers an offence for bad indentation of a while body' do
434
+ it 'registers an offense for bad indentation of a while body' do
299
435
  inspect_source(cop,
300
436
  ['while cond',
301
437
  ' func',
@@ -303,7 +439,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
303
439
  expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
304
440
  end
305
441
 
306
- it 'registers an offence for bad indentation of begin/end/while' do
442
+ it 'registers an offense for bad indentation of begin/end/while' do
307
443
  inspect_source(cop,
308
444
  ['something = begin',
309
445
  ' func1',
@@ -312,7 +448,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
312
448
  expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
313
449
  end
314
450
 
315
- it 'registers an offence for bad indentation of an until body' do
451
+ it 'registers an offense for bad indentation of an until body' do
316
452
  inspect_source(cop,
317
453
  ['until cond',
318
454
  ' func',
@@ -324,12 +460,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
324
460
  inspect_source(cop,
325
461
  ['while a',
326
462
  'end'])
327
- expect(cop.offences).to be_empty
463
+ expect(cop.offenses).to be_empty
328
464
  end
329
465
  end
330
466
 
331
467
  context 'with for' do
332
- it 'registers an offence for bad indentation of a for body' do
468
+ it 'registers an offense for bad indentation of a for body' do
333
469
  inspect_source(cop,
334
470
  ['for var in 1..10',
335
471
  ' func',
@@ -341,21 +477,21 @@ describe Rubocop::Cop::Style::IndentationWidth do
341
477
  inspect_source(cop,
342
478
  ['for var in 1..10',
343
479
  'end'])
344
- expect(cop.offences).to be_empty
480
+ expect(cop.offenses).to be_empty
345
481
  end
346
482
  end
347
483
 
348
484
  context 'with def/defs' do
349
- it 'registers an offence for bad indentation of a def body' do
485
+ it 'registers an offense for bad indentation of a def body' do
350
486
  inspect_source(cop,
351
487
  ['def test',
352
488
  ' func1',
353
- ' func2', # No offence registered for this.
489
+ ' func2', # No offense registered for this.
354
490
  'end'])
355
491
  expect(cop.messages).to eq(['Use 2 (not 4) spaces for indentation.'])
356
492
  end
357
493
 
358
- it 'registers an offence for bad indentation of a defs body' do
494
+ it 'registers an offense for bad indentation of a defs body' do
359
495
  inspect_source(cop,
360
496
  ['def self.test',
361
497
  ' func',
@@ -367,19 +503,19 @@ describe Rubocop::Cop::Style::IndentationWidth do
367
503
  inspect_source(cop,
368
504
  ['def test',
369
505
  'end'])
370
- expect(cop.offences).to be_empty
506
+ expect(cop.offenses).to be_empty
371
507
  end
372
508
 
373
509
  it 'accepts an empty defs body' do
374
510
  inspect_source(cop,
375
511
  ['def self.test',
376
512
  'end'])
377
- expect(cop.offences).to be_empty
513
+ expect(cop.offenses).to be_empty
378
514
  end
379
515
  end
380
516
 
381
517
  context 'with class' do
382
- it 'registers an offence for bad indentation of a class body' do
518
+ it 'registers an offense for bad indentation of a class body' do
383
519
  inspect_source(cop,
384
520
  ['class Test',
385
521
  ' def func',
@@ -392,7 +528,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
392
528
  inspect_source(cop,
393
529
  ['class Test',
394
530
  'end'])
395
- expect(cop.offences).to be_empty
531
+ expect(cop.offenses).to be_empty
396
532
  end
397
533
 
398
534
  it 'accepts indented public, protected, and private' do
@@ -413,12 +549,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
413
549
  ' def g',
414
550
  ' end',
415
551
  'end'])
416
- expect(cop.offences).to be_empty
552
+ expect(cop.offenses).to be_empty
417
553
  end
418
554
  end
419
555
 
420
556
  context 'with module' do
421
- it 'registers an offence for bad indentation of a module body' do
557
+ it 'registers an offense for bad indentation of a module body' do
422
558
  inspect_source(cop,
423
559
  ['module Test',
424
560
  ' def func',
@@ -431,12 +567,12 @@ describe Rubocop::Cop::Style::IndentationWidth do
431
567
  inspect_source(cop,
432
568
  ['module Test',
433
569
  'end'])
434
- expect(cop.offences).to be_empty
570
+ expect(cop.offenses).to be_empty
435
571
  end
436
572
  end
437
573
 
438
574
  context 'with block' do
439
- it 'registers an offence for bad indentation of a do/end body' do
575
+ it 'registers an offense for bad indentation of a do/end body' do
440
576
  inspect_source(cop,
441
577
  ['a = func do',
442
578
  ' b',
@@ -444,7 +580,7 @@ describe Rubocop::Cop::Style::IndentationWidth do
444
580
  expect(cop.messages).to eq(['Use 2 (not 1) spaces for indentation.'])
445
581
  end
446
582
 
447
- it 'registers an offence for bad indentation of a {} body' do
583
+ it 'registers an offense for bad indentation of a {} body' do
448
584
  inspect_source(cop,
449
585
  ['func {',
450
586
  ' b',
@@ -457,14 +593,14 @@ describe Rubocop::Cop::Style::IndentationWidth do
457
593
  ['a = func do',
458
594
  ' b',
459
595
  'end'])
460
- expect(cop.offences).to be_empty
596
+ expect(cop.offenses).to be_empty
461
597
  end
462
598
 
463
599
  it 'accepts an empty block body' do
464
600
  inspect_source(cop,
465
601
  ['a = func do',
466
602
  'end'])
467
- expect(cop.offences).to be_empty
603
+ expect(cop.offenses).to be_empty
468
604
  end
469
605
  end
470
606
  end