datarockets-style 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13302183c2bb2361f4069f312d84b44569bdac9bd3e012868cf6845357d1754f
4
- data.tar.gz: 6d8c66f18353e28136e855a7cf3a0ee1933c4103f68fc1cb0a602d8dcaa5190a
3
+ metadata.gz: 7ef40260e95ced035f4c8f86b18c807997a4e79228c72e75a880477fecb8030e
4
+ data.tar.gz: b35d77e092533855df4092585e8af229653859c6cce685bed399f50880d5bc49
5
5
  SHA512:
6
- metadata.gz: c17ff90118be39c8b0b078aea534e4a650e4c5dcb3dbccbda0cca6394c7372a97530b50112e76691155237b9944efd26d54fab5f7ef3437d20470c535f1f720b
7
- data.tar.gz: 4ddba3d32c03980657729a5b46d7d186fe589ddff67a4d4743bf377180c58bd3d2e0de59451286b28accfa12384852c96a59cf1a150efe611a9d9d361e3cc870
6
+ metadata.gz: a8b0a2bcb81d48837a708f337e3f37baba4e26d86f1be42fa02c12f441e18286b1164996a0a0026f870886a887c7664300683de2b80dee0e7fc6c4721934fce2
7
+ data.tar.gz: 0dd7f1c7bd2a72a7cbebe4fb5eaf4b399f53d014b0ecfe701be979917e09e7bc7467367d0dced76d25f9a76ad369b88da746285774e092b0078eea180209c913
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /tmp/
7
7
 
8
8
  .byebug_history
9
+ .idea
data/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-
4
4
 
5
5
  ## master
6
6
 
7
+ ## 1.1.0 (2021-02-09)
8
+
9
+ ### Changed
10
+
11
+ * Setup `EnforcedStyleForMultiline` for `Style/TrailingCommaInHashLiteral` rule. ([@r.dubrovsky][])
12
+ * Update rubocop to ```1.9.1```.([@paydaylight][])
13
+ * Update rubocop-rails requirement to ```>= 2.8.0, < 2.10.0```. ([@paydaylight][])
14
+ * Update rubocop-rspec to `2.2.0`. ([@paydaylight][])
15
+ * Change ```Datarockets::Style``` module to ```DatarocketsStyle```. ([@paydaylight][])
16
+
17
+ ### Fixed
18
+
19
+ * [#177](https://github.com/datarockets/datarockets-style/issues/177) set ```Layout/MultilineOperationIndentation``` to indented ([@paydaylight][])
20
+
7
21
  ## 1.0.0 (2020-11-10)
8
22
 
9
23
  ### Changed
@@ -207,4 +221,4 @@ The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-
207
221
  [@v.kuzmik]: https://github.com/TheBlackArroVV/
208
222
  [@a.branzeanu]: https://github.com/texpert
209
223
  [@nikitasakov]: https://github.com/nikitasakov
210
-
224
+ [@paydaylight]: https://github.com/paydaylight
data/Gemfile.lock CHANGED
@@ -1,31 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datarockets-style (1.0.0)
4
+ datarockets-style (1.1.0)
5
5
  rubocop (>= 1.2, < 2.0)
6
- rubocop-rails (>= 2.8.0, < 2.9.0)
6
+ rubocop-rails (>= 2.8.0, < 2.10.0)
7
7
  rubocop-rspec (~> 2.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.0.3.4)
12
+ activesupport (6.1.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2, >= 2.2.2)
18
- ast (2.4.1)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
+ ast (2.4.2)
19
19
  byebug (11.1.3)
20
20
  coderay (1.1.2)
21
21
  concurrent-ruby (1.1.7)
22
22
  diff-lcs (1.4.4)
23
- i18n (1.8.5)
23
+ i18n (1.8.7)
24
24
  concurrent-ruby (~> 1.0)
25
25
  method_source (1.0.0)
26
- minitest (5.14.2)
27
- parallel (1.20.0)
28
- parser (2.7.2.0)
26
+ minitest (5.14.3)
27
+ parallel (1.20.1)
28
+ parser (3.0.0.0)
29
29
  ast (~> 2.4.1)
30
30
  pry (0.13.1)
31
31
  coderay (~> 1.1)
@@ -35,8 +35,8 @@ GEM
35
35
  pry (~> 0.13.0)
36
36
  rack (2.2.3)
37
37
  rainbow (3.0.0)
38
- rake (13.0.1)
39
- regexp_parser (1.8.2)
38
+ rake (13.0.3)
39
+ regexp_parser (2.0.3)
40
40
  rexml (3.2.4)
41
41
  rspec (3.10.0)
42
42
  rspec-core (~> 3.10.0)
@@ -51,30 +51,29 @@ GEM
51
51
  diff-lcs (>= 1.2.0, < 2.0)
52
52
  rspec-support (~> 3.10.0)
53
53
  rspec-support (3.10.0)
54
- rubocop (1.2.0)
54
+ rubocop (1.9.1)
55
55
  parallel (~> 1.10)
56
- parser (>= 2.7.1.5)
56
+ parser (>= 3.0.0.0)
57
57
  rainbow (>= 2.2.2, < 4.0)
58
- regexp_parser (>= 1.8)
58
+ regexp_parser (>= 1.8, < 3.0)
59
59
  rexml
60
- rubocop-ast (>= 1.0.1)
60
+ rubocop-ast (>= 1.2.0, < 2.0)
61
61
  ruby-progressbar (~> 1.7)
62
- unicode-display_width (>= 1.4.0, < 2.0)
63
- rubocop-ast (1.1.1)
62
+ unicode-display_width (>= 1.4.0, < 3.0)
63
+ rubocop-ast (1.4.1)
64
64
  parser (>= 2.7.1.5)
65
- rubocop-rails (2.8.1)
65
+ rubocop-rails (2.9.1)
66
66
  activesupport (>= 4.2.0)
67
67
  rack (>= 1.1)
68
- rubocop (>= 0.87.0)
69
- rubocop-rspec (2.0.0)
68
+ rubocop (>= 0.90.0, < 2.0)
69
+ rubocop-rspec (2.1.0)
70
70
  rubocop (~> 1.0)
71
71
  rubocop-ast (>= 1.1.0)
72
- ruby-progressbar (1.10.1)
73
- thread_safe (0.3.6)
74
- tzinfo (1.2.8)
75
- thread_safe (~> 0.1)
76
- unicode-display_width (1.7.0)
77
- zeitwerk (2.4.1)
72
+ ruby-progressbar (1.11.0)
73
+ tzinfo (2.0.4)
74
+ concurrent-ruby (~> 1.0)
75
+ unicode-display_width (2.0.0)
76
+ zeitwerk (2.4.2)
78
77
 
79
78
  PLATFORMS
80
79
  ruby
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "datarockets/style"
4
+ require "datarockets_style"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
data/config/base.yml CHANGED
@@ -1,4 +1,4 @@
1
- require: datarockets/style
1
+ require: datarockets_style
2
2
 
3
3
  AllCops:
4
4
  NewCops: enable
@@ -50,6 +50,9 @@ Layout/FirstHashElementIndentation:
50
50
  Layout/MultilineMethodCallIndentation:
51
51
  EnforcedStyle: indented
52
52
 
53
+ Layout/MultilineOperationIndentation:
54
+ EnforcedStyle: indented
55
+
53
56
  Layout/SpaceAroundMethodCallOperator:
54
57
  Enabled: true
55
58
 
@@ -186,3 +189,6 @@ Style/StringConcatenation:
186
189
 
187
190
  Style/StringLiterals:
188
191
  EnforcedStyle: double_quotes
192
+
193
+ Style/TrailingCommaInHashLiteral:
194
+ EnforcedStyleForMultiline: comma
@@ -1,10 +1,10 @@
1
1
  lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "datarockets/style/version"
3
+ require "datarockets_style/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "datarockets-style"
7
- spec.version = Datarockets::Style::VERSION
7
+ spec.version = DatarocketsStyle::VERSION
8
8
  spec.authors = ["Roman Dubrovsky"]
9
9
  spec.email = ["r.dubrovsky@datarockets.com"]
10
10
 
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  spec.add_dependency "rubocop", ">= 1.2 ", "< 2.0"
34
- spec.add_dependency "rubocop-rails", ">= 2.8.0", "< 2.9.0"
34
+ spec.add_dependency "rubocop-rails", ">= 2.8.0", "< 2.10.0"
35
35
  spec.add_dependency "rubocop-rspec", "~> 2.0"
36
36
  end
data/doc/STYLE_GUIDE.md CHANGED
@@ -392,6 +392,46 @@ def foo
392
392
  end
393
393
  ```
394
394
 
395
+ * <a name="style-trailing-comma-in-hash-literal"></a>
396
+ Requires a comma after the last item in a hash.
397
+ <sup>[[link](#style-trailing-comma-in-hash-literal)]</sup>
398
+
399
+ ```ruby
400
+ # bad
401
+ a = { foo: 1, bar: 2, }
402
+
403
+ # good
404
+ a = { foo: 1, bar: 2 }
405
+
406
+ # bad
407
+ a = {
408
+ foo: 1, bar: 2,
409
+ qux: 3,
410
+ }
411
+
412
+ # good
413
+ a = {
414
+ foo: 1, bar: 2,
415
+ qux: 3
416
+ }
417
+
418
+ # bad
419
+ a = {
420
+ foo: 1, bar: 2, qux: 3,
421
+ }
422
+
423
+ # good
424
+ a = {
425
+ foo: 1, bar: 2, qux: 3
426
+ }
427
+
428
+ # good
429
+ a = {
430
+ foo: 1,
431
+ bar: 2,
432
+ }
433
+ ```
434
+
395
435
  * <a name="style-magic-link"></a>
396
436
  There are not any required rules for `frozen_string_literal` magic url.
397
437
  Set up [this cop](https://rubocop.readthedocs.io/en/latest/cops_style/#stylefrozenstringliteralcomment) depends on the project.
@@ -0,0 +1,12 @@
1
+ require "rubocop"
2
+ require "datarockets_style/formatter/todo_list_formatter"
3
+
4
+ require "datarockets_style/version"
5
+
6
+ require "datarockets_style/cop/layout/array_alignment_extended"
7
+ require "datarockets_style/cop/style/nested_interpolation"
8
+
9
+ # Top level module for datarockets-style
10
+ module DatarocketsStyle
11
+ # Datarickors sharable config
12
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DatarocketsStyle
4
+ module Cop
5
+ module Layout
6
+ # Here we check if the elements of a multi-line array literal are
7
+ # aligned.
8
+ #
9
+ # @example EnforcedStyle: with_first_argument (default)
10
+ # # good
11
+ #
12
+ # array = [1, 2, 3,
13
+ # 4, 5, 6]
14
+ # array = ['run',
15
+ # 'forrest',
16
+ # 'run']
17
+ #
18
+ # # bad
19
+ #
20
+ # array = [1, 2, 3,
21
+ # 4, 5, 6]
22
+ # array = ['run',
23
+ # 'forrest',
24
+ # 'run']
25
+ #
26
+ # @example EnforcedStyle: with_fixed_indentation
27
+ # # good
28
+ #
29
+ # array = [1, 2, 3,
30
+ # 4, 5, 6]
31
+ #
32
+ # # bad
33
+ #
34
+ # array = [1, 2, 3,
35
+ # 4, 5, 6]
36
+ class ArrayAlignmentExtended < RuboCop::Cop::Cop
37
+ include RuboCop::Cop::Alignment
38
+
39
+ ALIGN_PARAMS_MSG = "Align the elements of an array literal if they span more than one line."
40
+
41
+ FIXED_INDENT_MSG = "Use one level of indentation for elements " \
42
+ "following the first line of a multi-line array."
43
+
44
+ def on_array(node)
45
+ return if node.children.size < 2
46
+
47
+ check_alignment(node.children, base_column(node, node.children))
48
+ end
49
+
50
+ def autocorrect(node)
51
+ RuboCop::Cop::AlignmentCorrector.correct(processed_source, node, column_delta)
52
+ end
53
+
54
+ private
55
+
56
+ def message(_node)
57
+ fixed_indentation? ? FIXED_INDENT_MSG : ALIGN_PARAMS_MSG
58
+ end
59
+
60
+ def fixed_indentation?
61
+ cop_config["EnforcedStyle"] == "with_fixed_indentation"
62
+ end
63
+
64
+ def base_column(node, args)
65
+ fixed_indentation? ? line_indentation(node) : display_column(args.first.source_range)
66
+ end
67
+
68
+ def line_indentation(node)
69
+ lineno = target_method_lineno(node)
70
+ line = node.source_range.source_buffer.source_line(lineno)
71
+ line_indentation = /\S.*/.match(line).begin(0)
72
+ line_indentation + configured_indentation_width
73
+ end
74
+
75
+ def target_method_lineno(node)
76
+ node.loc.line
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,35 @@
1
+ module DatarocketsStyle
2
+ module Cop
3
+ module Style
4
+ # This cop checks nested interpolations
5
+ #
6
+ # @example
7
+ #
8
+ # # bad
9
+ # "Hello, #{user.blank? ? 'guest' : "dear #{user.name}"}"
10
+ #
11
+ # # good
12
+ # user_name = user.blank? ? 'guest' : "dear #{user.name}"
13
+ # "Hello, #{user_name}"
14
+ class NestedInterpolation < RuboCop::Cop::Cop
15
+ include RuboCop::Cop::Interpolation
16
+
17
+ MSG = "Redundant nested interpolation.".freeze
18
+
19
+ def on_interpolation(node)
20
+ node.each_descendant(:dstr) do |descendant_node|
21
+ detect_double_interpolation(descendant_node)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def detect_double_interpolation(node)
28
+ node.each_child_node(:begin) do |begin_node|
29
+ add_offense(begin_node)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -46,6 +46,6 @@ class TodoListFormatter < RuboCop::Formatter::ProgressFormatter
46
46
  @total_correctable_count)
47
47
  output.puts
48
48
 
49
- Datarockets::Style::Formatter::TodoListFormatter::ReportSummary.new(offense_list).call(output)
49
+ DatarocketsStyle::Formatter::TodoListFormatter::ReportSummary.new(offense_list).call(output)
50
50
  end
51
51
  end
@@ -0,0 +1,55 @@
1
+ module DatarocketsStyle
2
+ module Formatter
3
+ module TodoListFormatter
4
+ # Get file of pairs: file path and cop name - and prepare report for ToDo list formatter.
5
+ #
6
+ # Example of result:
7
+ #
8
+ # LineLength
9
+ # Exclude:
10
+ # - "really/bad/file.rb" # 100500
11
+ # - "almost/ok.rb" # 1
12
+ class ReportSummary
13
+ attr_reader :offense_list
14
+
15
+ FileGroup = Struct.new(:file, :offenses_count) do
16
+ def print(output)
17
+ output.puts " - '#{file}' # #{offenses_count}"
18
+ end
19
+ end
20
+
21
+ OffenseGroup = Struct.new(:cop_name, :offenses) do
22
+ def file_groups
23
+ @_file_groups ||= offenses.group_by(&:file_path).map do |file, offenses|
24
+ FileGroup.new(file, offenses.length)
25
+ end
26
+ end
27
+
28
+ def print(output)
29
+ output.puts("#{cop_name}:")
30
+ output.puts(" Exclude:")
31
+ file_groups.sort_by(&:file).each do |file_group|
32
+ file_group.print(output)
33
+ end
34
+ output.puts
35
+ end
36
+ end
37
+
38
+ def initialize(offense_list)
39
+ @offense_list = offense_list
40
+ end
41
+
42
+ def call(output)
43
+ offense_groups.sort_by(&:cop_name).each { |group| group.print(output) }
44
+ end
45
+
46
+ private
47
+
48
+ def offense_groups
49
+ @_offense_groups ||= offense_list.group_by(&:cop_name)
50
+ .map { |cop_name, offenses| OffenseGroup.new(cop_name, offenses) }
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module DatarocketsStyle
2
+ VERSION = "1.1.0".freeze
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datarockets-style
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Dubrovsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2021-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 2.8.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: 2.9.0
42
+ version: 2.10.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 2.8.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: 2.9.0
52
+ version: 2.10.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rubocop-rspec
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -98,12 +98,12 @@ files:
98
98
  - doc/STYLE_GUIDE.md
99
99
  - doc/STYLE_GUIDE_RAILS.md
100
100
  - doc/STYLE_GUIDE_RSPEC.md
101
- - lib/datarockets/style.rb
102
- - lib/datarockets/style/cop/layout/array_alignment_extended.rb
103
- - lib/datarockets/style/cop/style/nested_interpolation.rb
104
- - lib/datarockets/style/formatter/todo_list_formatter.rb
105
- - lib/datarockets/style/formatter/todo_list_formatter/report_summary.rb
106
- - lib/datarockets/style/version.rb
101
+ - lib/datarockets_style.rb
102
+ - lib/datarockets_style/cop/layout/array_alignment_extended.rb
103
+ - lib/datarockets_style/cop/style/nested_interpolation.rb
104
+ - lib/datarockets_style/formatter/todo_list_formatter.rb
105
+ - lib/datarockets_style/formatter/todo_list_formatter/report_summary.rb
106
+ - lib/datarockets_style/version.rb
107
107
  - manual/cops_layout.md
108
108
  homepage: https://github.com/datarockets/datarockets-style
109
109
  licenses:
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.1.2
128
+ rubygems_version: 3.2.5
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Datarockets style guides and shared style configs
@@ -1,14 +0,0 @@
1
- require "rubocop"
2
- require "datarockets/style/formatter/todo_list_formatter"
3
-
4
- require "datarockets/style/version"
5
-
6
- require "datarockets/style/cop/layout/array_alignment_extended"
7
- require "datarockets/style/cop/style/nested_interpolation"
8
-
9
- module Datarockets
10
- # Datarickors sharable config
11
- module Style
12
- # Your code goes here...
13
- end
14
- end
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datarockets
4
- module Style
5
- module Cop
6
- module Layout
7
- # Here we check if the elements of a multi-line array literal are
8
- # aligned.
9
- #
10
- # @example EnforcedStyle: with_first_argument (default)
11
- # # good
12
- #
13
- # array = [1, 2, 3,
14
- # 4, 5, 6]
15
- # array = ['run',
16
- # 'forrest',
17
- # 'run']
18
- #
19
- # # bad
20
- #
21
- # array = [1, 2, 3,
22
- # 4, 5, 6]
23
- # array = ['run',
24
- # 'forrest',
25
- # 'run']
26
- #
27
- # @example EnforcedStyle: with_fixed_indentation
28
- # # good
29
- #
30
- # array = [1, 2, 3,
31
- # 4, 5, 6]
32
- #
33
- # # bad
34
- #
35
- # array = [1, 2, 3,
36
- # 4, 5, 6]
37
- class ArrayAlignmentExtended < RuboCop::Cop::Cop
38
- include RuboCop::Cop::Alignment
39
-
40
- ALIGN_PARAMS_MSG = "Align the elements of an array literal if they span more than one line."
41
-
42
- FIXED_INDENT_MSG = "Use one level of indentation for elements " \
43
- "following the first line of a multi-line array."
44
-
45
- def on_array(node)
46
- return if node.children.size < 2
47
-
48
- check_alignment(node.children, base_column(node, node.children))
49
- end
50
-
51
- def autocorrect(node)
52
- RuboCop::Cop::AlignmentCorrector.correct(processed_source, node, column_delta)
53
- end
54
-
55
- private
56
-
57
- def message(_node)
58
- fixed_indentation? ? FIXED_INDENT_MSG : ALIGN_PARAMS_MSG
59
- end
60
-
61
- def fixed_indentation?
62
- cop_config["EnforcedStyle"] == "with_fixed_indentation"
63
- end
64
-
65
- def base_column(node, args)
66
- fixed_indentation? ? line_indentation(node) : display_column(args.first.source_range)
67
- end
68
-
69
- def line_indentation(node)
70
- lineno = target_method_lineno(node)
71
- line = node.source_range.source_buffer.source_line(lineno)
72
- line_indentation = /\S.*/.match(line).begin(0)
73
- line_indentation + configured_indentation_width
74
- end
75
-
76
- def target_method_lineno(node)
77
- node.loc.line
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
@@ -1,37 +0,0 @@
1
- module Datarockets
2
- module Style
3
- module Cop
4
- module Style
5
- # This cop checks nested interpolations
6
- #
7
- # @example
8
- #
9
- # # bad
10
- # "Hello, #{user.blank? ? 'guest' : "dear #{user.name}"}"
11
- #
12
- # # good
13
- # user_name = user.blank? ? 'guest' : "dear #{user.name}"
14
- # "Hello, #{user_name}"
15
- class NestedInterpolation < RuboCop::Cop::Cop
16
- include RuboCop::Cop::Interpolation
17
-
18
- MSG = "Redundant nested interpolation.".freeze
19
-
20
- def on_interpolation(node)
21
- node.each_descendant(:dstr) do |descendant_node|
22
- detect_double_interpolation(descendant_node)
23
- end
24
- end
25
-
26
- private
27
-
28
- def detect_double_interpolation(node)
29
- node.each_child_node(:begin) do |begin_node|
30
- add_offense(begin_node)
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,57 +0,0 @@
1
- module Datarockets
2
- module Style
3
- module Formatter
4
- module TodoListFormatter
5
- # Get file of pairs: file path and cop name - and prepare report for ToDo list formatter.
6
- #
7
- # Example of result:
8
- #
9
- # LineLength
10
- # Exclude:
11
- # - "really/bad/file.rb" # 100500
12
- # - "almost/ok.rb" # 1
13
- class ReportSummary
14
- attr_reader :offense_list
15
-
16
- FileGroup = Struct.new(:file, :offenses_count) do
17
- def print(output)
18
- output.puts " - '#{file}' # #{offenses_count}"
19
- end
20
- end
21
-
22
- OffenseGroup = Struct.new(:cop_name, :offenses) do
23
- def file_groups
24
- @_file_groups ||= offenses.group_by(&:file_path).map do |file, offenses|
25
- FileGroup.new(file, offenses.length)
26
- end
27
- end
28
-
29
- def print(output)
30
- output.puts("#{cop_name}:")
31
- output.puts(" Exclude:")
32
- file_groups.sort_by(&:file).each do |file_group|
33
- file_group.print(output)
34
- end
35
- output.puts
36
- end
37
- end
38
-
39
- def initialize(offense_list)
40
- @offense_list = offense_list
41
- end
42
-
43
- def call(output)
44
- offense_groups.sort_by(&:cop_name).each { |group| group.print(output) }
45
- end
46
-
47
- private
48
-
49
- def offense_groups
50
- @_offense_groups ||= offense_list.group_by(&:cop_name)
51
- .map { |cop_name, offenses| OffenseGroup.new(cop_name, offenses) }
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,5 +0,0 @@
1
- module Datarockets
2
- module Style
3
- VERSION = "1.0.0".freeze
4
- end
5
- end