rubocop 0.26.1 → 0.27.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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.rubocop_todo.yml +10 -6
  4. data/.travis.yml +2 -0
  5. data/CHANGELOG.md +30 -0
  6. data/README.md +9 -2
  7. data/assets/logo.png +0 -0
  8. data/assets/output.html.erb +68 -65
  9. data/config/default.yml +42 -7
  10. data/config/disabled.yml +5 -0
  11. data/config/enabled.yml +32 -7
  12. data/lib/rubocop.rb +10 -2
  13. data/lib/rubocop/comment_config.rb +11 -17
  14. data/lib/rubocop/config.rb +20 -16
  15. data/lib/rubocop/config_loader.rb +8 -12
  16. data/lib/rubocop/cop/cop.rb +13 -12
  17. data/lib/rubocop/cop/lint/block_alignment.rb +4 -6
  18. data/lib/rubocop/cop/lint/def_end_alignment.rb +2 -2
  19. data/lib/rubocop/cop/lint/require_parentheses.rb +1 -1
  20. data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -3
  21. data/lib/rubocop/cop/lint/useless_setter_call.rb +2 -2
  22. data/lib/rubocop/cop/metrics/abc_size.rb +27 -0
  23. data/lib/rubocop/cop/metrics/block_nesting.rb +2 -4
  24. data/lib/rubocop/cop/metrics/class_length.rb +1 -1
  25. data/lib/rubocop/cop/metrics/line_length.rb +2 -5
  26. data/lib/rubocop/cop/metrics/method_length.rb +2 -2
  27. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +24 -15
  28. data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +15 -2
  29. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +63 -0
  30. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
  31. data/lib/rubocop/cop/mixin/if_node.rb +3 -1
  32. data/lib/rubocop/cop/mixin/method_complexity.rb +3 -3
  33. data/lib/rubocop/cop/mixin/{on_method.rb → on_method_def.rb} +3 -3
  34. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +2 -2
  35. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  36. data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -2
  37. data/lib/rubocop/cop/mixin/string_literals_help.rb +28 -0
  38. data/lib/rubocop/cop/rails/delegate.rb +2 -2
  39. data/lib/rubocop/cop/style/access_modifier_indentation.rb +2 -2
  40. data/lib/rubocop/cop/style/accessor_method_name.rb +2 -2
  41. data/lib/rubocop/cop/style/align_hash.rb +16 -12
  42. data/lib/rubocop/cop/style/align_parameters.rb +1 -1
  43. data/lib/rubocop/cop/style/and_or.rb +14 -6
  44. data/lib/rubocop/cop/style/array_join.rb +1 -1
  45. data/lib/rubocop/cop/style/block_comments.rb +16 -8
  46. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +6 -30
  47. data/lib/rubocop/cop/style/case_indentation.rb +20 -12
  48. data/lib/rubocop/cop/style/collection_methods.rb +4 -4
  49. data/lib/rubocop/cop/style/colon_method_call.rb +9 -0
  50. data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
  51. data/lib/rubocop/cop/style/comment_indentation.rb +22 -22
  52. data/lib/rubocop/cop/style/def_with_parentheses.rb +2 -2
  53. data/lib/rubocop/cop/style/deprecated_hash_methods.rb +1 -1
  54. data/lib/rubocop/cop/style/double_negation.rb +6 -1
  55. data/lib/rubocop/cop/style/else_alignment.rb +93 -0
  56. data/lib/rubocop/cop/style/empty_line_between_defs.rb +1 -1
  57. data/lib/rubocop/cop/style/empty_lines.rb +1 -1
  58. data/lib/rubocop/cop/style/empty_lines_around_class_body.rb +34 -0
  59. data/lib/rubocop/cop/style/empty_lines_around_method_body.rb +37 -0
  60. data/lib/rubocop/cop/style/empty_lines_around_module_body.rb +30 -0
  61. data/lib/rubocop/cop/style/encoding.rb +1 -1
  62. data/lib/rubocop/cop/style/format_string.rb +4 -4
  63. data/lib/rubocop/cop/style/indent_array.rb +2 -2
  64. data/lib/rubocop/cop/style/indent_hash.rb +17 -12
  65. data/lib/rubocop/cop/style/indentation_width.rb +27 -19
  66. data/lib/rubocop/cop/style/method_call_parentheses.rb +3 -3
  67. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -1
  68. data/lib/rubocop/cop/style/method_def_parentheses.rb +17 -11
  69. data/lib/rubocop/cop/style/method_name.rb +1 -1
  70. data/lib/rubocop/cop/style/multiline_operation_indentation.rb +174 -0
  71. data/lib/rubocop/cop/style/non_nil_check.rb +12 -15
  72. data/lib/rubocop/cop/style/not.rb +1 -1
  73. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +12 -17
  74. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  75. data/lib/rubocop/cop/style/predicate_name.rb +2 -2
  76. data/lib/rubocop/cop/style/redundant_begin.rb +2 -2
  77. data/lib/rubocop/cop/style/redundant_return.rb +3 -3
  78. data/lib/rubocop/cop/style/redundant_self.rb +3 -3
  79. data/lib/rubocop/cop/style/regexp_literal.rb +17 -13
  80. data/lib/rubocop/cop/style/rescue_modifier.rb +2 -2
  81. data/lib/rubocop/cop/style/single_line_methods.rb +7 -4
  82. data/lib/rubocop/cop/style/space_after_method_name.rb +2 -2
  83. data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +17 -11
  84. data/lib/rubocop/cop/style/space_before_block_braces.rb +1 -1
  85. data/lib/rubocop/cop/style/space_inside_block_braces.rb +17 -14
  86. data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +10 -6
  87. data/lib/rubocop/cop/style/string_literals.rb +13 -16
  88. data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +41 -0
  89. data/lib/rubocop/cop/style/trailing_comma.rb +1 -3
  90. data/lib/rubocop/cop/style/trivial_accessors.rb +3 -3
  91. data/lib/rubocop/cop/style/unneeded_capital_w.rb +1 -1
  92. data/lib/rubocop/cop/style/unneeded_percent_q.rb +2 -2
  93. data/lib/rubocop/cop/style/word_array.rb +23 -19
  94. data/lib/rubocop/cop/team.rb +13 -26
  95. data/lib/rubocop/cop/util.rb +5 -0
  96. data/lib/rubocop/cop/variable_force/locatable.rb +7 -13
  97. data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
  98. data/lib/rubocop/formatter/formatter_set.rb +9 -1
  99. data/lib/rubocop/formatter/html_formatter.rb +83 -55
  100. data/lib/rubocop/formatter/simple_text_formatter.rb +2 -2
  101. data/lib/rubocop/formatter/text_util.rb +25 -0
  102. data/lib/rubocop/options.rb +14 -7
  103. data/lib/rubocop/path_util.rb +11 -7
  104. data/lib/rubocop/runner.rb +7 -2
  105. data/lib/rubocop/version.rb +1 -1
  106. data/relnotes/v0.27.0.md +77 -0
  107. data/rubocop.gemspec +1 -1
  108. data/spec/fixtures/html_formatter/expected.html +495 -0
  109. data/spec/fixtures/html_formatter/project/app/controllers/application_controller.rb +5 -0
  110. data/spec/fixtures/html_formatter/project/app/controllers/books_controller.rb +74 -0
  111. data/spec/fixtures/html_formatter/project/app/models/book.rb +5 -0
  112. data/spec/rubocop/cli_spec.rb +56 -13
  113. data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +1 -1
  114. data/spec/rubocop/cop/metrics/abc_size_spec.rb +99 -0
  115. data/spec/rubocop/cop/rails/action_filter_spec.rb +1 -0
  116. data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +23 -1
  117. data/spec/rubocop/cop/style/align_hash_spec.rb +13 -0
  118. data/spec/rubocop/cop/style/align_parameters_spec.rb +44 -33
  119. data/spec/rubocop/cop/style/blocks_spec.rb +8 -0
  120. data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +9 -9
  121. data/spec/rubocop/cop/style/case_indentation_spec.rb +3 -2
  122. data/spec/rubocop/cop/style/colon_method_call_spec.rb +5 -0
  123. data/spec/rubocop/cop/style/comment_indentation_spec.rb +6 -1
  124. data/spec/rubocop/cop/style/else_alignment_spec.rb +437 -0
  125. data/spec/rubocop/cop/style/empty_lines_around_class_body_spec.rb +75 -0
  126. data/spec/rubocop/cop/style/{empty_lines_around_body_spec.rb → empty_lines_around_method_body_spec.rb} +9 -50
  127. data/spec/rubocop/cop/style/empty_lines_around_module_body_spec.rb +79 -0
  128. data/spec/rubocop/cop/style/file_name_spec.rb +1 -1
  129. data/spec/rubocop/cop/style/format_string_spec.rb +12 -0
  130. data/spec/rubocop/cop/style/indent_array_spec.rb +6 -1
  131. data/spec/rubocop/cop/style/indent_hash_spec.rb +2 -1
  132. data/spec/rubocop/cop/style/indentation_width_spec.rb +765 -722
  133. data/spec/rubocop/cop/style/multiline_operation_indentation_spec.rb +414 -0
  134. data/spec/rubocop/cop/style/non_nil_check_spec.rb +86 -55
  135. data/spec/rubocop/cop/style/single_line_methods_spec.rb +5 -1
  136. data/spec/rubocop/cop/style/space_before_block_braces_spec.rb +2 -1
  137. data/spec/rubocop/cop/style/space_inside_block_braces_spec.rb +2 -1
  138. data/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb +63 -0
  139. data/spec/rubocop/cop/style/string_literals_spec.rb +2 -2
  140. data/spec/rubocop/cop/style/word_array_spec.rb +15 -1
  141. data/spec/rubocop/formatter/base_formatter_spec.rb +1 -1
  142. data/spec/rubocop/formatter/disabled_lines_formatter_spec.rb +0 -1
  143. data/spec/rubocop/formatter/formatter_set_spec.rb +9 -0
  144. data/spec/rubocop/formatter/html_formatter_spec.rb +25 -122
  145. data/spec/rubocop/formatter/offense_count_formatter_spec.rb +0 -1
  146. data/spec/rubocop/runner_spec.rb +1 -1
  147. data/spec/spec_helper.rb +12 -130
  148. data/spec/support/cop_helper.rb +72 -0
  149. data/spec/support/coverage.rb +15 -0
  150. data/spec/support/{offenses_matcher.rb → custom_matchers.rb} +28 -0
  151. data/spec/support/jruby_workaround.rb +15 -0
  152. data/spec/support/{isolated_environment.rb → shared_contexts.rb} +19 -0
  153. metadata +49 -14
  154. data/lib/rubocop/cop/style/empty_lines_around_body.rb +0 -75
  155. data/spec/support/shared_context.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dd2c1c375e842c50e244af47472085016e9214e
4
- data.tar.gz: 355612f83c8f6774162368b1dfdaaa677bd9dbb9
3
+ metadata.gz: 30651383f11c3dcaac288e77b0055e6523b509fe
4
+ data.tar.gz: 245cd91aaf840d894118ed9f0530c1d3019b9c1f
5
5
  SHA512:
6
- metadata.gz: 3b9b20e7c9eca832d37b245745fe68c9b6d2bb0132c98b752ff530a2988e4d65cffd9d17d1d3a06785a75010dda8d69f827460cf1a141db6c6ca3da614f34e01
7
- data.tar.gz: 909ee8bd3302d9c32c9340980d67f03b757de1745523f38d914173ec48203edf224145cc0890e79cdb6336ed7cea03aa0b1169692aec3db31ca3aa6f4fcea4c9
6
+ metadata.gz: 56e26bc6f778104eae7226a633e6eca1f5302d263c1ae4d8a208031c08bc688011817dc55272a8962c586cc436639749b504b208f4ac415d87f11aaedda40a49
7
+ data.tar.gz: f457149f614495b72eabfc4fece9f96007aa18f6debb384bc4dadb6bd580b45ac3bcf0818d8241cf3a5524f04ca881324c0c7ee4238f03973b41148f74e21f76
@@ -2,5 +2,10 @@
2
2
 
3
3
  inherit_from: .rubocop_todo.yml
4
4
 
5
+ AllCops:
6
+ Exclude:
7
+ - 'vendor/**/*'
8
+ - 'spec/fixtures/**/*'
9
+
5
10
  Style/Encoding:
6
11
  Enabled: true
@@ -1,24 +1,28 @@
1
1
  # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-07-27 10:46:47 +0200 using RuboCop version 0.24.1.
2
+ # on 2014-10-22 08:31:49 +0200 using RuboCop version 0.26.1.
3
3
  # The point is for the user to remove these configuration records
4
4
  # one by one as the offenses are removed from the code base.
5
5
  # Note that changes in the inspected code, or installation of new
6
6
  # versions of RuboCop, may require this file to be generated again.
7
7
 
8
- # Offense count: 8
8
+ # Offense count: 116
9
+ Metrics/AbcSize:
10
+ Max: 33
11
+
12
+ # Offense count: 10
9
13
  # Configuration parameters: CountComments.
10
14
  Metrics/ClassLength:
11
15
  Max: 131
12
16
 
13
- # Offense count: 30
17
+ # Offense count: 27
14
18
  Metrics/CyclomaticComplexity:
15
19
  Max: 10
16
20
 
17
- # Offense count: 124
21
+ # Offense count: 129
18
22
  # Configuration parameters: CountComments.
19
23
  Metrics/MethodLength:
20
- Max: 21
24
+ Max: 16
21
25
 
22
- # Offense count: 22
26
+ # Offense count: 16
23
27
  Metrics/PerceivedComplexity:
24
28
  Max: 11
@@ -11,6 +11,8 @@ matrix:
11
11
  - rvm: ruby-head
12
12
  - rvm: rbx-2
13
13
  before_install: gem update --remote bundler
14
+ install:
15
+ - bundle install --retry=3
14
16
  script:
15
17
  - bundle exec rspec
16
18
  - bundle exec rubocop
@@ -2,6 +2,34 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.27.0 (30/10/2014)
6
+
7
+ ### New features
8
+
9
+ * [#1348](https://github.com/bbatsov/rubocop/issues/1348): New cop `ElseAlignment` checks alignment of `else` and `elsif` keywords. ([@jonas054][])
10
+ * [#1321](https://github.com/bbatsov/rubocop/issues/1321): New cop `MultilineOperationIndentation` checks indentation/alignment of binary operations if they span more than one line. ([@jonas054][])
11
+ * [#1077](https://github.com/bbatsov/rubocop/issues/1077): New cop `Metrics/AbcSize` checks the ABC metric, based on assignments, branches, and conditions. ([@jonas054][], [@jfelchner][])
12
+ * [#1352](https://github.com/bbatsov/rubocop/issues/1352): `WordArray` is now configurable with the `WordRegex` option. ([@bquorning][])
13
+ * [#1181](https://github.com/bbatsov/rubocop/issues/1181): New cop `Style/StringLiteralsInInterpolation` checks quotes inside interpolated expressions in strings. ([@jonas054][])
14
+ * [#872](https://github.com/bbatsov/rubocop/issues/872): `Style/IndentationWidth` is now configurable with the `Width` option. ([@jonas054][])
15
+ * [#1396](https://github.com/bbatsov/rubocop/issues/1396): Include `.opal` files by default. ([@bbatsov][])
16
+ * [#771](https://github.com/bbatsov/rubocop/issues/771): Three new `Style` cops, `EmptyLinesAroundMethodBody` , `EmptyLinesAroundClassBody` , and `EmptyLinesAroundModuleBody` replace the `EmptyLinesAroundBody` cop. ([@jonas054][])
17
+
18
+ ### Changes
19
+
20
+ * [#1084](https://github.com/bbatsov/rubocop/issues/1084): Disabled `Style/CollectionMethods` by default. ([@bbatsov][])
21
+
22
+ ### Bugs fixed
23
+
24
+ * `AlignHash` no longer skips multiline hashes that contain some elements on the same line. ([@mvz][])
25
+ * [#1349](https://github.com/bbatsov/rubocop/issues/1349): `BracesAroundHashParameters` no longer cleans up whitespace in autocorrect, as these extra corrections are likely to interfere with other cops' corrections. ([@jonas054][])
26
+ * [#1350](https://github.com/bbatsov/rubocop/issues/1350): Guard against `Blocks` cop introducing syntax errors in auto-correct. ([@jonas054][])
27
+ * [#1374](https://github.com/bbatsov/rubocop/issues/1374): To eliminate interference, auto-correction is now done by one cop at a time, with saving and re-parsing inbetween. ([@jonas054][])
28
+ * [#1388](https://github.com/bbatsov/rubocop/issues/1388): Fix a false positive in `FormatString`. ([@bbatsov][])
29
+ * [#1389](https://github.com/bbatsov/rubocop/issues/1389): Make `--out` to create parent directories. ([@yous][])
30
+ * Refine HTML formatter. ([@yujinakayama][])
31
+ * [#1410](https://github.com/bbatsov/rubocop/issues/1410): Handle specially Java primitive type references in `ColonMethodCall`. ([@bbatsov][])
32
+
5
33
  ## 0.26.1 (18/09/2014)
6
34
 
7
35
  ### Bugs fixed
@@ -1103,3 +1131,5 @@
1103
1131
  [@jspanjers]: https://github.com/jspanjers
1104
1132
  [@sch1zo]: https://github.com/sch1zo
1105
1133
  [@smangelsdorf]: https://github.com/smangelsdorf
1134
+ [@mvz]: https://github.com/mvz
1135
+ [@jfelchner]: https://github.com/jfelchner
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Coverage Status](http://img.shields.io/coveralls/bbatsov/rubocop/master.svg)](https://coveralls.io/r/bbatsov/rubocop)
5
5
  [![Code Climate](https://codeclimate.com/github/bbatsov/rubocop/badges/gpa.svg)](https://codeclimate.com/github/bbatsov/rubocop)
6
6
  [![Inline docs](http://inch-ci.org/github/bbatsov/rubocop.svg)](http://inch-ci.org/github/bbatsov/rubocop)
7
+ [![Gratipay](http://img.shields.io/gratipay/bbatsov.svg)](https://www.gratipay.com/bbatsov/)
7
8
 
8
9
  <p align="center">
9
10
  <img src="https://raw.github.com/bbatsov/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
@@ -22,6 +23,10 @@ Most aspects of its behavior can be tweaked via various
22
23
  Apart from reporting problems in your code, RuboCop can also
23
24
  automatically fix some of the problems for you.
24
25
 
26
+ You can support my work on RuboCop and [all my other projects](https://github.com/bbatsov) via [gratipay](https://www.gratipay.com/bbatsov).
27
+
28
+ [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/bbatsov)
29
+
25
30
  **This documentation tracks the `master` branch of RuboCop. Some of
26
31
  the features and settings discussed here might not be available in
27
32
  older releases (including the current stable release). Please, consult
@@ -794,9 +799,11 @@ priority right now. Writing a new cop is a great way to dive into RuboCop!
794
799
  Of course, bug reports and suggestions for improvements are always
795
800
  welcome. GitHub pull requests are even better! :-)
796
801
 
797
- I'm also accepting financial contributions via [gittip](https://www.gittip.com/bbatsov).
802
+ You can also support my work on RuboCop and
803
+ [all my other projects](https://github.com/bbatsov) via
804
+ [gratipay](https://www.gratipay.com/bbatsov).
798
805
 
799
- [![Support via Gittip](https://rawgithub.com/twolfson/gittip-badge/0.2.0/dist/gittip.png)](https://www.gittip.com/bbatsov)
806
+ [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/bbatsov)
800
807
 
801
808
  ## Mailing List
802
809
 
Binary file
@@ -2,14 +2,15 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset='UTF-8' />
5
- <title>RuboCop output</title>
5
+ <title>RuboCop Inspection Report</title>
6
+ <%# TODO: Clean up the messy markup and style definitions. %>
6
7
  <style>
7
8
  * {
8
9
  -webkit-box-sizing: border-box;
9
10
  -moz-box-sizing: border-box;
10
11
  box-sizing: border-box;
11
12
  }
12
-
13
+
13
14
  body, html {
14
15
  font-size: 62.5%;
15
16
  }
@@ -18,26 +19,33 @@
18
19
  font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
19
20
  margin: 0;
20
21
  }
22
+ code {
23
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
24
+ font-size: 85%;
25
+ }
21
26
  #header {
22
- background: #171717;
23
- border-bottom: none;
24
- border-left: 1px solid #3a3a3a;
25
- box-shadow: 1px 3px 0 1px #cccccc;
27
+ background: #f9f9f9;
28
+ color: #333;
29
+ border-bottom: 3px solid #ccc;
26
30
  height: 50px;
27
31
  padding: 0;
28
32
  }
29
- h2 {
30
- color: #FFF;
33
+ #header .logo {
34
+ float: left;
35
+ margin: 5px 12px 7px 20px;
36
+ width: 38px;
37
+ height: 38px;
38
+ }
39
+ #header .title {
31
40
  display: inline-block;
32
41
  float: left;
33
42
  height: 50px;
34
- font-size: 2rem;
43
+ font-size: 2.4rem;
35
44
  letter-spacing: normal;
36
45
  line-height: 50px;
37
46
  margin: 0;
38
- padding: 0 22px 0 20px;
39
47
  }
40
-
48
+
41
49
  .information, #offenses {
42
50
  width: 100%;
43
51
  padding: 20px;
@@ -46,7 +54,7 @@
46
54
  #offenses {
47
55
  padding: 0 20px;
48
56
  }
49
-
57
+
50
58
  .information .infobox {
51
59
  border-left: 3px solid;
52
60
  border-radius: 4px;
@@ -55,24 +63,22 @@
55
63
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
56
64
  padding: 15px;
57
65
  border-color: #0088cc;
66
+ font-size: 1.4rem;
58
67
  }
59
-
60
68
  .information .infobox .info-title {
61
69
  font-size: 1.8rem;
62
70
  line-height: 2.2rem;
63
- margin: 0;
71
+ margin: 0 0 0.5em;
64
72
  }
65
73
  .information .infobox ul {
66
- font-size: 1.4rem;
67
74
  list-style: none;
68
75
  margin: 0;
69
- margin-top: 5px;
70
76
  padding: 0;
71
77
  }
72
78
  .information .infobox ul li {
73
79
  line-height: 1.8rem
74
80
  }
75
-
81
+
76
82
  #offenses .offense-box {
77
83
  border-radius: 4px;
78
84
  margin-bottom: 20px;
@@ -102,71 +108,76 @@
102
108
  #offenses .offense-box .offense-reports .report:last-child {
103
109
  border-bottom: none;
104
110
  }
105
- #offenses .offense-box .offense-reports .report pre {
111
+ #offenses .offense-box .offense-reports .report pre code {
112
+ display: block;
106
113
  background: #000;
107
114
  color: #fff;
108
115
  padding: 10px 15px;
109
- font-size: 1.2rem;
110
116
  border-radius: 5px;
111
117
  line-height: 1.6rem;
112
118
  }
113
119
  #offenses .offense-box .offense-reports .report .location {
114
- padding: 0;
115
- list-style: none;
120
+ font-weight: bold;
116
121
  }
117
- #offenses .offense-box .offense-reports .report .location li {
118
- display: inline;
119
- margin-right: 10px;
122
+ #offenses .offense-box .offense-reports .report .message code {
123
+ padding: 0.3em;
124
+ background-color: rgba(0,0,0,0.07);
125
+ border-radius: 3px;
120
126
  }
121
127
  .severity {
122
128
  text-transform: capitalize;
123
129
  font-weight: bold;
124
130
  }
125
- .severity.convention, .severity.refactor {
126
- color: #47a447;
131
+ .highlight {
132
+ padding: 2px;
133
+ border-radius: 2px;
134
+ font-weight: bold;
127
135
  }
128
- .severity.warning {
129
- color: #ed9c28;
136
+ <%- SEVERITY_COLORS.each do |severity, color| %>
137
+ .severity.<%= severity %> {
138
+ color: <%= color %>;
130
139
  }
131
- .severity.error, .severity.fatal {
132
- color: #d2322d;
140
+ .highlight.<%= severity %> {
141
+ background-color: <%= color.fade_out(0.4) %>;
142
+ border: 1px solid <%= color.fade_out(0.6) %>;
143
+ }
144
+ <%- end %>
145
+ footer {
146
+ margin-bottom: 20px;
147
+ margin-right: 20px;
148
+ font-size: 1.3rem;
149
+ color: #777;
150
+ text-align: right;
133
151
  }
134
152
  </style>
135
153
  </head>
136
154
  <body>
137
155
  <div id="header">
138
- <h2>RuboCop Output</h2>
156
+ <img class="logo" src="data:image/png;base64,<%= base64_encoded_logo_image %>" alt="">
157
+ <h1 class="title">RuboCop Inspection Report</h1>
139
158
  </div>
140
159
  <div class="information">
141
160
  <div class="infobox">
142
- <h4 class="info-title">RuboCop Stats</h4>
143
- <ul>
144
- <li><strong>Offense Count:</strong> <%= output_hash[:summary][:offense_count] %></li>
145
- <li><strong>Target File Count:</strong> <%= output_hash[:summary][:target_file_count] %></li>
146
- <li><strong>Inspected File Count:</strong> <%= output_hash[:summary][:inspected_file_count] %></li>
147
- </ul>
161
+ <%= pluralize(files.count, 'file') %> inspected,
162
+ <%= pluralize(summary.offense_count, 'offense', no_for_zero: true) %> detected
148
163
  </div>
149
164
  </div>
150
165
  <div id="offenses">
151
- <% output_hash[:files].each do |file| %>
152
- <% if file[:offenses].any? %>
166
+ <% files.each do |file| %>
167
+ <% if file.offenses.any? %>
153
168
  <div class="offense-box">
154
- <div class="box-title"><h3><%= file[:path] %> - <%= file[:offenses].length %></h3></div>
169
+ <div class="box-title"><h3><%= relative_path(file.path) %> - <%= pluralize(file.offenses.count, 'offense') %></h3></div>
155
170
  <div class="offense-reports">
156
- <% file[:offenses].each do |offense| %>
171
+ <% file.offenses.each do |offense| %>
157
172
  <div class="report">
158
- <p class="message"><span class="severity <%= offense[:severity] %>"><%= offense[:severity] %>:</span> <%= offense[:message] %></p>
159
- <% if offense[:location][:source_line].strip.length > 0 %>
160
- <pre>
161
- <%= offense[:location][:source_line] %>
162
- <%= offense[:location][:highlight] %>
163
- </pre>
173
+ <div class="meta">
174
+ <span class="location">Line #<%= offense.location.line %></span>
175
+ <span class="severity <%= offense.severity %>"><%= offense.severity %>:</span>
176
+ <span class="message"><%= decorated_message(offense) %></span>
177
+ </div>
178
+ <% unless offense.location.source_line.strip.empty? %>
179
+ <pre><code><%= highlighted_source_line(offense) %></code></pre>
164
180
  <% end %>
165
- <ul class="location">
166
- <li><strong>Line: </strong> <%= offense[:location][:line] %></li>
167
- <li><strong>Column: </strong> <%= offense[:location][:column] %></li>
168
- <li><strong>Length: </strong> <%= offense[:location][:length] %></li>
169
- </ul>
170
181
  </div>
171
182
  <% end %>
172
183
  </div>
@@ -174,17 +185,9 @@
174
185
  <% end %>
175
186
  <% end %>
176
187
  </div>
177
- <div class="information">
178
- <div class="infobox">
179
- <h4 class="info-title">Environment Information</h4>
180
- <ul>
181
- <li><strong>RuboCop Version:</strong> <%= output_hash[:metadata][:rubocop_version] %></li>
182
- <li><strong>Ruby Engine:</strong> <%= output_hash[:metadata][:ruby_engine] %></li>
183
- <li><strong>Ruby Version:</strong> <%= output_hash[:metadata][:ruby_version] %></li>
184
- <li><strong>Ruby Patch Level:</strong> <%= output_hash[:metadata][:ruby_patchlevel] %></li>
185
- <li><strong>Ruby Platform:</strong> <%= output_hash[:metadata][:ruby_platform] %></li>
186
- </ul>
187
- </div>
188
- </div>
188
+ <footer>
189
+ Generated by <a href="https://github.com/bbatsov/rubocop">RuboCop</a>
190
+ <span class="version"><%= RuboCop::Version::STRING %></span>
191
+ </footer>
189
192
  </body>
190
- </html>
193
+ </html>
@@ -13,6 +13,7 @@ AllCops:
13
13
  - '**/*.podspec'
14
14
  - '**/*.jbuilder'
15
15
  - '**/*.rake'
16
+ - '**/*.opal'
16
17
  - '**/Gemfile'
17
18
  - '**/Rakefile'
18
19
  - '**/Capfile'
@@ -20,6 +21,9 @@ AllCops:
20
21
  - '**/Podfile'
21
22
  - '**/Thorfile'
22
23
  - '**/Vagrantfile'
24
+ - '**/Berksfile'
25
+ - '**/Cheffile'
26
+ - '**/Vagabondfile'
23
27
  Exclude:
24
28
  - 'vendor/**/*'
25
29
  # By default, the rails cops are not run. Override in project or home
@@ -210,6 +214,18 @@ Style/EmptyLineBetweenDefs:
210
214
  # need an empty line between them.
211
215
  AllowAdjacentOneLineDefs: false
212
216
 
217
+ Style/EmptyLinesAroundClassBody:
218
+ EnforcedStyle: no_empty_lines
219
+ SupportedStyles:
220
+ - empty_lines
221
+ - no_empty_lines
222
+
223
+ Style/EmptyLinesAroundModuleBody:
224
+ EnforcedStyle: no_empty_lines
225
+ SupportedStyles:
226
+ - empty_lines
227
+ - no_empty_lines
228
+
213
229
  # Checks whether the source file has a utf-8 encoding comment or not
214
230
  Style/Encoding:
215
231
  EnforcedStyle: always
@@ -218,13 +234,9 @@ Style/Encoding:
218
234
  - always
219
235
 
220
236
  Style/FileName:
221
- Exclude:
222
- - '**/Rakefile'
223
- - '**/Gemfile'
224
- - '**/Capfile'
225
- - '**/Vagrantfile'
226
- - '**/Podfile'
227
- - '**/Thorfile'
237
+ # File names listed in AllCops:Include are excluded by default. Add extra
238
+ # excludes here.
239
+ Exclude: []
228
240
 
229
241
  # Checks use of for or each in multiline loops.
230
242
  Style/For:
@@ -259,6 +271,10 @@ Style/HashSyntax:
259
271
  Style/IfUnlessModifier:
260
272
  MaxLineLength: 80
261
273
 
274
+ Style/IndentationWidth:
275
+ # Number of spaces for each indentation level.
276
+ Width: 2
277
+
262
278
  # Checks the indentation of the first key in a hash literal.
263
279
  Style/IndentHash:
264
280
  # The value `special_inside_parentheses` means that hash literals with braces
@@ -312,6 +328,12 @@ Style/MethodName:
312
328
  - snake_case
313
329
  - camelCase
314
330
 
331
+ Style/MultilineOperationIndentation:
332
+ EnforcedStyle: aligned
333
+ SupportedStyles:
334
+ - aligned
335
+ - indented
336
+
315
337
  Style/NumericLiterals:
316
338
  MinDigits: 5
317
339
 
@@ -393,6 +415,12 @@ Style/StringLiterals:
393
415
  - single_quotes
394
416
  - double_quotes
395
417
 
418
+ Style/StringLiteralsInInterpolation:
419
+ EnforcedStyle: single_quotes
420
+ SupportedStyles:
421
+ - single_quotes
422
+ - double_quotes
423
+
396
424
  Style/SpaceAroundEqualsInParameterDefault:
397
425
  EnforcedStyle: space
398
426
  SupportedStyles:
@@ -486,9 +514,16 @@ Style/WhileUntilModifier:
486
514
 
487
515
  Style/WordArray:
488
516
  MinSize: 0
517
+ # The regular expression WordRegex decides what is considered a word.
518
+ WordRegex: !ruby/regexp '/\A[\p{Word}]+\z/'
489
519
 
490
520
  ##################### Metrics ##################################
491
521
 
522
+ Metrics/AbcSize:
523
+ # The ABC size is a calculated magnitude, so this number can be a Fixnum or
524
+ # a Float.
525
+ Max: 15
526
+
492
527
  Metrics/BlockNesting:
493
528
  Max: 3
494
529