sabat-rubocop 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +50 -0
- data/.rspec +1 -0
- data/.rubocop.yml +7 -0
- data/.travis.yml +7 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +268 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +324 -0
- data/Rakefile +29 -0
- data/bin/rubocop +22 -0
- data/config/default.yml +58 -0
- data/config/disabled.yml +5 -0
- data/config/enabled.yml +403 -0
- data/lib/rubocop.rb +116 -0
- data/lib/rubocop/cli.rb +407 -0
- data/lib/rubocop/config.rb +250 -0
- data/lib/rubocop/config_store.rb +39 -0
- data/lib/rubocop/cop/cop.rb +138 -0
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +54 -0
- data/lib/rubocop/cop/lint/end_alignment.rb +189 -0
- data/lib/rubocop/cop/lint/end_in_method.rb +30 -0
- data/lib/rubocop/cop/lint/ensure_return.rb +22 -0
- data/lib/rubocop/cop/lint/eval.rb +22 -0
- data/lib/rubocop/cop/lint/handle_exceptions.rb +20 -0
- data/lib/rubocop/cop/lint/literal_in_condition.rb +81 -0
- data/lib/rubocop/cop/lint/loop.rb +29 -0
- data/lib/rubocop/cop/lint/rescue_exception.rb +29 -0
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +34 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +35 -0
- data/lib/rubocop/cop/lint/unused_local_variable.rb +32 -0
- data/lib/rubocop/cop/lint/void.rb +58 -0
- data/lib/rubocop/cop/offence.rb +136 -0
- data/lib/rubocop/cop/rails/validation.rb +30 -0
- data/lib/rubocop/cop/style/access_control.rb +58 -0
- data/lib/rubocop/cop/style/alias.rb +28 -0
- data/lib/rubocop/cop/style/align_parameters.rb +39 -0
- data/lib/rubocop/cop/style/and_or.rb +45 -0
- data/lib/rubocop/cop/style/ascii_comments.rb +21 -0
- data/lib/rubocop/cop/style/ascii_identifiers.rb +22 -0
- data/lib/rubocop/cop/style/attr.rb +20 -0
- data/lib/rubocop/cop/style/avoid_class_vars.rb +20 -0
- data/lib/rubocop/cop/style/avoid_for.rb +18 -0
- data/lib/rubocop/cop/style/avoid_global_vars.rb +65 -0
- data/lib/rubocop/cop/style/avoid_perl_backrefs.rb +21 -0
- data/lib/rubocop/cop/style/avoid_perlisms.rb +50 -0
- data/lib/rubocop/cop/style/begin_block.rb +18 -0
- data/lib/rubocop/cop/style/block_comments.rb +20 -0
- data/lib/rubocop/cop/style/block_nesting.rb +47 -0
- data/lib/rubocop/cop/style/blocks.rb +27 -0
- data/lib/rubocop/cop/style/case_equality.rb +22 -0
- data/lib/rubocop/cop/style/case_indentation.rb +28 -0
- data/lib/rubocop/cop/style/character_literal.rb +37 -0
- data/lib/rubocop/cop/style/class_and_module_camel_case.rb +33 -0
- data/lib/rubocop/cop/style/class_methods.rb +22 -0
- data/lib/rubocop/cop/style/collection_methods.rb +56 -0
- data/lib/rubocop/cop/style/colon_method_call.rb +29 -0
- data/lib/rubocop/cop/style/constant_name.rb +31 -0
- data/lib/rubocop/cop/style/def_parentheses.rb +70 -0
- data/lib/rubocop/cop/style/documentation.rb +58 -0
- data/lib/rubocop/cop/style/dot_position.rb +25 -0
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +26 -0
- data/lib/rubocop/cop/style/empty_lines.rb +40 -0
- data/lib/rubocop/cop/style/empty_literal.rb +53 -0
- data/lib/rubocop/cop/style/encoding.rb +29 -0
- data/lib/rubocop/cop/style/end_block.rb +18 -0
- data/lib/rubocop/cop/style/end_of_line.rb +23 -0
- data/lib/rubocop/cop/style/favor_join.rb +29 -0
- data/lib/rubocop/cop/style/favor_modifier.rb +118 -0
- data/lib/rubocop/cop/style/favor_sprintf.rb +28 -0
- data/lib/rubocop/cop/style/favor_unless_over_negated_if.rb +54 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +47 -0
- data/lib/rubocop/cop/style/if_then_else.rb +29 -0
- data/lib/rubocop/cop/style/if_with_semicolon.rb +20 -0
- data/lib/rubocop/cop/style/lambda.rb +47 -0
- data/lib/rubocop/cop/style/leading_comment_space.rb +25 -0
- data/lib/rubocop/cop/style/line_continuation.rb +26 -0
- data/lib/rubocop/cop/style/line_length.rb +30 -0
- data/lib/rubocop/cop/style/method_and_variable_snake_case.rb +61 -0
- data/lib/rubocop/cop/style/method_call_parentheses.rb +22 -0
- data/lib/rubocop/cop/style/method_length.rb +57 -0
- data/lib/rubocop/cop/style/multiline_if_then.rb +47 -0
- data/lib/rubocop/cop/style/not.rb +24 -0
- data/lib/rubocop/cop/style/numeric_literals.rb +25 -0
- data/lib/rubocop/cop/style/one_line_conditional.rb +20 -0
- data/lib/rubocop/cop/style/op_method.rb +29 -0
- data/lib/rubocop/cop/style/parameter_lists.rb +42 -0
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +42 -0
- data/lib/rubocop/cop/style/proc.rb +30 -0
- data/lib/rubocop/cop/style/reduce_arguments.rb +34 -0
- data/lib/rubocop/cop/style/regexp_literal.rb +39 -0
- data/lib/rubocop/cop/style/rescue_modifier.rb +55 -0
- data/lib/rubocop/cop/style/semicolon.rb +51 -0
- data/lib/rubocop/cop/style/single_line_methods.rb +48 -0
- data/lib/rubocop/cop/style/space_after_comma_etc.rb +69 -0
- data/lib/rubocop/cop/style/space_after_control_keyword.rb +32 -0
- data/lib/rubocop/cop/style/string_literals.rb +36 -0
- data/lib/rubocop/cop/style/surrounding_space.rb +314 -0
- data/lib/rubocop/cop/style/symbol_array.rb +31 -0
- data/lib/rubocop/cop/style/symbol_name.rb +27 -0
- data/lib/rubocop/cop/style/tab.rb +25 -0
- data/lib/rubocop/cop/style/ternary_operator.rb +49 -0
- data/lib/rubocop/cop/style/trailing_whitespace.rb +24 -0
- data/lib/rubocop/cop/style/trivial_accessors.rb +32 -0
- data/lib/rubocop/cop/style/unless_else.rb +26 -0
- data/lib/rubocop/cop/style/variable_interpolation.rb +32 -0
- data/lib/rubocop/cop/style/when_then.rb +25 -0
- data/lib/rubocop/cop/style/while_until_do.rb +45 -0
- data/lib/rubocop/cop/style/word_array.rb +44 -0
- data/lib/rubocop/cop/util.rb +27 -0
- data/lib/rubocop/cop/variable_inspector.rb +280 -0
- data/lib/rubocop/formatter/base_formatter.rb +119 -0
- data/lib/rubocop/formatter/clang_style_formatter.rb +21 -0
- data/lib/rubocop/formatter/emacs_style_formatter.rb +17 -0
- data/lib/rubocop/formatter/formatter_set.rb +77 -0
- data/lib/rubocop/formatter/json_formatter.rb +76 -0
- data/lib/rubocop/formatter/progress_formatter.rb +63 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +62 -0
- data/lib/rubocop/version.rb +21 -0
- data/rubocop.gemspec +36 -0
- data/spec/.rubocop.yml +5 -0
- data/spec/project_spec.rb +24 -0
- data/spec/rubocop/cli_spec.rb +906 -0
- data/spec/rubocop/config_spec.rb +470 -0
- data/spec/rubocop/config_store_spec.rb +66 -0
- data/spec/rubocop/cops/cop_spec.rb +38 -0
- data/spec/rubocop/cops/lint/assignment_in_condition_spec.rb +111 -0
- data/spec/rubocop/cops/lint/end_alignment_spec.rb +333 -0
- data/spec/rubocop/cops/lint/end_in_method_spec.rb +35 -0
- data/spec/rubocop/cops/lint/ensure_return_spec.rb +37 -0
- data/spec/rubocop/cops/lint/eval_spec.rb +41 -0
- data/spec/rubocop/cops/lint/handle_exceptions_spec.rb +36 -0
- data/spec/rubocop/cops/lint/literal_in_condition_spec.rb +42 -0
- data/spec/rubocop/cops/lint/loop_spec.rb +33 -0
- data/spec/rubocop/cops/lint/rescue_exception_spec.rb +127 -0
- data/spec/rubocop/cops/lint/shadowing_outer_local_variable_spec.rb +243 -0
- data/spec/rubocop/cops/lint/unreachable_code_spec.rb +69 -0
- data/spec/rubocop/cops/lint/unused_local_variable_spec.rb +497 -0
- data/spec/rubocop/cops/lint/void_spec.rb +63 -0
- data/spec/rubocop/cops/offence_spec.rb +133 -0
- data/spec/rubocop/cops/rails/validation_spec.rb +27 -0
- data/spec/rubocop/cops/style/access_control_spec.rb +142 -0
- data/spec/rubocop/cops/style/alias_spec.rb +47 -0
- data/spec/rubocop/cops/style/align_parameters_spec.rb +199 -0
- data/spec/rubocop/cops/style/and_or_spec.rb +39 -0
- data/spec/rubocop/cops/style/ascii_comments_spec.rb +28 -0
- data/spec/rubocop/cops/style/ascii_identifiers_spec.rb +28 -0
- data/spec/rubocop/cops/style/attr_spec.rb +20 -0
- data/spec/rubocop/cops/style/avoid_class_vars_spec.rb +27 -0
- data/spec/rubocop/cops/style/avoid_for_spec.rb +37 -0
- data/spec/rubocop/cops/style/avoid_global_vars_spec.rb +34 -0
- data/spec/rubocop/cops/style/avoid_perl_backrefs_spec.rb +20 -0
- data/spec/rubocop/cops/style/avoid_perlisms_spec.rb +47 -0
- data/spec/rubocop/cops/style/begin_block_spec.rb +19 -0
- data/spec/rubocop/cops/style/block_comments_spec.rb +27 -0
- data/spec/rubocop/cops/style/block_nesting_spec.rb +159 -0
- data/spec/rubocop/cops/style/blocks_spec.rb +35 -0
- data/spec/rubocop/cops/style/case_equality_spec.rb +18 -0
- data/spec/rubocop/cops/style/case_indentation_spec.rb +88 -0
- data/spec/rubocop/cops/style/character_literal_spec.rb +28 -0
- data/spec/rubocop/cops/style/class_and_module_camel_case_spec.rb +46 -0
- data/spec/rubocop/cops/style/class_methods_spec.rb +51 -0
- data/spec/rubocop/cops/style/collection_methods_spec.rb +41 -0
- data/spec/rubocop/cops/style/colon_method_call_spec.rb +55 -0
- data/spec/rubocop/cops/style/constant_name_spec.rb +56 -0
- data/spec/rubocop/cops/style/def_with_parentheses_spec.rb +40 -0
- data/spec/rubocop/cops/style/def_without_parentheses_spec.rb +34 -0
- data/spec/rubocop/cops/style/documentation_spec.rb +79 -0
- data/spec/rubocop/cops/style/dot_position_spec.rb +30 -0
- data/spec/rubocop/cops/style/empty_line_between_defs_spec.rb +85 -0
- data/spec/rubocop/cops/style/empty_lines_spec.rb +40 -0
- data/spec/rubocop/cops/style/empty_literal_spec.rb +91 -0
- data/spec/rubocop/cops/style/encoding_spec.rb +49 -0
- data/spec/rubocop/cops/style/end_block_spec.rb +19 -0
- data/spec/rubocop/cops/style/end_of_line_spec.rb +25 -0
- data/spec/rubocop/cops/style/favor_join_spec.rb +37 -0
- data/spec/rubocop/cops/style/favor_modifier_spec.rb +160 -0
- data/spec/rubocop/cops/style/favor_sprintf_spec.rb +53 -0
- data/spec/rubocop/cops/style/favor_unless_over_negated_if_spec.rb +64 -0
- data/spec/rubocop/cops/style/favor_until_over_negated_while_spec.rb +47 -0
- data/spec/rubocop/cops/style/hash_syntax_spec.rb +51 -0
- data/spec/rubocop/cops/style/if_with_semicolon_spec.rb +25 -0
- data/spec/rubocop/cops/style/lambda_spec.rb +45 -0
- data/spec/rubocop/cops/style/leading_comment_space_spec.rb +65 -0
- data/spec/rubocop/cops/style/line_continuation_spec.rb +26 -0
- data/spec/rubocop/cops/style/line_length_spec.rb +25 -0
- data/spec/rubocop/cops/style/method_and_variable_snake_case_spec.rb +95 -0
- data/spec/rubocop/cops/style/method_call_parentheses_spec.rb +25 -0
- data/spec/rubocop/cops/style/method_length_spec.rb +151 -0
- data/spec/rubocop/cops/style/multiline_if_then_spec.rb +97 -0
- data/spec/rubocop/cops/style/not_spec.rb +28 -0
- data/spec/rubocop/cops/style/numeric_literals_spec.rb +51 -0
- data/spec/rubocop/cops/style/one_line_conditional_spec.rb +18 -0
- data/spec/rubocop/cops/style/op_method_spec.rb +80 -0
- data/spec/rubocop/cops/style/parameter_lists_spec.rb +49 -0
- data/spec/rubocop/cops/style/parentheses_around_condition_spec.rb +59 -0
- data/spec/rubocop/cops/style/proc_spec.rb +28 -0
- data/spec/rubocop/cops/style/reduce_arguments_spec.rb +59 -0
- data/spec/rubocop/cops/style/regexp_literal_spec.rb +83 -0
- data/spec/rubocop/cops/style/rescue_modifier_spec.rb +122 -0
- data/spec/rubocop/cops/style/semicolon_spec.rb +95 -0
- data/spec/rubocop/cops/style/single_line_methods_spec.rb +54 -0
- data/spec/rubocop/cops/style/space_after_colon_spec.rb +29 -0
- data/spec/rubocop/cops/style/space_after_comma_spec.rb +31 -0
- data/spec/rubocop/cops/style/space_after_control_keyword_spec.rb +69 -0
- data/spec/rubocop/cops/style/space_after_semicolon_spec.rb +24 -0
- data/spec/rubocop/cops/style/space_around_braces_spec.rb +49 -0
- data/spec/rubocop/cops/style/space_around_equals_in_default_parameter_spec.rb +34 -0
- data/spec/rubocop/cops/style/space_around_operators_spec.rb +216 -0
- data/spec/rubocop/cops/style/space_inside_brackets_spec.rb +51 -0
- data/spec/rubocop/cops/style/space_inside_hash_literal_braces_spec.rb +99 -0
- data/spec/rubocop/cops/style/space_inside_parens_spec.rb +33 -0
- data/spec/rubocop/cops/style/string_literals_spec.rb +62 -0
- data/spec/rubocop/cops/style/symbol_array_spec.rb +45 -0
- data/spec/rubocop/cops/style/symbol_name_spec.rb +122 -0
- data/spec/rubocop/cops/style/tab_spec.rb +23 -0
- data/spec/rubocop/cops/style/ternary_operator_spec.rb +42 -0
- data/spec/rubocop/cops/style/trailing_whitespace_spec.rb +29 -0
- data/spec/rubocop/cops/style/trivial_accessors_spec.rb +338 -0
- data/spec/rubocop/cops/style/unless_else_spec.rb +31 -0
- data/spec/rubocop/cops/style/variable_interpolation_spec.rb +53 -0
- data/spec/rubocop/cops/style/when_then_spec.rb +40 -0
- data/spec/rubocop/cops/style/while_until_do_spec.rb +47 -0
- data/spec/rubocop/cops/style/word_array_spec.rb +61 -0
- data/spec/rubocop/cops/variable_inspector_spec.rb +374 -0
- data/spec/rubocop/formatter/base_formatter_spec.rb +190 -0
- data/spec/rubocop/formatter/clang_style_formatter_spec.rb +70 -0
- data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +32 -0
- data/spec/rubocop/formatter/formatter_set_spec.rb +132 -0
- data/spec/rubocop/formatter/json_formatter_spec.rb +142 -0
- data/spec/rubocop/formatter/progress_formatter_spec.rb +196 -0
- data/spec/rubocop/formatter/simple_text_formatter_spec.rb +74 -0
- data/spec/spec_helper.rb +92 -0
- data/spec/support/file_helper.rb +21 -0
- data/spec/support/isolated_environment.rb +27 -0
- data/spec/support/mri_syntax_checker.rb +69 -0
- data/spec/support/shared_examples.rb +33 -0
- metadata +517 -0
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
Gemfile.lock
|
15
|
+
|
16
|
+
# jeweler generated
|
17
|
+
pkg
|
18
|
+
|
19
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
20
|
+
#
|
21
|
+
# * Create a file at ~/.gitignore
|
22
|
+
# * Include files you want ignored
|
23
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
24
|
+
#
|
25
|
+
# After doing this, these files will be ignored in all your git projects,
|
26
|
+
# saving you from having to 'pollute' every project you touch with them
|
27
|
+
#
|
28
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
29
|
+
#
|
30
|
+
# For MacOS:
|
31
|
+
#
|
32
|
+
#.DS_Store
|
33
|
+
|
34
|
+
# For TextMate
|
35
|
+
#*.tmproj
|
36
|
+
#tmtags
|
37
|
+
|
38
|
+
# For emacs:
|
39
|
+
#*~
|
40
|
+
#\#*
|
41
|
+
#.\#*
|
42
|
+
|
43
|
+
# For vim:
|
44
|
+
#*.swp
|
45
|
+
|
46
|
+
# For redcar:
|
47
|
+
#.redcar
|
48
|
+
|
49
|
+
# For rubinius:
|
50
|
+
#*.rbc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,268 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## master (unreleased)
|
4
|
+
|
5
|
+
### New features
|
6
|
+
|
7
|
+
* Added `-l/--lint` option to allow doing only linting with no style checks (similar to running `ruby -wc`).
|
8
|
+
|
9
|
+
### Changes
|
10
|
+
|
11
|
+
* Removed the `BlockAlignSchema` configuration option from `EndAlignment`. We now support only the default alignment schema - `StartOfAssignment`.
|
12
|
+
|
13
|
+
### Bugs fixed
|
14
|
+
|
15
|
+
* [#318](https://github.com/bbatsov/rubocop/issues/318) - correct some special cases of block end alignment
|
16
|
+
* [#317](https://github.com/bbatsov/rubocop/issues/317) - fix a false positive in `LiteralInCondition`
|
17
|
+
* [#321](https://github.com/bbatsov/rubocop/issues/321) - Ignore variables whose name start with `_` in `ShadowingOuterLocalVariable`
|
18
|
+
* [#322](https://github.com/bbatsov/rubocop/issues/322) - Fix exception of `UnusedLocalVariable` and `ShadowingOuterLocalVariable` when inspecting keyword splat argument
|
19
|
+
* [#316](https://github.com/bbatsov/rubocop/issues/316) - Correct nested postfix unless in `MultilineIfThen`
|
20
|
+
* [#327](https://github.com/bbatsov/rubocop/issues/327) - Fix false offences for block expression that spawn on two lines in `EndAlignment`
|
21
|
+
|
22
|
+
## 0.9.0 (01/07/2013)
|
23
|
+
|
24
|
+
### New features
|
25
|
+
|
26
|
+
* Introduced formatter feature, enables custom formatted output and multiple outputs.
|
27
|
+
* Added progress formatter and now it's the default. (`--format progress`)
|
28
|
+
* Added JSON formatter. (`--format json`)
|
29
|
+
* Added clang style formatter showing the offending source
|
30
|
+
code. (`--format clang`). The `clang` formatter marks a whole range
|
31
|
+
rather than just the starting position, to indicate more clearly
|
32
|
+
where the problem is.
|
33
|
+
* Added `-f`/`--format` option to specify formatter.
|
34
|
+
* Added `-o`/`--out` option to specify output file for each formatter.
|
35
|
+
* Added `-r/--require` option to inject external Ruby code into RuboCop.
|
36
|
+
* Added `-V/--verbose-version` option that displays Parser version and Ruby version as well.
|
37
|
+
* Added `-R/--rails` option that enables extra Rails-specific cops.
|
38
|
+
* Added support for auto-correction of some offences with `-a`/`--auto-correct`.
|
39
|
+
* New cop `CaseEquality` checks for explicit use of `===`
|
40
|
+
* New cop `AssignmentInCondition` checks for assignment in conditions.
|
41
|
+
* New cop `EndAlignment` tracks misaligned `end` keywords.
|
42
|
+
* New cop `Void` tracks uses of literals/variables/operators in possibly void context.
|
43
|
+
* New cop `Documentation` checks for top level class/module doc comments.
|
44
|
+
* New cop `UnreachableCode` tracks unreachable code segments.
|
45
|
+
* New cop `MethodCallParentheses` tracks unwanted braces in method calls.
|
46
|
+
* New cop `UnusedLocalVariable` tracks unused local variables for each scope.
|
47
|
+
* New cop `ShadowingOuterLocalVariable` tracks use of the same name as outer local variables for block arguments or block local variables.
|
48
|
+
* New cop `WhileUntilDo` tracks uses of `do` with multi-line `while/until`.
|
49
|
+
* New cop `CharacterLiteral` tracks uses of character literals (`?x`).
|
50
|
+
* New cop `EndInMethod` tracks uses of `END` in method definitions.
|
51
|
+
* New cop `LiteralInCondition` tracks uses of literals in the conditions of `if/while/until`.
|
52
|
+
* New cop `BeginBlock` tracks uses of `BEGIN` blocks.
|
53
|
+
* New cop `EndBlock` tracks uses of `END` blocks.
|
54
|
+
* New cop `DotPosition` tracks the dot position in multi-line method calls.
|
55
|
+
* New cop `Attr` tracks uses of `Module#attr`.
|
56
|
+
|
57
|
+
### Changes
|
58
|
+
|
59
|
+
* Deprecated `-e`/`--emacs` option. (Use `--format emacs` instead)
|
60
|
+
* Made `progress` formatter the default.
|
61
|
+
* Most formatters (`progress`, `simple` and `clang`) now print relative file paths if the paths are under the current working directory.
|
62
|
+
* Migrate all cops to new namespaces. `Rubocop::Cop::Lint` is for cops that emit warnings. `Rubocop::Cop::Style` is for cops that do not belong in other namespaces.
|
63
|
+
* Merge `FavorPercentR` and `PercentR` into one cop called `RegexpLiteral`, and add configuration parameter `MaxSlashes`.
|
64
|
+
* Add `CountKeywordArgs` configuration option to `ParameterLists` cop.
|
65
|
+
|
66
|
+
### Bugs fixed
|
67
|
+
|
68
|
+
* [#239](https://github.com/bbatsov/rubocop/issues/239) - fixed double quotes false positives
|
69
|
+
* [#233](https://github.com/bbatsov/rubocop/issues/233) - report syntax cop offences
|
70
|
+
* Fix off-by-one error in favor_modifier.
|
71
|
+
* [#229](https://github.com/bbatsov/rubocop/issues/229) - recognize a line with CR+LF as a blank line in AccessControl cop.
|
72
|
+
* [#235](https://github.com/bbatsov/rubocop/issues/235) - handle multiple constant assignment in ConstantName cop
|
73
|
+
* [#246](https://github.com/bbatsov/rubocop/issues/246) - correct handling of unicode escapes within double quotes
|
74
|
+
* Fix crashes in Blocks, CaseEquality, CaseIndentation, ClassAndModuleCamelCase, ClassMethods, CollectionMethods, and ColonMethodCall.
|
75
|
+
* [#263](https://github.com/bbatsov/rubocop/issues/263) - do not check for space around operators called with method syntax
|
76
|
+
* [#271](https://github.com/bbatsov/rubocop/issues/271) - always allow line breaks inside hash literal braces
|
77
|
+
* [#270](https://github.com/bbatsov/rubocop/issues/270) - fixed a false positive in ParenthesesAroundCondition
|
78
|
+
* [#288](https://github.com/bbatsov/rubocop/issues/288) - get config parameter AllCops/Excludes from highest config file in path
|
79
|
+
* [#276](https://github.com/bbatsov/rubocop/issues/276) - let columns start at 1 instead of 0 in all output of column numbers
|
80
|
+
* [#292](https://github.com/bbatsov/rubocop/issues/292) - don't check non-regular files (like sockets, etc)
|
81
|
+
* Fix crashes in WordArray on arrays of character literals such as `[?\r, ?\n]`
|
82
|
+
* Fix crashes in Documentation on empty modules
|
83
|
+
|
84
|
+
## 0.8.3 (18/06/2013)
|
85
|
+
|
86
|
+
### Bug fixes
|
87
|
+
|
88
|
+
* Lock Parser dependency to version 2.0.0.beta5.
|
89
|
+
|
90
|
+
## 0.8.2 (06/05/2013)
|
91
|
+
|
92
|
+
### New features
|
93
|
+
|
94
|
+
* New cop `BlockNesting` checks for excessive block nesting
|
95
|
+
|
96
|
+
### Bug fixes
|
97
|
+
|
98
|
+
* Correct calculation of whether a modifier version of a conditional statement will fit.
|
99
|
+
* Fix an error in `MultilineIfThen` cop that occurred in some special cases.
|
100
|
+
* [#231](https://github.com/bbatsov/rubocop/issues/231) - fix a false positive for modifier if
|
101
|
+
|
102
|
+
## 0.8.1 (05/30/2013)
|
103
|
+
|
104
|
+
### New features
|
105
|
+
|
106
|
+
* New cop `Proc` tracks uses of `Proc.new`
|
107
|
+
|
108
|
+
### Changes
|
109
|
+
|
110
|
+
* Renamed `NewLambdaLiteral` to `Lambda`.
|
111
|
+
* Aligned the `Lambda` cop more closely to the style guide - it now
|
112
|
+
allows the use of `lambda` for multi-line blocks.
|
113
|
+
|
114
|
+
### Bugs fixed
|
115
|
+
|
116
|
+
* [#210](https://github.com/bbatsov/rubocop/issues/210) - fix a false positive for double quotes in regexp literals
|
117
|
+
* [#211](https://github.com/bbatsov/rubocop/issues/211) - fix a false positive for `initialize` method looking like a trivial writer
|
118
|
+
* [#215](https://github.com/bbatsov/rubocop/issues/215) - Fixed a lot of modifier `if/unless/while/until` issues
|
119
|
+
* [#213](https://github.com/bbatsov/rubocop/issues/213) - Make sure even disabled cops get their configuration set
|
120
|
+
* [#214](https://github.com/bbatsov/rubocop/issues/214) - Fix SpaceInsideHashLiteralBraces to handle string interpolation right
|
121
|
+
|
122
|
+
## 0.8.0 (05/28/2013)
|
123
|
+
|
124
|
+
### Changes
|
125
|
+
|
126
|
+
* Folded `ArrayLiteral` and `HashLiteral` into `EmptyLiteral` cop
|
127
|
+
* The maximum number of params `ParameterLists` accepts in now configurable
|
128
|
+
* Reworked `SymbolSnakeCase` into `SymbolName`, which has an option `AllowCamelCase` enabled by default.
|
129
|
+
* Migrated from `Ripper` to the portable [Parser](https://github.com/whitequark/parser).
|
130
|
+
|
131
|
+
### New features
|
132
|
+
|
133
|
+
* New cop `ConstantName` checks for constant which are not using `SCREAMING_SNAKE_CASE`.
|
134
|
+
* New cop `AccessControl` checks private/protected indentation and surrounding blank lines.
|
135
|
+
* New cop `Loop` checks for `begin/end/while(until)` and suggests the use of `Kernel#loop`.
|
136
|
+
|
137
|
+
## 0.7.2 (05/13/2013)
|
138
|
+
|
139
|
+
### Bugs fixed
|
140
|
+
|
141
|
+
* [#155](https://github.com/bbatsov/rubocop/issues/155) 'Do not use semicolons to terminate expressions.' is not implemented correctly
|
142
|
+
* `OpMethod` now handles definition of unary operators without crashing.
|
143
|
+
* `SymbolSnakeCase` now handles aliasing of operators without crashing.
|
144
|
+
* `RescueException` now handles the splat operator `*` in a `rescue` clause without crashing.
|
145
|
+
* [#159](https://github.com/bbatsov/rubocop/issues/159) AvoidFor cop misses many violations
|
146
|
+
|
147
|
+
## 0.7.1 (05/11/2013)
|
148
|
+
|
149
|
+
### Bugs fixed
|
150
|
+
|
151
|
+
* Added missing files to the gemspec
|
152
|
+
|
153
|
+
## 0.7.0 (05/11/2013)
|
154
|
+
|
155
|
+
### New features
|
156
|
+
|
157
|
+
* Added ability to include or exclude files/directories through `.rubocop.yml`
|
158
|
+
* Added option --only for running a single cop.
|
159
|
+
* Relax semicolon rule for one line methods, classes and modules
|
160
|
+
* Configuration files, such as `.rubocop.yml`, can now include configuration from other files through the `inherit_from` directive. All configuration files implicitly inherit from `config/default.yml`.
|
161
|
+
* New cop `ClassMethods` checks for uses for class/module names in definitions of class/module methods
|
162
|
+
* New cop `SingleLineMethods` checks for methods implemented on a single line
|
163
|
+
* New cop `FavorJoin` checks for usages of `Array#*` with a string argument
|
164
|
+
* New cop `BlockComments` tracks uses of block comments(`=begin/=end` comments)
|
165
|
+
* New cop `EmptyLines` tracks consecutive blank lines
|
166
|
+
* New cop `WordArray` tracks arrays of words.
|
167
|
+
* [#108](https://github.com/bbatsov/rubocop/issues/108) New cop `SpaceInsideHashLiteralBraces` checks for spaces inside hash literal braces - style is configurable
|
168
|
+
* New cop `LineContinuation` tracks uses of the line continuation character (`\`)
|
169
|
+
* New cop `SymbolArray` tracks arrays of symbols.
|
170
|
+
* Print warnings for unrecognized names in configuration files.
|
171
|
+
* New cop `TrivialAccessors` tracks method definitions that could be automatically generated with `attr_*` methods.
|
172
|
+
* New cop `LeadingCommentSpace` checks for missing space after `#` in comments.
|
173
|
+
* New cop `ColonMethodCall` tracks uses of `::` for method calls.
|
174
|
+
* New cop `AvoidGlobalVars` tracks uses of non built-in global variables.
|
175
|
+
* New cop `SpaceAfterControlKeyword` tracks missing spaces after `if/elsif/case/when/until/unless/while`.
|
176
|
+
* New cop `Not` tracks uses of the `not` keyword.
|
177
|
+
* New cop `Eval` tracks uses of the `eval` function.
|
178
|
+
|
179
|
+
### Bugs fixed
|
180
|
+
|
181
|
+
* [#101](https://github.com/bbatsov/rubocop/issues/101) `SpaceAroundEqualsInParameterDefault` doesn't work properly with empty string
|
182
|
+
* Fix `BraceAfterPercent` for `%W`, `%i` and `%I` and added more tests
|
183
|
+
* Fix a false positive in the `Alias` cop. `:alias` is no longer treated as keyword
|
184
|
+
* `ArrayLiteral` now properly detects `Array.new`
|
185
|
+
* `HashLiteral` now properly detects `Hash.new`
|
186
|
+
* `VariableInterpolation` now detects regexp back references and doesn't crash.
|
187
|
+
* Don't generate pathnames like some/project//some.rb
|
188
|
+
* [#151](https://github.com/bbatsov/rubocop/issues/151) Don't print the unrecognized cop warning several times for the same `.rubocop.yml`
|
189
|
+
|
190
|
+
### Misc
|
191
|
+
|
192
|
+
* Renamed `Indentation` cop to `CaseIndentation` to avoid confusion
|
193
|
+
* Renamed `EmptyLines` cop to `EmptyLineBetweenDefs` to avoid confusion
|
194
|
+
|
195
|
+
## 0.6.1 (04/28/2013)
|
196
|
+
|
197
|
+
### New features
|
198
|
+
|
199
|
+
* Split `AsciiIdentifiersAndComments` cop in two separate cops
|
200
|
+
|
201
|
+
### Bugs fixed
|
202
|
+
|
203
|
+
* [#90](https://github.com/bbatsov/rubocop/issues/90) Two cops crash when scanning code using `super`
|
204
|
+
* [#93](https://github.com/bbatsov/rubocop/issues/93) Issue with `whitespace?': undefined method`
|
205
|
+
* [#97](https://github.com/bbatsov/rubocop/issues/97) Build fails
|
206
|
+
* [#100](https://github.com/bbatsov/rubocop/issues/100) `OpMethod` cop doesn't work if method arg is not in braces
|
207
|
+
* `SymbolSnakeCase` now tracks Ruby 1.9 hash labels as well as regular symbols
|
208
|
+
|
209
|
+
### Misc
|
210
|
+
|
211
|
+
* [#88](https://github.com/bbatsov/rubocop/issues/88) Abort gracefully when interrupted with Ctrl-C
|
212
|
+
* No longer crashes on bugs within cops. Now problematic checks are skipped and a message is displayed.
|
213
|
+
* Replaced `Term::ANSIColor` with `Rainbow`.
|
214
|
+
* Add an option to disable colors in the output.
|
215
|
+
* Cop names are now displayed alongside messages when `-d/--debug` is passed.
|
216
|
+
|
217
|
+
## 0.6.0 (04/23/2013)
|
218
|
+
|
219
|
+
### New features
|
220
|
+
|
221
|
+
* New cop `ReduceArguments` tracks argument names in reduce calls
|
222
|
+
* New cop `MethodLength` tracks number of LOC (lines of code) in methods
|
223
|
+
* New cop `RescueModifier` tracks uses of `rescue` in modifier form.
|
224
|
+
* New cop `PercentLiterals` tracks uses of `%q`, `%Q`, `%s` and `%x`.
|
225
|
+
* New cop `BraceAfterPercent` tracks uses of % literals with
|
226
|
+
delimiters other than ().
|
227
|
+
* Support for disabling cops locally in a file with rubocop:disable comments.
|
228
|
+
* New cop `EnsureReturn` tracks usages of `return` in `ensure` blocks.
|
229
|
+
* New cop `HandleExceptions` tracks suppressed exceptions.
|
230
|
+
* New cop `AsciiIdentifiersAndComments` tracks uses of non-ascii
|
231
|
+
characters in identifiers and comments.
|
232
|
+
* New cop `RescueException` tracks uses of rescuing the `Exception` class.
|
233
|
+
* New cop `ArrayLiteral` tracks uses of Array.new.
|
234
|
+
* New cop `HashLiteral` tracks uses of Hash.new.
|
235
|
+
* New cop `OpMethod` tracks the argument name in operator methods.
|
236
|
+
* New cop `PercentR` tracks uses of %r literals with zero or one slash in the regexp.
|
237
|
+
* New cop `FavorPercentR` tracks uses of // literals with more than one slash in the regexp.
|
238
|
+
|
239
|
+
### Bugs fixed
|
240
|
+
|
241
|
+
* [#62](https://github.com/bbatsov/rubocop/issues/62) - Config files in ancestor directories are ignored if another exists in home directory
|
242
|
+
* [#65](https://github.com/bbatsov/rubocop/issues/65) - Suggests to convert symbols `:==`, `:<=>` and the like to snake_case
|
243
|
+
* [#66](https://github.com/bbatsov/rubocop/issues/66) - Does not crash on unreadable or unparseable files
|
244
|
+
* [#70](https://github.com/bbatsov/rubocop/issues/70) - Support `alias` with bareword arguments
|
245
|
+
* [#64](https://github.com/bbatsov/rubocop/issues/64) - Performance issue with Bundler
|
246
|
+
* [#75](https://github.com/bbatsov/rubocop/issues/75) - Make it clear that some global variables require the use of the English library
|
247
|
+
* [#79](https://github.com/bbatsov/rubocop/issues/79) - Ternary operator missing whitespace detection
|
248
|
+
|
249
|
+
### Misc
|
250
|
+
|
251
|
+
* Dropped Jeweler for gem release management since it's no longer
|
252
|
+
actively maintained.
|
253
|
+
* Handle pluralization properly in the final summary.
|
254
|
+
|
255
|
+
## 0.5.0 (04/17/2013)
|
256
|
+
|
257
|
+
### New features
|
258
|
+
|
259
|
+
* New cop `FavorSprintf` that checks for usages of `String#%`
|
260
|
+
* New cop `Semicolon` that checks for usages of `;` as expression separator
|
261
|
+
* New cop `VariableInterpolation` that checks for variable interpolation in double quoted strings
|
262
|
+
* New cop `Alias` that checks for uses of the keyword `alias`
|
263
|
+
* Automatically detect extensionless Ruby files with shebangs when search for Ruby source files in a directory
|
264
|
+
|
265
|
+
### Bugs fixed
|
266
|
+
|
267
|
+
* [#59](https://github.com/bbatsov/rubocop/issues/59) - Interpolated variables not enclosed in braces are not noticed
|
268
|
+
* [#42](https://github.com/bbatsov/rubocop/issues/42) - Received malformed format string ArgumentError from rubocop
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Contributing to RuboCop
|
2
|
+
|
3
|
+
* Check out the latest master to make sure the feature hasn't been
|
4
|
+
implemented or the bug hasn't been fixed yet.
|
5
|
+
* Check out the issue tracker to make sure someone already hasn't
|
6
|
+
requested it and/or contributed it.
|
7
|
+
* Fork the project.
|
8
|
+
* Start a feature/bugfix branch.
|
9
|
+
* Commit and push until you are happy with your contribution.
|
10
|
+
* Make sure to add tests for it. This is important so I don't break it
|
11
|
+
in a future version unintentionally.
|
12
|
+
* Update the [Changelog](CHANGELOG.md) accordingly.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If
|
14
|
+
you want to have your own version, or is otherwise necessary, that
|
15
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
16
|
+
around it.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Bozhidar Batsov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,324 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/rubocop.png)](http://badge.fury.io/rb/rubocop)
|
2
|
+
[![Build Status](https://travis-ci.org/bbatsov/rubocop.png?branch=master)](https://travis-ci.org/bbatsov/rubocop)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/bbatsov/rubocop/badge.png?branch=master)](https://coveralls.io/r/bbatsov/rubocop)
|
4
|
+
|
5
|
+
# RuboCop
|
6
|
+
|
7
|
+
> Role models are important. <br/>
|
8
|
+
> -- Officer Alex J. Murphy / RoboCop
|
9
|
+
|
10
|
+
**RuboCop** is a Ruby code style checker based on the
|
11
|
+
[Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide).
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
**RuboCop**'s installation is pretty standard:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ gem install rubocop
|
19
|
+
```
|
20
|
+
|
21
|
+
## Basic Usage
|
22
|
+
|
23
|
+
Running `rubocop` with no arguments will check all Ruby source files
|
24
|
+
in the current folder:
|
25
|
+
|
26
|
+
```bash
|
27
|
+
$ rubocop
|
28
|
+
```
|
29
|
+
|
30
|
+
Alternatively you can pass `rubocop` a list of files and folders to check:
|
31
|
+
|
32
|
+
```bash
|
33
|
+
$ rubocop app spec lib/something.rb
|
34
|
+
```
|
35
|
+
|
36
|
+
For more details check the available command-line options:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
$ rubocop -h
|
40
|
+
```
|
41
|
+
|
42
|
+
Command flag | Description
|
43
|
+
-----------------------|------------------------------------------------------------
|
44
|
+
`-v/--version` | Displays the current version and exits
|
45
|
+
`-V/--verbose-version` | Displays the current version plus the version of Parser and Ruby
|
46
|
+
`-d/--debug` | Displays some extra debug output
|
47
|
+
`-c/--config` | Run with specified config file
|
48
|
+
`-f/--format` | Choose a formatter
|
49
|
+
`-o/--out` | Write output to a file instead of STDOUT
|
50
|
+
`-r/--require` | Require Ruby file
|
51
|
+
`-R/--rails` | Run extra Rails cops
|
52
|
+
`-l/--lint` | Run only lint cops
|
53
|
+
`-a/--auto-correct` | Auto-correct certain offences.
|
54
|
+
`-s/--silent` | Suppress the final summary
|
55
|
+
`--only` | Run only the specified cop
|
56
|
+
|
57
|
+
## Configuration
|
58
|
+
|
59
|
+
The behavior of RuboCop can be controlled via the
|
60
|
+
[.rubocop.yml](https://github.com/bbatsov/rubocop/blob/master/.rubocop.yml)
|
61
|
+
configuration file. The file can be placed either in your home folder
|
62
|
+
or in some project folder.
|
63
|
+
|
64
|
+
RuboCop will start looking for the configuration file in the directory
|
65
|
+
where the inspected file is and continue its way up to the root folder.
|
66
|
+
|
67
|
+
The file has the following format:
|
68
|
+
|
69
|
+
```yaml
|
70
|
+
inherit_from: ../.rubocop.yml
|
71
|
+
|
72
|
+
Encoding:
|
73
|
+
Enabled: true
|
74
|
+
|
75
|
+
LineLength:
|
76
|
+
Enabled: true
|
77
|
+
Max: 79
|
78
|
+
```
|
79
|
+
|
80
|
+
It allows to enable/disable certain cops (checks) and to alter their
|
81
|
+
behavior if they accept any parameters.
|
82
|
+
|
83
|
+
The optional `inherit_from` directive is used to include configuration
|
84
|
+
from one or more files. This makes it possible to have the common
|
85
|
+
project settings in the `.rubocop.yml` file at the project root, and
|
86
|
+
then only the deviations from those rules in the subdirectories. The
|
87
|
+
included files can be given with absolute paths or paths relative to
|
88
|
+
the file where they are referenced. The settings after an
|
89
|
+
`inherit_from` directive override any settings in the included
|
90
|
+
file(s). When multiple files are included, the first file in the list
|
91
|
+
has the lowest precedence and the last one has the highest. The format
|
92
|
+
for multiple inclusion is:
|
93
|
+
|
94
|
+
```yaml
|
95
|
+
inherit_from:
|
96
|
+
- ../.rubocop.yml
|
97
|
+
- ../conf/.rubocop.yml
|
98
|
+
```
|
99
|
+
|
100
|
+
### Defaults
|
101
|
+
|
102
|
+
The file `config/default.yml` under the RuboCop home directory
|
103
|
+
contains the default settings that all configurations inherit
|
104
|
+
from. Project and personal `.rubocop.yml` files need only make
|
105
|
+
settings that are different from the default ones. If there is no
|
106
|
+
`.rubocop.yml` file in the project or home directory,
|
107
|
+
`config/default.yml` will be used.
|
108
|
+
|
109
|
+
### Disabling Cops within Source Code
|
110
|
+
|
111
|
+
One or more individual cops can be disabled locally in a section of a
|
112
|
+
file by adding a comment such as
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
# rubocop:disable LineLength, StringLiterals
|
116
|
+
[...]
|
117
|
+
# rubocop:enable LineLength, StringLiterals
|
118
|
+
```
|
119
|
+
|
120
|
+
You can also disable *all* cops with
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
# rubocop:disable all
|
124
|
+
[...]
|
125
|
+
# rubocop:enable all
|
126
|
+
```
|
127
|
+
|
128
|
+
One or more cops can be disabled on a single line with an end-of-line
|
129
|
+
comment.
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
for x in (0..19) # rubocop:disable AvoidFor
|
133
|
+
```
|
134
|
+
|
135
|
+
### Including/Excluding files
|
136
|
+
|
137
|
+
RuboCop checks all files recursively within the directory it is run
|
138
|
+
on. However, it does not recognize some files as Ruby(only files
|
139
|
+
ending with `.rb` or extensionless files with a `#!.*ruby` declaration
|
140
|
+
are automatically detected) files, and if you'd like it to check these
|
141
|
+
you'll need to manually pass them in. Files and directories can
|
142
|
+
also be ignored through `.rubocop.yml`.
|
143
|
+
|
144
|
+
Here is an example that might be used for a Rails project:
|
145
|
+
|
146
|
+
```yaml
|
147
|
+
AllCops:
|
148
|
+
Includes:
|
149
|
+
- Rakefile
|
150
|
+
- config.ru
|
151
|
+
Excludes:
|
152
|
+
- db/**
|
153
|
+
- config/**
|
154
|
+
- script/**
|
155
|
+
|
156
|
+
# other configuration
|
157
|
+
# ...
|
158
|
+
```
|
159
|
+
|
160
|
+
Note: Files and directories are specified relative to the
|
161
|
+
`.rubocop.yml` file. The `Excludes` parameter is special. It is valid
|
162
|
+
for the directory tree starting where it is defined. It is not
|
163
|
+
shadowed by the setting of `Excludes` in other `.rubocop.yml` files in
|
164
|
+
subdirectories.
|
165
|
+
|
166
|
+
## Formatters
|
167
|
+
|
168
|
+
### JSON Formatter
|
169
|
+
|
170
|
+
You can get RuboCop's inspection result in JSON format by passing `--format json` option in command line.
|
171
|
+
The JSON structure is like the following example:
|
172
|
+
|
173
|
+
```javascript
|
174
|
+
{
|
175
|
+
"metadata": {
|
176
|
+
"rubocop_version": "0.9.0",
|
177
|
+
"ruby_engine": "ruby",
|
178
|
+
"ruby_version": "2.0.0",
|
179
|
+
"ruby_patchlevel": "195",
|
180
|
+
"ruby_platform": "x86_64-darwin12.3.0"
|
181
|
+
},
|
182
|
+
"files": [{
|
183
|
+
"path": "lib/foo.rb",
|
184
|
+
"offences": []
|
185
|
+
}, {
|
186
|
+
"path": "lib/bar.rb",
|
187
|
+
"offences": [{
|
188
|
+
"severity": "convention",
|
189
|
+
"message": "Line is too long. [81/79]",
|
190
|
+
"cop_name": "LineLength",
|
191
|
+
"location": {
|
192
|
+
"line": 546,
|
193
|
+
"column": 80
|
194
|
+
}
|
195
|
+
}, {
|
196
|
+
"severity": "warning",
|
197
|
+
"message": "Unreachable code detected.",
|
198
|
+
"cop_name": "UnreachableCode",
|
199
|
+
"location": {
|
200
|
+
"line": 15,
|
201
|
+
"column": 9
|
202
|
+
}
|
203
|
+
}
|
204
|
+
]
|
205
|
+
}
|
206
|
+
],
|
207
|
+
"summary": {
|
208
|
+
"offence_count": 2,
|
209
|
+
"target_file_count": 2,
|
210
|
+
"inspected_file_count": 2
|
211
|
+
}
|
212
|
+
}
|
213
|
+
```
|
214
|
+
|
215
|
+
### Custom Formatters
|
216
|
+
|
217
|
+
You can customize RuboCop's output format with custom formatter.
|
218
|
+
|
219
|
+
#### Creating Custom Formatter
|
220
|
+
|
221
|
+
To implement a custom formatter, you need to subclass
|
222
|
+
`Rubocop::Formatter::BaseFormatter` and override some methods,
|
223
|
+
or implement all formatter API methods by duck typing.
|
224
|
+
|
225
|
+
Please see the documents below for more formatter API details.
|
226
|
+
|
227
|
+
* [Rubocop::Formatter::BaseFormatter](http://rubydoc.info/gems/rubocop/Rubocop/Formatter/BaseFormatter)
|
228
|
+
* [Rubocop::Cop::Offence](http://rubydoc.info/gems/rubocop/Rubocop/Cop/Offence)
|
229
|
+
* [Parser::Source::Range](http://rubydoc.info/github/whitequark/parser/Parser/Source/Range)
|
230
|
+
|
231
|
+
#### Using Custom Formatter in Command Line
|
232
|
+
|
233
|
+
You can tell RuboCop to use your custom formatter with a combination of
|
234
|
+
`--format` and `--require` option.
|
235
|
+
For example, when you have defined `MyCustomFormatter` in
|
236
|
+
`./path/to/my_custom_formatter.rb`, you would type this command:
|
237
|
+
|
238
|
+
```bash
|
239
|
+
$ rubocop --require ./path/to/my_custom_formatter --format MyCustomFormatter
|
240
|
+
```
|
241
|
+
|
242
|
+
Note: The path passed to `--require` is directly passed to `Kernel.require`.
|
243
|
+
If your custom formatter file is not in `$LOAD_PATH`,
|
244
|
+
you need to specify the path as relative path prefixed with `./` explicitly,
|
245
|
+
or absolute path.
|
246
|
+
|
247
|
+
## Compatibility
|
248
|
+
|
249
|
+
RuboCop supported only MRI 1.9 & MRI 2.0 prior to version 0.8. After
|
250
|
+
RuboCop 0.8, JRuby and Rubinius in 1.9 modes are also supported.
|
251
|
+
|
252
|
+
## Editor integration
|
253
|
+
|
254
|
+
### Emacs
|
255
|
+
|
256
|
+
[rubocop.el](https://github.com/bbatsov/rubocop-emacs) is a simple
|
257
|
+
Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs
|
258
|
+
and quickly jump between problems in your code.
|
259
|
+
|
260
|
+
[flycheck](https://github.com/lunaryorn/flycheck) > 0.9 also supports
|
261
|
+
RuboCop and uses it by default when available.
|
262
|
+
|
263
|
+
### Vim
|
264
|
+
|
265
|
+
The [vim-rubocop](https://github.com/ngmy/vim-rubocop) plugin runs
|
266
|
+
RuboCop and displays the results in Vim.
|
267
|
+
|
268
|
+
There's also a RuboCop checker in
|
269
|
+
[syntastic](https://github.com/scrooloose/syntastic).
|
270
|
+
|
271
|
+
### Sublime Text 2
|
272
|
+
|
273
|
+
If you're a ST2 user you might find the
|
274
|
+
[Sublime RuboCop plugin](https://github.com/pderichs/sublime_rubocop)
|
275
|
+
useful.
|
276
|
+
|
277
|
+
### Other Editors
|
278
|
+
|
279
|
+
Here's one great opportunity to contribute to RuboCop - implement
|
280
|
+
RuboCop integration for your favorite editor.
|
281
|
+
|
282
|
+
## Guard integration
|
283
|
+
|
284
|
+
If you're fond of [Guard](https://github.com/guard/guard) you might
|
285
|
+
like
|
286
|
+
[guard-rubocop](https://github.com/yujinakayama/guard-rubocop). It
|
287
|
+
allows you to automatically check Ruby code style with RuboCop when
|
288
|
+
files are modified.
|
289
|
+
|
290
|
+
## Contributors
|
291
|
+
|
292
|
+
Here's a [list](https://github.com/bbatsov/rubocop/contributors) of
|
293
|
+
all the people who have contributed to the development of RuboCop.
|
294
|
+
|
295
|
+
I'm extremely grateful to each and every one of them!
|
296
|
+
|
297
|
+
I'd like to single out [Jonas Arvidsson](https://github.com/jonas054)
|
298
|
+
and [Yuji Nakayama](https://github.com/yujinakayama) for their many
|
299
|
+
excellent code contributions as well as valuable feedback and ideas!
|
300
|
+
|
301
|
+
If you'd like to contribute to RuboCop, please take the time to go
|
302
|
+
through our short
|
303
|
+
[contribution guidelines](CONTRIBUTING.md).
|
304
|
+
|
305
|
+
Converting more of the Ruby Style Guide into RuboCop cops is our top
|
306
|
+
priority right now. Writing a new cop is a great way to dive into RuboCop!
|
307
|
+
|
308
|
+
Of course, bug reports and suggestions for improvements are always
|
309
|
+
welcome. GitHub pull requests are even better! :-)
|
310
|
+
|
311
|
+
## Mailing List
|
312
|
+
|
313
|
+
If you're interested in everything regarding RuboCop's development,
|
314
|
+
consider joining its
|
315
|
+
[Google Group](https://groups.google.com/forum/?fromgroups#!forum/rubocop).
|
316
|
+
|
317
|
+
## Changelog
|
318
|
+
|
319
|
+
RuboCop's changelog is available [here](CHANGELOG.md).
|
320
|
+
|
321
|
+
## Copyright
|
322
|
+
|
323
|
+
Copyright (c) 2012-2013 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
|
324
|
+
further details.
|