rubocop-i18n 1.2.0 → 1.3.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
  SHA1:
3
- metadata.gz: e23a0dde90c58003d524a1baeca709a66c900822
4
- data.tar.gz: 1ddec0669b48c044937bcc2b9c52eeb551eb3651
3
+ metadata.gz: 1519b7393133fbbd4edcc8aa1fdeaa46bd93155b
4
+ data.tar.gz: 2e16dc911733af1dc139d31b69c383b226c3db51
5
5
  SHA512:
6
- metadata.gz: 855e9c7119359d442e3fc9b0833afaaa0adcb6f72de12403d4b4b3cab1e0cc3dea733b82cd001ca7c8bb9728302d3417fa8deae0056f0f56686e62b24737422f
7
- data.tar.gz: 26b98a062a7634ca03c17037f46c7864cdc9bd31e95b2f9a6fd85ed9f8ed381053f36c6449fa95130da881f9afcebe7334c9dc6ead5ee20f2e3c566d362d3d21
6
+ metadata.gz: 9f2110409579d9d8eae8d3d5501a841d6b75dae69b66048563808bb4ed40391256360d48c8700851979d32bf171757469429f5d3a98c7f0a26c4b879ac71ff7d
7
+ data.tar.gz: 8b1fde24e8b0368d2e7139369e3a94e799266f3be6bbb7b79c4bd3a887118adc5c6023ade4413183791856b0dc473e305258e772a1445acb71d3438e32abfd6d
@@ -1 +1,3 @@
1
1
  inherit_from: .rubocop_todo.yml
2
+ require:
3
+ - rubocop/cop/internal_affairs
@@ -1,18 +1,25 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-10-13 16:58:50 -0700 using RuboCop version 0.49.1.
3
+ # on 2018-06-12 15:16:26 -0700 using RuboCop version 0.57.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 6
10
+ Lint/InterpolationCheck:
11
+ Exclude:
12
+ - 'spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation_spec.rb'
13
+ - 'spec/rubocop/cop/i18n/gettext/decorate_string_spec.rb'
14
+
8
15
  # Offense count: 4
9
16
  Metrics/AbcSize:
10
- Max: 31
17
+ Max: 29
11
18
 
12
- # Offense count: 5
19
+ # Offense count: 6
13
20
  # Configuration parameters: CountComments, ExcludedMethods.
14
21
  Metrics/BlockLength:
15
- Max: 68
22
+ Max: 61
16
23
 
17
24
  # Offense count: 1
18
25
  # Configuration parameters: CountComments.
@@ -23,16 +30,10 @@ Metrics/ClassLength:
23
30
  Metrics/CyclomaticComplexity:
24
31
  Max: 8
25
32
 
26
- # Offense count: 86
27
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
28
- # URISchemes: http, https
29
- Metrics/LineLength:
30
- Max: 174
31
-
32
- # Offense count: 6
33
+ # Offense count: 7
33
34
  # Configuration parameters: CountComments.
34
35
  Metrics/MethodLength:
35
- Max: 26
36
+ Max: 25
36
37
 
37
38
  # Offense count: 2
38
39
  Metrics/PerceivedComplexity:
@@ -46,24 +47,35 @@ Style/Documentation:
46
47
  - 'lib/rubocop/cop/i18n/gettext.rb'
47
48
  - 'lib/rubocop/cop/i18n/gettext/decorate_function_message.rb'
48
49
 
49
- # Offense count: 1
50
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
51
- # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
52
- Style/FileName:
53
- Exclude:
54
- - 'lib/rubocop-i18n.rb'
55
-
56
- # Offense count: 7
57
- # Configuration parameters: SupportedStyles.
58
- # SupportedStyles: annotated, template
50
+ # Offense count: 11
51
+ # Configuration parameters: EnforcedStyle.
52
+ # SupportedStyles: annotated, template, unannotated
59
53
  Style/FormatStringToken:
60
- EnforcedStyle: template
54
+ Exclude:
55
+ - 'spec/rubocop/cop/i18n/gettext/decorate_function_message_spec.rb'
56
+ - 'spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation_spec.rb'
57
+ - 'spec/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent_spec.rb'
58
+ - 'spec/rubocop/cop/i18n/gettext/decorate_string_spec.rb'
61
59
 
62
- # Offense count: 4
60
+ # Offense count: 3
63
61
  # Configuration parameters: MinBodyLength.
64
62
  Style/GuardClause:
65
63
  Exclude:
66
64
  - 'lib/rubocop/cop/i18n/gettext/decorate_function_message.rb'
67
- - 'lib/rubocop/cop/i18n/gettext/decorate_string.rb'
68
65
  - 'lib/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation.rb'
69
66
  - 'lib/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent.rb'
67
+
68
+ # Offense count: 10
69
+ # Cop supports --auto-correct.
70
+ Style/IfUnlessModifier:
71
+ Exclude:
72
+ - 'lib/rubocop/cop/i18n/gettext/decorate_function_message.rb'
73
+ - 'lib/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation.rb'
74
+ - 'lib/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent.rb'
75
+ - 'lib/rubocop/rspec/cop_helper.rb'
76
+
77
+ # Offense count: 93
78
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
79
+ # URISchemes: http, https
80
+ Metrics/LineLength:
81
+ Max: 174
data/README.md CHANGED
@@ -256,5 +256,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
256
256
 
257
257
  ## Contributing
258
258
 
259
- Bug reports and pull requests are welcome on GitHub at https://github.com/highb/rubocop-i18n. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
259
+ Bug reports and pull requests are welcome on GitHub at https://github.com/puppetlabs/rubocop-i18n. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
260
260
 
@@ -18,6 +18,14 @@ module RuboCop
18
18
  end
19
19
  end
20
20
 
21
+ def autocorrect(node)
22
+ if node.str_type?
23
+ single_string_correct(node)
24
+ elsif interpolation_offense?(node)
25
+ # interpolation_correct(node)
26
+ end
27
+ end
28
+
21
29
  private
22
30
 
23
31
  def already_decorated?(node, parent = nil)
@@ -33,7 +41,7 @@ module RuboCop
33
41
  end
34
42
 
35
43
  def string_constant?(nodes)
36
- nodes[0].type == :const && nodes[1]
44
+ nodes[0].const_type? && nodes[1]
37
45
  end
38
46
 
39
47
  def contains_string?(nodes)
@@ -51,7 +59,7 @@ module RuboCop
51
59
  error_message << 'message should use correctly formatted interpolation. ' if error == :interpolation
52
60
  error_message << 'message should be decorated. ' if error == :no_decoration
53
61
  end
54
- add_offense(message_section, :expression, error_message)
62
+ add_offense(message_section, message: error_message)
55
63
  end
56
64
 
57
65
  def how_bad_is_it(message_section)
@@ -85,21 +93,13 @@ module RuboCop
85
93
  def interpolation_offense?(node, parent = nil)
86
94
  parent ||= node
87
95
 
88
- return true if node.class == RuboCop::AST::Node && node.dstr_type?
96
+ return true if node.respond_to?(:dstr_type?) && node.dstr_type?
89
97
 
90
98
  return false unless node.respond_to?(:children)
91
99
 
92
100
  node.children.any? { |child| interpolation_offense?(child, parent) }
93
101
  end
94
102
 
95
- def autocorrect(node)
96
- if node.str_type?
97
- single_string_correct(node)
98
- elsif interpolation_offense?(node)
99
- # interpolation_correct(node)
100
- end
101
- end
102
-
103
103
  def single_string_correct(node)
104
104
  lambda { |corrector|
105
105
  corrector.insert_before(node.source_range, '_(')
@@ -114,10 +114,10 @@ module RuboCop
114
114
  node.children.each do |child|
115
115
  # dstrs are split into "str" segments and other segments.
116
116
  # The "other" segments are the interpolated values.
117
- next unless child.type == :begin
117
+ next unless child.begin_type?
118
118
  value = child.children[0]
119
119
  hash_key = 'value'
120
- if value.type == :lvar
120
+ if value.lvar_type?
121
121
  # Use the variable's name as the format key
122
122
  hash_key = value.loc.name.source
123
123
  else
@@ -31,7 +31,7 @@ module RuboCop
31
31
 
32
32
  parent = node.parent
33
33
  if parent.respond_to?(:type)
34
- return if parent.type == :regexp || parent.type == :dstr
34
+ return if parent.regexp_type? || parent.dstr_type?
35
35
  end
36
36
 
37
37
  check_for_parent_decorator(node)
@@ -47,7 +47,7 @@ module RuboCop
47
47
  else
48
48
  false
49
49
  end
50
- elsif child.respond_to?(:type) && child.type == :str
50
+ elsif child.respond_to?(:type) && child.str_type?
51
51
  sentence?(child)
52
52
  else
53
53
  false
@@ -60,13 +60,13 @@ module RuboCop
60
60
 
61
61
  def check_for_parent_decorator(node)
62
62
  parent = node.parent
63
- if parent.respond_to?(:type) && parent.type == :send
63
+ if parent.respond_to?(:type) && parent.send_type?
64
64
  method_name = parent.loc.selector.source
65
65
  return if GetText.supported_decorator?(method_name)
66
66
  elsif parent.respond_to?(:method_name) && parent.method_name == :[]
67
67
  return
68
68
  end
69
- add_offense(node, :expression, 'decorator is missing around sentence')
69
+ add_offense(node, message: 'decorator is missing around sentence')
70
70
  end
71
71
  end
72
72
  end
@@ -27,7 +27,7 @@ module RuboCop
27
27
  _, method_name, *arg_nodes = *node
28
28
  if !arg_nodes.empty? && contains_string_formatting_with_interpolation?(arg_nodes)
29
29
  message_section = arg_nodes[0]
30
- add_offense(message_section, :expression, "'#{method_name}' function, message string should not contain \#{} formatting")
30
+ add_offense(message_section, message: "'#{method_name}' function, message string should not contain \#{} formatting")
31
31
  end
32
32
  end
33
33
 
@@ -43,7 +43,7 @@ module RuboCop
43
43
  end
44
44
 
45
45
  if node.respond_to?(:type)
46
- if node.type == :str || node.type == :dstr
46
+ if node.str_type? || node.dstr_type?
47
47
  return string_contains_interpolation_format?(node.source)
48
48
  end
49
49
  end
@@ -30,7 +30,7 @@ module RuboCop
30
30
  _, method_name, *arg_nodes = *node
31
31
  if !arg_nodes.empty? && contains_string_with_percent_format?(arg_nodes)
32
32
  message_section = arg_nodes[0]
33
- add_offense(message_section, :expression, "'#{method_name}' function, message string should not contain sprintf style formatting (ie %s)")
33
+ add_offense(message_section, message: "'#{method_name}' function, message string should not contain sprintf style formatting (ie %s)")
34
34
  end
35
35
  end
36
36
 
@@ -46,7 +46,7 @@ module RuboCop
46
46
  end
47
47
 
48
48
  if node.respond_to?(:type)
49
- if node.type == :str || node.type == :dstr
49
+ if node.str_type? || node.dstr_type?
50
50
  return string_contains_percent_format?(node.source)
51
51
  end
52
52
  end
@@ -1,12 +1,10 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- rubocop_version = '~> 0.49.0'
3
+ rubocop_version = '~> 0.51'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'rubocop-i18n'
9
- spec.version = '1.2.0'
7
+ spec.version = '1.3.0'
10
8
  spec.authors = ['Puppet', 'Brandon High', 'TP Honey', 'Helen Campbell']
11
9
  spec.email = ['team-modules@puppet.com', 'brandon.high@puppet.com', 'tp@puppet.com', 'helen@puppet.com']
12
10
 
@@ -23,10 +21,10 @@ Gem::Specification.new do |spec|
23
21
  spec.require_paths = ['lib']
24
22
 
25
23
  spec.add_development_dependency 'bundler', '~> 1.14'
24
+ spec.add_development_dependency 'pry'
26
25
  spec.add_development_dependency 'rake', '~> 10.0'
27
- spec.add_development_dependency 'rspec', '~> 3.0'
28
26
  spec.add_development_dependency 'rb-readline'
29
- spec.add_development_dependency 'pry'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
30
28
  spec.add_development_dependency 'rubocop', rubocop_version
31
29
  spec.add_runtime_dependency 'rubocop', rubocop_version
32
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2017-10-17 00:00:00.000000000 Z
14
+ date: 2018-09-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -28,33 +28,33 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.14'
30
30
  - !ruby/object:Gem::Dependency
31
- name: rake
31
+ name: pry
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - "~>"
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: '10.0'
36
+ version: '0'
37
37
  type: :development
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '10.0'
43
+ version: '0'
44
44
  - !ruby/object:Gem::Dependency
45
- name: rspec
45
+ name: rake
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '3.0'
50
+ version: '10.0'
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '3.0'
57
+ version: '10.0'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rb-readline
60
60
  requirement: !ruby/object:Gem::Requirement
@@ -70,47 +70,47 @@ dependencies:
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
- name: pry
73
+ name: rspec
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - ">="
76
+ - - "~>"
77
77
  - !ruby/object:Gem::Version
78
- version: '0'
78
+ version: '3.0'
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ">="
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
- version: '0'
85
+ version: '3.0'
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: rubocop
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: 0.49.0
92
+ version: '0.51'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: 0.49.0
99
+ version: '0.51'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: rubocop
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: 0.49.0
106
+ version: '0.51'
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: 0.49.0
113
+ version: '0.51'
114
114
  description: RuboCop rules for detecting and autocorrecting undecorated strings for
115
115
  i18n
116
116
  email:
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubyforge_project:
166
- rubygems_version: 2.6.6
166
+ rubygems_version: 2.6.14.1
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: RuboCop rules for i18n