rubocop 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +7 -7
- data/.travis.yml +4 -0
- data/CHANGELOG.md +59 -0
- data/README.md +62 -28
- data/config/default.yml +31 -0
- data/config/disabled.yml +1 -1
- data/config/enabled.yml +17 -0
- data/lib/rubocop.rb +4 -0
- data/lib/rubocop/cli.rb +1 -1
- data/lib/rubocop/config.rb +12 -8
- data/lib/rubocop/config_loader.rb +20 -10
- data/lib/rubocop/cop/cop.rb +13 -7
- data/lib/rubocop/cop/corrector.rb +10 -10
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +6 -1
- data/lib/rubocop/cop/lint/block_alignment.rb +9 -2
- data/lib/rubocop/cop/lint/debugger.rb +13 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +104 -0
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/require_parentheses.rb +3 -3
- data/lib/rubocop/cop/mixin/access_modifier_node.rb +27 -0
- data/lib/rubocop/cop/mixin/on_normal_if_unless.rb +0 -4
- data/lib/rubocop/cop/rails/delegate.rb +4 -5
- data/lib/rubocop/cop/rails/read_write_attribute.rb +33 -0
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +0 -7
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +4 -2
- data/lib/rubocop/cop/style/class_methods.rb +25 -9
- data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +7 -1
- data/lib/rubocop/cop/style/empty_literal.rb +25 -10
- data/lib/rubocop/cop/style/even_odd.rb +32 -14
- data/lib/rubocop/cop/style/first_parameter_indentation.rb +106 -0
- data/lib/rubocop/cop/style/format_string.rb +2 -2
- data/lib/rubocop/cop/style/global_vars.rb +1 -5
- data/lib/rubocop/cop/style/hash_syntax.rb +0 -4
- data/lib/rubocop/cop/style/indentation_consistency.rb +5 -5
- data/lib/rubocop/cop/style/indentation_width.rb +13 -14
- data/lib/rubocop/cop/style/lambda.rb +48 -2
- data/lib/rubocop/cop/style/line_end_concatenation.rb +43 -47
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +3 -3
- data/lib/rubocop/cop/style/module_function.rb +3 -3
- data/lib/rubocop/cop/style/multiline_block_layout.rb +65 -17
- data/lib/rubocop/cop/style/multiline_operation_indentation.rb +2 -1
- data/lib/rubocop/cop/style/perl_backrefs.rb +2 -2
- data/lib/rubocop/cop/style/redundant_exception.rb +12 -0
- data/lib/rubocop/cop/style/self_assignment.rb +27 -0
- data/lib/rubocop/cop/style/semicolon.rb +2 -1
- data/lib/rubocop/cop/style/space_around_block_parameters.rb +92 -0
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +0 -8
- data/lib/rubocop/cop/style/struct_inheritance.rb +42 -0
- data/lib/rubocop/cop/style/trivial_accessors.rb +10 -4
- data/lib/rubocop/cop/util.rb +32 -7
- data/lib/rubocop/formatter/simple_text_formatter.rb +0 -15
- data/lib/rubocop/options.rb +28 -41
- data/lib/rubocop/processed_source.rb +6 -0
- data/lib/rubocop/rake_task.rb +6 -3
- data/lib/rubocop/runner.rb +55 -15
- data/lib/rubocop/version.rb +1 -1
- data/relnotes/v0.29.0.md +116 -0
- data/rubocop.gemspec +3 -3
- data/spec/rubocop/cli_spec.rb +329 -25
- data/spec/rubocop/config_loader_spec.rb +20 -0
- data/spec/rubocop/cop/lint/assignment_in_condition_spec.rb +27 -3
- data/spec/rubocop/cop/lint/block_alignment_spec.rb +3 -4
- data/spec/rubocop/cop/lint/condition_position_spec.rb +1 -1
- data/spec/rubocop/cop/lint/debugger_spec.rb +20 -7
- data/spec/rubocop/cop/lint/duplicate_methods_spec.rb +189 -0
- data/spec/rubocop/cop/lint/empty_interpolation_spec.rb +1 -1
- data/spec/rubocop/cop/lint/end_in_method_spec.rb +1 -1
- data/spec/rubocop/cop/lint/eval_spec.rb +4 -4
- data/spec/rubocop/cop/lint/literal_in_condition_spec.rb +18 -0
- data/spec/rubocop/cop/lint/literal_in_interpolation_spec.rb +2 -2
- data/spec/rubocop/cop/lint/loop_spec.rb +4 -4
- data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +7 -7
- data/spec/rubocop/cop/lint/space_before_first_arg_spec.rb +5 -4
- data/spec/rubocop/cop/lint/useless_assignment_spec.rb +3 -9
- data/spec/rubocop/cop/lint/useless_comparison_spec.rb +1 -1
- data/spec/rubocop/cop/lint/void_spec.rb +1 -1
- data/spec/rubocop/cop/metrics/abc_size_spec.rb +10 -0
- data/spec/rubocop/cop/metrics/line_length_spec.rb +2 -2
- data/spec/rubocop/cop/metrics/parameter_lists_spec.rb +2 -2
- data/spec/rubocop/cop/rails/action_filter_spec.rb +6 -12
- data/spec/rubocop/cop/rails/default_scope_spec.rb +5 -5
- data/spec/rubocop/cop/rails/delegate_spec.rb +8 -0
- data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +1 -1
- data/spec/rubocop/cop/rails/read_write_attribute_spec.rb +119 -8
- data/spec/rubocop/cop/rails/scope_args_spec.rb +3 -3
- data/spec/rubocop/cop/rails/validation_spec.rb +3 -3
- data/spec/rubocop/cop/style/alias_spec.rb +5 -5
- data/spec/rubocop/cop/style/align_hash_spec.rb +1 -1
- data/spec/rubocop/cop/style/align_parameters_spec.rb +8 -8
- data/spec/rubocop/cop/style/and_or_spec.rb +15 -30
- data/spec/rubocop/cop/style/array_join_spec.rb +4 -4
- data/spec/rubocop/cop/style/ascii_comments_spec.rb +1 -2
- data/spec/rubocop/cop/style/ascii_identifiers_spec.rb +2 -2
- data/spec/rubocop/cop/style/begin_block_spec.rb +1 -1
- data/spec/rubocop/cop/style/block_comments_spec.rb +1 -1
- data/spec/rubocop/cop/style/block_end_newline_spec.rb +1 -1
- data/spec/rubocop/cop/style/blocks_spec.rb +2 -2
- data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +38 -33
- data/spec/rubocop/cop/style/case_equality_spec.rb +1 -1
- data/spec/rubocop/cop/style/character_literal_spec.rb +4 -4
- data/spec/rubocop/cop/style/class_and_module_children_spec.rb +4 -2
- data/spec/rubocop/cop/style/class_methods_spec.rb +12 -0
- data/spec/rubocop/cop/style/class_vars_spec.rb +2 -2
- data/spec/rubocop/cop/style/collection_methods_spec.rb +4 -4
- data/spec/rubocop/cop/style/colon_method_call_spec.rb +8 -8
- data/spec/rubocop/cop/style/comment_annotation_spec.rb +10 -10
- data/spec/rubocop/cop/style/constant_name_spec.rb +7 -7
- data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +1 -1
- data/spec/rubocop/cop/style/deprecated_hash_methods_spec.rb +4 -4
- data/spec/rubocop/cop/style/dot_position_spec.rb +8 -6
- data/spec/rubocop/cop/style/each_with_object_spec.rb +2 -2
- data/spec/rubocop/cop/style/else_alignment_spec.rb +2 -4
- data/spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb +78 -0
- data/spec/rubocop/cop/style/empty_lines_around_class_body_spec.rb +60 -0
- data/spec/rubocop/cop/style/empty_lines_spec.rb +3 -3
- data/spec/rubocop/cop/style/empty_literal_spec.rb +29 -12
- data/spec/rubocop/cop/style/encoding_spec.rb +3 -3
- data/spec/rubocop/cop/style/end_block_spec.rb +1 -1
- data/spec/rubocop/cop/style/end_of_line_spec.rb +2 -2
- data/spec/rubocop/cop/style/even_odd_spec.rb +109 -20
- data/spec/rubocop/cop/style/extra_spacing_spec.rb +3 -3
- data/spec/rubocop/cop/style/first_parameter_indentation_spec.rb +293 -0
- data/spec/rubocop/cop/style/for_spec.rb +2 -2
- data/spec/rubocop/cop/style/format_string_spec.rb +45 -21
- data/spec/rubocop/cop/style/global_vars_spec.rb +4 -4
- data/spec/rubocop/cop/style/guard_clause_spec.rb +17 -0
- data/spec/rubocop/cop/style/hash_syntax_spec.rb +15 -15
- data/spec/rubocop/cop/{metrics → style}/if_unless_modifier_spec.rb +2 -2
- data/spec/rubocop/cop/style/if_with_semicolon_spec.rb +2 -2
- data/spec/rubocop/cop/style/indent_array_spec.rb +3 -6
- data/spec/rubocop/cop/style/indent_hash_spec.rb +4 -4
- data/spec/rubocop/cop/style/indentation_consistency_spec.rb +1 -2
- data/spec/rubocop/cop/style/indentation_width_spec.rb +1 -2
- data/spec/rubocop/cop/style/infinite_loop_spec.rb +1 -1
- data/spec/rubocop/cop/style/lambda_call_spec.rb +4 -4
- data/spec/rubocop/cop/style/lambda_spec.rb +37 -2
- data/spec/rubocop/cop/style/leading_comment_space_spec.rb +7 -12
- data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +41 -1
- data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +4 -4
- data/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb +3 -3
- data/spec/rubocop/cop/style/method_name_spec.rb +1 -1
- data/spec/rubocop/cop/style/multiline_block_layout_spec.rb +61 -0
- data/spec/rubocop/cop/style/multiline_if_then_spec.rb +1 -3
- data/spec/rubocop/cop/style/multiline_operation_indentation_spec.rb +8 -0
- data/spec/rubocop/cop/style/multiline_ternary_operator_spec.rb +1 -1
- data/spec/rubocop/cop/style/nested_ternary_operator_spec.rb +1 -1
- data/spec/rubocop/cop/style/next_spec.rb +16 -0
- data/spec/rubocop/cop/style/numeric_literals_spec.rb +5 -5
- data/spec/rubocop/cop/style/one_line_conditional_spec.rb +1 -1
- data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +22 -4
- data/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb +31 -31
- data/spec/rubocop/cop/style/percent_q_literals_spec.rb +12 -12
- data/spec/rubocop/cop/style/perl_backrefs_spec.rb +3 -3
- data/spec/rubocop/cop/style/proc_spec.rb +3 -3
- data/spec/rubocop/cop/style/raise_args_spec.rb +9 -9
- data/spec/rubocop/cop/style/redundant_begin_spec.rb +1 -1
- data/spec/rubocop/cop/style/redundant_exception_spec.rb +36 -4
- data/spec/rubocop/cop/style/redundant_self_spec.rb +89 -45
- data/spec/rubocop/cop/style/regexp_literal_spec.rb +9 -9
- data/spec/rubocop/cop/style/rescue_modifier_spec.rb +2 -2
- data/spec/rubocop/cop/style/self_assignment_spec.rb +16 -10
- data/spec/rubocop/cop/style/semicolon_spec.rb +9 -9
- data/spec/rubocop/cop/style/single_line_block_params_spec.rb +2 -2
- data/spec/rubocop/cop/style/single_space_before_first_arg_spec.rb +1 -1
- data/spec/rubocop/cop/style/space_after_colon_spec.rb +5 -5
- data/spec/rubocop/cop/style/space_after_comma_spec.rb +3 -3
- data/spec/rubocop/cop/style/space_after_control_keyword_spec.rb +4 -4
- data/spec/rubocop/cop/style/space_after_not_spec.rb +2 -2
- data/spec/rubocop/cop/style/space_after_semicolon_spec.rb +2 -2
- data/spec/rubocop/cop/style/space_around_block_parameters_spec.rb +150 -0
- data/spec/rubocop/cop/style/space_around_equals_in_parameter_default_spec.rb +18 -9
- data/spec/rubocop/cop/style/space_around_operators_spec.rb +24 -21
- data/spec/rubocop/cop/style/space_before_block_braces_spec.rb +4 -4
- data/spec/rubocop/cop/style/space_before_comma_spec.rb +4 -4
- data/spec/rubocop/cop/style/space_before_comment_spec.rb +3 -3
- data/spec/rubocop/cop/style/space_before_semicolon_spec.rb +2 -2
- data/spec/rubocop/cop/style/space_inside_block_braces_spec.rb +33 -24
- data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +2 -2
- data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +9 -9
- data/spec/rubocop/cop/style/space_inside_parens_spec.rb +1 -1
- data/spec/rubocop/cop/style/special_global_vars_spec.rb +6 -6
- data/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb +3 -3
- data/spec/rubocop/cop/style/string_literals_spec.rb +16 -16
- data/spec/rubocop/cop/style/struct_inheritance_spec.rb +44 -0
- data/spec/rubocop/cop/style/symbol_array_spec.rb +9 -9
- data/spec/rubocop/cop/style/symbol_proc_spec.rb +12 -12
- data/spec/rubocop/cop/style/tab_spec.rb +4 -4
- data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +2 -2
- data/spec/rubocop/cop/style/trailing_whitespace_spec.rb +2 -2
- data/spec/rubocop/cop/style/trivial_accessors_spec.rb +16 -0
- data/spec/rubocop/cop/style/unneeded_capital_w_spec.rb +11 -22
- data/spec/rubocop/cop/style/variable_interpolation_spec.rb +7 -7
- data/spec/rubocop/cop/style/while_until_do_spec.rb +2 -2
- data/spec/rubocop/cop/{metrics → style}/while_until_modifier_spec.rb +2 -2
- data/spec/rubocop/cop/style/word_array_spec.rb +11 -11
- data/spec/rubocop/cop/util_spec.rb +51 -0
- data/spec/rubocop/cop/variable_force/reference_spec.rb +19 -0
- data/spec/rubocop/cop/variable_force/variable_table_spec.rb +7 -0
- data/spec/rubocop/formatter/disabled_lines_formatter_spec.rb +7 -8
- data/spec/rubocop/formatter/text_util_spec.rb +55 -0
- data/spec/rubocop/options_spec.rb +26 -20
- data/spec/rubocop/rake_task_spec.rb +122 -0
- data/spec/rubocop/runner_spec.rb +37 -2
- data/spec/rubocop/token_spec.rb +5 -1
- data/spec/spec_helper.rb +5 -2
- data/spec/support/cop_helper.rb +3 -0
- data/spec/support/cops/class_must_be_a_module_cop.rb +19 -0
- data/spec/support/cops/module_must_be_a_class_cop.rb +19 -0
- data/spec/support/custom_matchers.rb +1 -1
- metadata +35 -12
data/lib/rubocop/version.rb
CHANGED
data/relnotes/v0.29.0.md
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
### New features
|
2
|
+
|
3
|
+
* [#1430](https://github.com/bbatsov/rubocop/issues/1430): Add `--except` option for disabling cops on the command line. ([@jonas054][])
|
4
|
+
* [#1506](https://github.com/bbatsov/rubocop/pull/1506): Add auto-correct from `EvenOdd` cop. ([@blainesch][])
|
5
|
+
* [#1507](https://github.com/bbatsov/rubocop/issues/1507): `Debugger` cop now checks for the Capybara debug methods `save_and_open_page` and `save_and_open_screenshot`. ([@rrosenblum][])
|
6
|
+
* [#1539](https://github.com/bbatsov/rubocop/pull/1539): Implement autocorrection for Rails/ReadWriteAttribute cop. ([@huerlisi][])
|
7
|
+
* [#1324](https://github.com/bbatsov/rubocop/issues/1324): Add `AllCops/DisplayCopNames` configuration option for showing cop names in reports, like `--display-cop-names`. ([@jonas054][])
|
8
|
+
* [#1271](https://github.com/bbatsov/rubocop/issues/1271): `Lambda` cop does auto-correction. ([@lumeet][])
|
9
|
+
* [#1284](https://github.com/bbatsov/rubocop/issues/1284): Support namespaces, e.g. `Lint`, in the arguments to `--only` and `--except`. ([@jonas054][])
|
10
|
+
* [#1276](https://github.com/bbatsov/rubocop/issues/1276): `SelfAssignment` cop does auto-correction. ([@lumeet][])
|
11
|
+
* Add autocorrect to `RedundantException`. ([@mattjmcnaughton][])
|
12
|
+
* [#1571](https://github.com/bbatsov/rubocop/pull/1571): New cop `StructInheritance` checks for inheritance from Struct.new. ([@mmozuras][])
|
13
|
+
* [#1575](https://github.com/bbatsov/rubocop/issues/1575): New cop `DuplicateMethods` points out duplicate method name in class and module. ([@d4rk5eed][])
|
14
|
+
* [#1144](https://github.com/bbatsov/rubocop/issues/1144): New cop `FirstParameterIndentation` checks the indentation of the first parameter in a method call. ([@jonas054][])
|
15
|
+
* [#1627](https://github.com/bbatsov/rubocop/issues/1627): New cop `SpaceAroundBlockParameters` checks the spacing inside and after block parameters pipes. ([@jonas054][])
|
16
|
+
|
17
|
+
### Changes
|
18
|
+
|
19
|
+
* [#1492](https://github.com/bbatsov/rubocop/pull/1492): Abort when auto-correct causes an infinite loop. ([@dblock][])
|
20
|
+
* Options `-e`/`--emacs` and `-s`/`--silent` are no longer recognized. Using them will now raise an error. ([@bquorning][])
|
21
|
+
* [#1565](https://github.com/bbatsov/rubocop/issues/1565): Let `--fail-level A` cause exit with error if all offenses are auto-corrected. ([@jonas054][])
|
22
|
+
* [#1309](https://github.com/bbatsov/rubocop/issues/1309): Add argument handling to `MultilineBlockLayout`. ([@lumeet][])
|
23
|
+
|
24
|
+
### Bugs fixed
|
25
|
+
|
26
|
+
* [#1634](https://github.com/bbatsov/rubocop/pull/1634): Fix `PerlBackrefs` Cop Autocorrections to Not Raise. ([@cshaffer][])
|
27
|
+
* [#1553](https://github.com/bbatsov/rubocop/pull/1553): Fix bug where `Style/EmptyLinesAroundAccessModifier` interfered with `Style/EmptyLinesAroundBlockBody` when there is and access modifier at the beginning of a block. ([@volkert][])
|
28
|
+
* Handle element assignment in `Lint/AssignmentInCondition`. ([@jonas054][])
|
29
|
+
* [#1484](https://github.com/bbatsov/rubocop/issues/1484): Fix `EmptyLinesAroundAccessModifier` incorrectly finding a violation inside method calls with names identical to an access modifier. ([@dblock][])
|
30
|
+
* Fix bug concerning `Exclude` properties inherited from a higher directory level. ([@jonas054][])
|
31
|
+
* [#1500](https://github.com/bbatsov/rubocop/issues/1500): Fix crashing `--auto-correct --only IndentationWidth`. ([@jonas054][])
|
32
|
+
* [#1512](https://github.com/bbatsov/rubocop/issues/1512): Fix false negative for typical string formatting examples. ([@kakutani][], [@jonas054][])
|
33
|
+
* [#1504](https://github.com/bbatsov/rubocop/issues/1504): Fail with a meaningful error if the configuration file is malformed. ([@bquorning][])
|
34
|
+
* Fix bug where `auto_correct` Rake tasks does not take in the options specified in its parent task. ([@rrosenblum][])
|
35
|
+
* [#1054](https://github.com/bbatsov/rubocop/issues/1054): Handle comments within concatenated strings in `LineEndConcatenation`. ([@yujinakayama][], [@jonas054][])
|
36
|
+
* [#1527](https://github.com/bbatsov/rubocop/issues/1527): Make autocorrect `BracesAroundHashParameter` leave the correct number of spaces. ([@mattjmcnaughton][])
|
37
|
+
* [#1547](https://github.com/bbatsov/rubocop/issues/1547): Don't print `[Corrected]` when auto-correction was avoided in `Style/Semicolon`. ([@jonas054][])
|
38
|
+
* [#1573](https://github.com/bbatsov/rubocop/issues/1573): Fix assignment-related auto-correction for `BlockAlignment`. ([@lumeet][])
|
39
|
+
* [#1587](https://github.com/bbatsov/rubocop/pull/1587): Exit with exit code 1 if there were errors ("crashing" cops). ([@jonas054][])
|
40
|
+
* [#1574](https://github.com/bbatsov/rubocop/issues/1574): Avoid auto-correcting `Hash.new` to `{}` when braces would be interpreted as a block. ([@jonas054][])
|
41
|
+
* [#1591](https://github.com/bbatsov/rubocop/issues/1591): Don't check parameters inside `[]` in `MultilineOperationIndentation`. ([@jonas054][])
|
42
|
+
* [#1509](https://github.com/bbatsov/rubocop/issues/1509): Ignore class methods in `Rails/Delegate`. ([@bbatsov][])
|
43
|
+
* [#1594](https://github.com/bbatsov/rubocop/issues/1594): Fix `@example` warnings in Yard Doc documentation generation. ([@mattjmcnaughton][])
|
44
|
+
* [#1598](https://github.com/bbatsov/rubocop/issues/1598): Fix bug in file inclusion when running from another directory. ([@jonas054][])
|
45
|
+
* [#1580](https://github.com/bbatsov/rubocop/issues/1580): Don't print `[Corrected]` when auto-correction was avoided in `TrivialAccessors`. ([@lumeet][])
|
46
|
+
* [#1612](https://github.com/bbatsov/rubocop/issues/1612): Allow `expand_path` on `inherit_from` in `.rubocop.yml`. ([@mattjmcnaughton][])
|
47
|
+
* [#1610](https://github.com/bbatsov/rubocop/issues/1610): Check that class method names actually match the name of the containing class/module in `Style/ClassMethods`. ([@bbatsov][])
|
48
|
+
|
49
|
+
[@bbatsov]: https://github.com/bbatsov
|
50
|
+
[@jonas054]: https://github.com/jonas054
|
51
|
+
[@yujinakayama]: https://github.com/yujinakayama
|
52
|
+
[@dblock]: https://github.com/dblock
|
53
|
+
[@nevir]: https://github.com/nevir
|
54
|
+
[@daviddavis]: https://github.com/daviddavis
|
55
|
+
[@sds]: https://github.com/sds
|
56
|
+
[@fancyremarker]: https://github.com/fancyremarker
|
57
|
+
[@sinisterchipmunk]: https://github.com/sinisterchipmunk
|
58
|
+
[@vonTronje]: https://github.com/vonTronje
|
59
|
+
[@agrimm]: https://github.com/agrimm
|
60
|
+
[@pmenglund]: https://github.com/pmenglund
|
61
|
+
[@chulkilee]: https://github.com/chulkilee
|
62
|
+
[@codez]: https://github.com/codez
|
63
|
+
[@emou]: https://github.com/emou
|
64
|
+
[@skanev]: http://github.com/skanev
|
65
|
+
[@claco]: http://github.com/claco
|
66
|
+
[@rifraf]: http://github.com/rifraf
|
67
|
+
[@scottmatthewman]: https://github.com/scottmatthewman
|
68
|
+
[@ma2gedev]: http://github.com/ma2gedev
|
69
|
+
[@jeremyolliver]: https://github.com/jeremyolliver
|
70
|
+
[@hannestyden]: https://github.com/hannestyden
|
71
|
+
[@geniou]: https://github.com/geniou
|
72
|
+
[@jkogara]: https://github.com/jkogara
|
73
|
+
[@tmorris-fiksu]: https://github.com/tmorris-fiksu
|
74
|
+
[@mockdeep]: https://github.com/mockdeep
|
75
|
+
[@hiroponz]: https://github.com/hiroponz
|
76
|
+
[@tamird]: https://github.com/tamird
|
77
|
+
[@fshowalter]: https://github.com/fshowalter
|
78
|
+
[@cschramm]: https://github.com/cschramm
|
79
|
+
[@bquorning]: https://github.com/bquorning
|
80
|
+
[@bcobb]: https://github.com/bcobb
|
81
|
+
[@irrationalfab]: https://github.com/irrationalfab
|
82
|
+
[@tommeier]: https://github.com/tommeier
|
83
|
+
[@sfeldon]: https://github.com/sfeldon
|
84
|
+
[@biinari]: https://github.com/biinari
|
85
|
+
[@barunio]: https://github.com/barunio
|
86
|
+
[@molawson]: https://github.com/molawson
|
87
|
+
[@wndhydrnt]: https://github.com/wndhydrnt
|
88
|
+
[@ggilder]: https://github.com/ggilder
|
89
|
+
[@salbertson]: https://github.com/salbertson
|
90
|
+
[@camilleldn]: https://github.com/camilleldn
|
91
|
+
[@mcls]: https://github.com/mcls
|
92
|
+
[@yous]: https://github.com/yous
|
93
|
+
[@vrthra]: https://github.com/vrthra
|
94
|
+
[@SkuliOskarsson]: https://github.com/SkuliOskarsson
|
95
|
+
[@jspanjers]: https://github.com/jspanjers
|
96
|
+
[@sch1zo]: https://github.com/sch1zo
|
97
|
+
[@smangelsdorf]: https://github.com/smangelsdorf
|
98
|
+
[@mvz]: https://github.com/mvz
|
99
|
+
[@jfelchner]: https://github.com/jfelchner
|
100
|
+
[@janraasch]: https://github.com/janraasch
|
101
|
+
[@jcarbo]: https://github.com/jcarbo
|
102
|
+
[@oneamtu]: https://github.com/oneamtu
|
103
|
+
[@toy]: https://github.com/toy
|
104
|
+
[@Koronen]: https://github.com/Koronen
|
105
|
+
[@blainesch]: https://github.com/blainesch
|
106
|
+
[@marxarelli]: https://github.com/marxarelli
|
107
|
+
[@katieschilling]: https://github.com/katieschilling
|
108
|
+
[@kakutani]: https://github.com/kakutani
|
109
|
+
[@rrosenblum]: https://github.com/rrosenblum
|
110
|
+
[@mattjmcnaughton]: https://github.com/mattjmcnaughton
|
111
|
+
[@huerlisi]: https://github.com/huerlisi
|
112
|
+
[@volkert]: https://github.com/volkert
|
113
|
+
[@lumeet]: https://github.com/lumeet
|
114
|
+
[@mmozuras]: https://github.com/mmozuras
|
115
|
+
[@d4rk5eed]: https://github.com/d4rk5eed
|
116
|
+
[@cshaffer]: https://github.com/cshaffer
|
data/rubocop.gemspec
CHANGED
@@ -27,12 +27,12 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.summary = 'Automatic Ruby code style checking tool.'
|
28
28
|
|
29
29
|
s.add_runtime_dependency('rainbow', '>= 1.99.1', '< 3.0')
|
30
|
-
s.add_runtime_dependency('parser', '>= 2.2.0.
|
31
|
-
s.add_runtime_dependency('powerpack', '~> 0.
|
30
|
+
s.add_runtime_dependency('parser', '>= 2.2.0.1', '< 3.0')
|
31
|
+
s.add_runtime_dependency('powerpack', '~> 0.1')
|
32
32
|
s.add_runtime_dependency('astrolabe', '~> 1.3')
|
33
33
|
s.add_runtime_dependency('ruby-progressbar', '~> 1.4')
|
34
34
|
s.add_development_dependency('rake', '~> 10.1')
|
35
|
-
s.add_development_dependency('rspec', '~> 3.0')
|
35
|
+
s.add_development_dependency('rspec', '~> 3.1.0')
|
36
36
|
s.add_development_dependency('yard', '~> 0.8')
|
37
37
|
s.add_development_dependency('bundler', '~> 1.3')
|
38
38
|
s.add_development_dependency('simplecov', '~> 0.7')
|
data/spec/rubocop/cli_spec.rb
CHANGED
@@ -47,6 +47,57 @@ describe RuboCop::CLI, :isolated_environment do
|
|
47
47
|
expect(uncorrected).to be_empty # Hence exit code 0.
|
48
48
|
end
|
49
49
|
|
50
|
+
it 'corrects only IndentationWidth without crashing' do
|
51
|
+
source = ['foo = if bar',
|
52
|
+
' something',
|
53
|
+
'elsif baz',
|
54
|
+
' other_thing',
|
55
|
+
'else',
|
56
|
+
' fail',
|
57
|
+
'end']
|
58
|
+
create_file('example.rb', source)
|
59
|
+
expect(cli.run(%w(--only IndentationWidth --auto-correct))).to eq(0)
|
60
|
+
corrected = ['foo = if bar',
|
61
|
+
' something',
|
62
|
+
'elsif baz',
|
63
|
+
' other_thing',
|
64
|
+
'else',
|
65
|
+
' fail',
|
66
|
+
'end',
|
67
|
+
''].join("\n")
|
68
|
+
expect(IO.read('example.rb')).to eq(corrected)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'crashes on infinite loop but prints offenses' do
|
72
|
+
create_file('example.rb', '3.times{ something;other_thing;}')
|
73
|
+
# This configuration makes --auto-correct impossible to finish since a
|
74
|
+
# space will be added after each ; but then removed again for the one
|
75
|
+
# that's inside }.
|
76
|
+
create_file('.rubocop.yml', ['SpaceInsideBlockBraces:',
|
77
|
+
' EnforcedStyle: no_space',
|
78
|
+
' SpaceBeforeBlockParameters: false'])
|
79
|
+
cmd = %w(--only SpaceAfterSemicolon,SpaceInsideBlockBraces
|
80
|
+
--auto-correct --format simple)
|
81
|
+
expect { cli.run(cmd) }.to raise_error(RuboCop::Runner::
|
82
|
+
InfiniteCorrectionLoop)
|
83
|
+
expect(IO.read('example.rb'))
|
84
|
+
.to eq("3.times{something; other_thing;}\n")
|
85
|
+
|
86
|
+
expected_output = [
|
87
|
+
'== example.rb ==',
|
88
|
+
'C: 1: 9: [Corrected] Space inside { detected.',
|
89
|
+
'C: 1: 19: [Corrected] Space missing after semicolon.',
|
90
|
+
'C: 1: 31: [Corrected] Space missing after semicolon.',
|
91
|
+
'C: 1: 32: [Corrected] Space inside } detected.',
|
92
|
+
'C: 1: 33: [Corrected] Space inside } detected.',
|
93
|
+
'',
|
94
|
+
# We're interrupted during inspection, hence 0 files inspected.
|
95
|
+
'0 files inspected, 5 offenses detected, 5 offenses corrected',
|
96
|
+
''
|
97
|
+
]
|
98
|
+
expect($stdout.string).to eq(expected_output.join("\n"))
|
99
|
+
end
|
100
|
+
|
50
101
|
it 'corrects complicated cases conservatively' do
|
51
102
|
# Two cops make corrections here; Style/BracesAroundHashParameters, and
|
52
103
|
# Style/AlignHash. Because they make minimal corrections relating only
|
@@ -66,13 +117,11 @@ describe RuboCop::CLI, :isolated_environment do
|
|
66
117
|
expect(cli.run(['-D', '--auto-correct'])).to eq(0)
|
67
118
|
corrected =
|
68
119
|
['# encoding: utf-8',
|
69
|
-
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
73
|
-
"
|
74
|
-
" postal_code: '99999-1111'",
|
75
|
-
')']
|
120
|
+
"expect(subject[:address]).to eq(street1: '1 Market',",
|
121
|
+
" street2: '#200',",
|
122
|
+
" city: 'Some Town',",
|
123
|
+
" state: 'CA',",
|
124
|
+
" postal_code: '99999-1111')"]
|
76
125
|
expect(IO.read('example.rb')).to eq(corrected.join("\n") + "\n")
|
77
126
|
end
|
78
127
|
|
@@ -320,12 +369,12 @@ describe RuboCop::CLI, :isolated_environment do
|
|
320
369
|
''].join("\n"))
|
321
370
|
expect($stdout.string).to eq(['',
|
322
371
|
'10 Style/TrailingWhitespace',
|
323
|
-
'
|
372
|
+
'3 Style/Semicolon',
|
324
373
|
'3 Style/SingleLineMethods',
|
325
374
|
'1 Style/DefWithParentheses',
|
326
375
|
'1 Style/EmptyLineBetweenDefs',
|
327
376
|
'--',
|
328
|
-
'
|
377
|
+
'18 Total',
|
329
378
|
'',
|
330
379
|
''].join("\n"))
|
331
380
|
end
|
@@ -570,22 +619,26 @@ describe RuboCop::CLI, :isolated_environment do
|
|
570
619
|
create_file('example.rb', ['# encoding: utf-8',
|
571
620
|
'a = c and b',
|
572
621
|
'not a && b',
|
573
|
-
'func a do b end'
|
622
|
+
'func a do b end',
|
623
|
+
"Signal.trap('TERM') { system(cmd); exit }"])
|
574
624
|
expect(cli.run(%w(-a -f simple))).to eq(1)
|
575
625
|
expect($stderr.string).to eq('')
|
576
|
-
expect(IO.read('example.rb'))
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
626
|
+
expect(IO.read('example.rb'))
|
627
|
+
.to eq(['# encoding: utf-8',
|
628
|
+
'a = c and b',
|
629
|
+
'not a && b',
|
630
|
+
'func a do b end',
|
631
|
+
"Signal.trap('TERM') { system(cmd); exit }",
|
632
|
+
''].join("\n"))
|
581
633
|
expect($stdout.string)
|
582
634
|
.to eq(['== example.rb ==',
|
583
635
|
'C: 2: 7: Use && instead of and.',
|
584
636
|
'C: 3: 1: Use ! instead of not.',
|
585
637
|
'C: 4: 8: Prefer {...} over do...end for single-line ' \
|
586
638
|
'blocks.',
|
639
|
+
'C: 5: 34: Do not use semicolons to terminate expressions.',
|
587
640
|
'',
|
588
|
-
'1 file inspected,
|
641
|
+
'1 file inspected, 4 offenses detected',
|
589
642
|
''].join("\n"))
|
590
643
|
end
|
591
644
|
|
@@ -847,7 +900,8 @@ describe RuboCop::CLI, :isolated_environment do
|
|
847
900
|
"\ty",
|
848
901
|
'end'])
|
849
902
|
expect(cli.run(['--only', 'Style/123'])).to eq(1)
|
850
|
-
expect($stderr.string)
|
903
|
+
expect($stderr.string)
|
904
|
+
.to include('Unrecognized cop or namespace: Style/123.')
|
851
905
|
end
|
852
906
|
|
853
907
|
it 'accepts cop names from plugins' do
|
@@ -974,6 +1028,125 @@ describe RuboCop::CLI, :isolated_environment do
|
|
974
1028
|
end
|
975
1029
|
end
|
976
1030
|
end
|
1031
|
+
|
1032
|
+
context 'when a namespace is given' do
|
1033
|
+
it 'runs all enabled cops in that namespace' do
|
1034
|
+
create_file('example.rb', ['if x== 100000000000000 ',
|
1035
|
+
' ' + '#' * 100,
|
1036
|
+
"\ty",
|
1037
|
+
'end'])
|
1038
|
+
expect(cli.run(%w(-f offenses --only Metrics example.rb))).to eq(1)
|
1039
|
+
expect($stdout.string).to eq(['',
|
1040
|
+
'1 Metrics/LineLength',
|
1041
|
+
'--',
|
1042
|
+
'1 Total',
|
1043
|
+
'',
|
1044
|
+
''].join("\n"))
|
1045
|
+
end
|
1046
|
+
end
|
1047
|
+
|
1048
|
+
context 'when two namespaces are given' do
|
1049
|
+
it 'runs all enabled cops in those namespaces' do
|
1050
|
+
create_file('example.rb', ['# encoding: utf-8',
|
1051
|
+
'if x== 100000000000000 ',
|
1052
|
+
' # ' + '-' * 98,
|
1053
|
+
"\ty",
|
1054
|
+
'end'])
|
1055
|
+
create_file('.rubocop.yml', ['Style/SpaceAroundOperators:',
|
1056
|
+
' Enabled: false'])
|
1057
|
+
expect(cli.run(%w(-f o --only Metrics,Style example.rb))).to eq(1)
|
1058
|
+
expect($stdout.string)
|
1059
|
+
.to eq(['',
|
1060
|
+
'1 Metrics/LineLength',
|
1061
|
+
'1 Style/CommentIndentation',
|
1062
|
+
'1 Style/IndentationWidth',
|
1063
|
+
'1 Style/NumericLiterals',
|
1064
|
+
'1 Style/Tab',
|
1065
|
+
'1 Style/TrailingWhitespace',
|
1066
|
+
'--',
|
1067
|
+
'6 Total',
|
1068
|
+
'',
|
1069
|
+
''].join("\n"))
|
1070
|
+
end
|
1071
|
+
end
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
describe '--except' do
|
1075
|
+
context 'when one name is given' do
|
1076
|
+
it 'exits with error if the cop name is incorrect' do
|
1077
|
+
create_file('example.rb', ['if x== 0 ',
|
1078
|
+
"\ty",
|
1079
|
+
'end'])
|
1080
|
+
expect(cli.run(['--except', 'Style/123'])).to eq(1)
|
1081
|
+
expect($stderr.string)
|
1082
|
+
.to include('Unrecognized cop or namespace: Style/123.')
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
context 'when one cop plus one namespace are given' do
|
1087
|
+
it 'runs all cops except the given' do
|
1088
|
+
create_file('example.rb', ['if x== 0 ',
|
1089
|
+
"\ty = 3",
|
1090
|
+
'end'])
|
1091
|
+
expect(cli.run(['--format', 'offenses',
|
1092
|
+
'--except', 'Style/IfUnlessModifier,Lint',
|
1093
|
+
'example.rb'])).to eq(1)
|
1094
|
+
expect($stdout.string)
|
1095
|
+
.to eq(['',
|
1096
|
+
# Note: No Lint/UselessAssignment offense.
|
1097
|
+
'1 Style/IndentationWidth',
|
1098
|
+
'1 Style/SpaceAroundOperators',
|
1099
|
+
'1 Style/Tab',
|
1100
|
+
'1 Style/TrailingWhitespace',
|
1101
|
+
'--',
|
1102
|
+
'4 Total',
|
1103
|
+
'',
|
1104
|
+
''].join("\n"))
|
1105
|
+
end
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
context 'when one cop is given without namespace' do
|
1109
|
+
it 'disables the given cop' do
|
1110
|
+
create_file('example.rb', ['if x== 0 ',
|
1111
|
+
"\ty",
|
1112
|
+
'end'])
|
1113
|
+
|
1114
|
+
cli.run(['--format', 'offenses',
|
1115
|
+
'--except', 'IfUnlessModifier',
|
1116
|
+
'example.rb'])
|
1117
|
+
with_option = $stdout.string
|
1118
|
+
$stdout = StringIO.new
|
1119
|
+
cli.run(['--format', 'offenses',
|
1120
|
+
'example.rb'])
|
1121
|
+
without_option = $stdout.string
|
1122
|
+
|
1123
|
+
expect(without_option.split($RS) - with_option.split($RS))
|
1124
|
+
.to eq(['1 Style/IfUnlessModifier', '5 Total'])
|
1125
|
+
end
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
context 'when several cops are given' do
|
1129
|
+
it 'disables the given cops' do
|
1130
|
+
create_file('example.rb', ['if x== 100000000000000 ',
|
1131
|
+
"\ty",
|
1132
|
+
'end'])
|
1133
|
+
expect(cli.run(['--format', 'offenses',
|
1134
|
+
'--except',
|
1135
|
+
'Style/IfUnlessModifier,Style/Tab,' \
|
1136
|
+
'Style/SpaceAroundOperators',
|
1137
|
+
'example.rb'])).to eq(1)
|
1138
|
+
expect($stderr.string).to eq('')
|
1139
|
+
expect($stdout.string)
|
1140
|
+
.to eq(['',
|
1141
|
+
'1 Style/IndentationWidth',
|
1142
|
+
'1 Style/NumericLiterals',
|
1143
|
+
'1 Style/TrailingWhitespace',
|
1144
|
+
'--',
|
1145
|
+
'3 Total',
|
1146
|
+
'',
|
1147
|
+
''].join("\n"))
|
1148
|
+
end
|
1149
|
+
end
|
977
1150
|
end
|
978
1151
|
|
979
1152
|
describe '--lint' do
|
@@ -1282,6 +1455,16 @@ describe RuboCop::CLI, :isolated_environment do
|
|
1282
1455
|
.to include('No formatter for "unknown"')
|
1283
1456
|
end
|
1284
1457
|
end
|
1458
|
+
|
1459
|
+
context 'when ambiguous format name is specified' do
|
1460
|
+
it 'aborts with error message' do
|
1461
|
+
# Both 'files' and 'fuubar' start with an 'f'.
|
1462
|
+
expect { cli.run(['--format', 'f', 'example.rb']) }
|
1463
|
+
.to exit_with_code(1)
|
1464
|
+
expect($stderr.string)
|
1465
|
+
.to include('Cannot determine formatter for "f"')
|
1466
|
+
end
|
1467
|
+
end
|
1285
1468
|
end
|
1286
1469
|
|
1287
1470
|
describe 'custom formatter' do
|
@@ -1372,16 +1555,63 @@ describe RuboCop::CLI, :isolated_environment do
|
|
1372
1555
|
|
1373
1556
|
before do
|
1374
1557
|
create_file(target_file, ['# encoding: utf-8',
|
1375
|
-
'
|
1558
|
+
'def f',
|
1559
|
+
' x',
|
1560
|
+
'end'])
|
1561
|
+
end
|
1562
|
+
|
1563
|
+
after do
|
1564
|
+
expect($stderr.string).to eq('')
|
1565
|
+
expect($stdout.string)
|
1566
|
+
.to include('1 file inspected, 1 offense detected')
|
1376
1567
|
end
|
1377
1568
|
|
1378
1569
|
it 'fails when option is less than the severity level' do
|
1570
|
+
expect(cli.run(['--fail-level', 'refactor', target_file])).to eq(1)
|
1571
|
+
expect(cli.run(['--fail-level', 'autocorrect', target_file])).to eq(1)
|
1572
|
+
end
|
1573
|
+
|
1574
|
+
it 'fails when option is equal to the severity level' do
|
1379
1575
|
expect(cli.run(['--fail-level', 'convention', target_file])).to eq(1)
|
1380
1576
|
end
|
1381
1577
|
|
1382
|
-
it '
|
1578
|
+
it 'succeeds when option is greater than the severity level' do
|
1383
1579
|
expect(cli.run(['--fail-level', 'warning', target_file])).to eq(0)
|
1384
1580
|
end
|
1581
|
+
|
1582
|
+
context 'with --auto-correct' do
|
1583
|
+
after do
|
1584
|
+
expect($stdout.string.lines.to_a.last)
|
1585
|
+
.to eq('1 file inspected, 1 offense detected, 1 offense corrected' \
|
1586
|
+
"\n")
|
1587
|
+
end
|
1588
|
+
|
1589
|
+
it 'fails when option is autocorrect and all offenses are ' \
|
1590
|
+
'autocorrected' do
|
1591
|
+
expect(cli.run(['--auto-correct', '--format', 'simple',
|
1592
|
+
'--fail-level', 'autocorrect',
|
1593
|
+
target_file])).to eq(1)
|
1594
|
+
end
|
1595
|
+
|
1596
|
+
it 'fails when option is A and all offenses are autocorrected' do
|
1597
|
+
expect(cli.run(['--auto-correct', '--format', 'simple',
|
1598
|
+
'--fail-level', 'A',
|
1599
|
+
target_file])).to eq(1)
|
1600
|
+
end
|
1601
|
+
|
1602
|
+
it 'succeeds when option is not given and all offenses are ' \
|
1603
|
+
'autocorrected' do
|
1604
|
+
expect(cli.run(['--auto-correct', '--format', 'simple',
|
1605
|
+
target_file])).to eq(0)
|
1606
|
+
end
|
1607
|
+
|
1608
|
+
it 'succeeds when option is refactor and all offenses are ' \
|
1609
|
+
'autocorrected' do
|
1610
|
+
expect(cli.run(['--auto-correct', '--format', 'simple',
|
1611
|
+
'--fail-level', 'refactor',
|
1612
|
+
target_file])).to eq(0)
|
1613
|
+
end
|
1614
|
+
end
|
1385
1615
|
end
|
1386
1616
|
|
1387
1617
|
describe '--force-exclusion' do
|
@@ -1457,6 +1687,44 @@ describe RuboCop::CLI, :isolated_environment do
|
|
1457
1687
|
end
|
1458
1688
|
end
|
1459
1689
|
|
1690
|
+
context 'when given a file/directory that is not under the current dir' do
|
1691
|
+
shared_examples 'checks Rakefile' do
|
1692
|
+
it 'checks a Rakefile but Style/FileName does not report' do
|
1693
|
+
create_file('Rakefile', 'x = 1')
|
1694
|
+
create_file('other/empty', '')
|
1695
|
+
Dir.chdir('other') do
|
1696
|
+
expect(cli.run(['--format', 'simple', checked_path])).to eq(1)
|
1697
|
+
end
|
1698
|
+
expect($stdout.string)
|
1699
|
+
.to eq(["== #{abs('Rakefile')} ==",
|
1700
|
+
'W: 1: 1: Useless assignment to variable - x.',
|
1701
|
+
'',
|
1702
|
+
'1 file inspected, 1 offense detected',
|
1703
|
+
''].join("\n"))
|
1704
|
+
end
|
1705
|
+
end
|
1706
|
+
|
1707
|
+
context 'and the directory is absolute' do
|
1708
|
+
let(:checked_path) { abs('..') }
|
1709
|
+
include_examples 'checks Rakefile'
|
1710
|
+
end
|
1711
|
+
|
1712
|
+
context 'and the directory is relative' do
|
1713
|
+
let(:checked_path) { '..' }
|
1714
|
+
include_examples 'checks Rakefile'
|
1715
|
+
end
|
1716
|
+
|
1717
|
+
context 'and the Rakefile path is absolute' do
|
1718
|
+
let(:checked_path) { abs('../Rakefile') }
|
1719
|
+
include_examples 'checks Rakefile'
|
1720
|
+
end
|
1721
|
+
|
1722
|
+
context 'and the Rakefile path is relative' do
|
1723
|
+
let(:checked_path) { '../Rakefile' }
|
1724
|
+
include_examples 'checks Rakefile'
|
1725
|
+
end
|
1726
|
+
end
|
1727
|
+
|
1460
1728
|
it 'checks a given correct file and returns 0' do
|
1461
1729
|
create_file('example.rb', ['# encoding: utf-8',
|
1462
1730
|
'x = 0',
|
@@ -1607,8 +1875,7 @@ describe RuboCop::CLI, :isolated_environment do
|
|
1607
1875
|
])
|
1608
1876
|
expect(cli.run(['--format', 'emacs', 'example.rb'])).to eq(1)
|
1609
1877
|
expect($stdout.string)
|
1610
|
-
.to eq(
|
1611
|
-
["#{abs('example.rb')}:3:81: C: Line is too long. [95/80]",
|
1878
|
+
.to eq(["#{abs('example.rb')}:3:81: C: Line is too long. [95/80]",
|
1612
1879
|
''].join("\n"))
|
1613
1880
|
end
|
1614
1881
|
|
@@ -1622,8 +1889,7 @@ describe RuboCop::CLI, :isolated_environment do
|
|
1622
1889
|
])
|
1623
1890
|
expect(cli.run(['--format', 'emacs', 'example.rb'])).to eq(1)
|
1624
1891
|
expect($stdout.string)
|
1625
|
-
.to eq(
|
1626
|
-
["#{abs('example.rb')}:3:81: C: Line is too long. [95/80]",
|
1892
|
+
.to eq(["#{abs('example.rb')}:3:81: C: Line is too long. [95/80]",
|
1627
1893
|
''].join("\n"))
|
1628
1894
|
end
|
1629
1895
|
end
|
@@ -1867,6 +2133,31 @@ describe RuboCop::CLI, :isolated_environment do
|
|
1867
2133
|
''].join("\n"))
|
1868
2134
|
end
|
1869
2135
|
|
2136
|
+
it 'displays cop names if DisplayCopNames is true' do
|
2137
|
+
source = ['# encoding: utf-8',
|
2138
|
+
'x = 0 ',
|
2139
|
+
'puts x']
|
2140
|
+
create_file('example1.rb', source)
|
2141
|
+
|
2142
|
+
# DisplayCopNames: false inherited from config/default.yml
|
2143
|
+
create_file('.rubocop.yml', [])
|
2144
|
+
|
2145
|
+
create_file('dir/example2.rb', source)
|
2146
|
+
create_file('dir/.rubocop.yml', ['AllCops:',
|
2147
|
+
' DisplayCopNames: true'])
|
2148
|
+
|
2149
|
+
expect(cli.run(%w(--format simple))).to eq(1)
|
2150
|
+
expect($stdout.string)
|
2151
|
+
.to eq(['== example1.rb ==',
|
2152
|
+
'C: 2: 6: Trailing whitespace detected.',
|
2153
|
+
'== dir/example2.rb ==',
|
2154
|
+
'C: 2: 6: Style/TrailingWhitespace: Trailing whitespace' \
|
2155
|
+
' detected.',
|
2156
|
+
'',
|
2157
|
+
'2 files inspected, 2 offenses detected',
|
2158
|
+
''].join("\n"))
|
2159
|
+
end
|
2160
|
+
|
1870
2161
|
it 'finds included files' do
|
1871
2162
|
create_file('file.rb', 'x=0') # Included by default
|
1872
2163
|
create_file('example', 'x=0')
|
@@ -2175,8 +2466,7 @@ describe RuboCop::CLI, :isolated_environment do
|
|
2175
2466
|
' Max: 100'
|
2176
2467
|
])
|
2177
2468
|
expect(cli.run(%w(--format simple example))).to eq(1)
|
2178
|
-
expect($stdout.string).to eq(
|
2179
|
-
['== example/lib/example1.rb ==',
|
2469
|
+
expect($stdout.string).to eq(['== example/lib/example1.rb ==',
|
2180
2470
|
'C: 2: 81: Line is too long. [90/80]',
|
2181
2471
|
'',
|
2182
2472
|
'2 files inspected, 1 offense detected',
|
@@ -2421,5 +2711,19 @@ describe RuboCop::CLI, :isolated_environment do
|
|
2421
2711
|
''].join("\n"))
|
2422
2712
|
end
|
2423
2713
|
end
|
2714
|
+
|
2715
|
+
context 'when a file inherits from a higher level' do
|
2716
|
+
before do
|
2717
|
+
create_file('.rubocop.yml', ['Metrics/LineLength:',
|
2718
|
+
' Exclude:',
|
2719
|
+
' - dir/example.rb'])
|
2720
|
+
create_file('dir/.rubocop.yml', 'inherit_from: ../.rubocop.yml')
|
2721
|
+
create_file('dir/example.rb', '#' * 90)
|
2722
|
+
end
|
2723
|
+
|
2724
|
+
it 'inherits relative excludes correctly' do
|
2725
|
+
expect(cli.run([])).to eq(0)
|
2726
|
+
end
|
2727
|
+
end
|
2424
2728
|
end
|
2425
2729
|
end
|