rubocop-i18n 3.1.0 → 3.2.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: a8757409734d4423d1eadc150b14ab3ea6d9ba9a0063dc9dd47de719e22ba5f3
4
- data.tar.gz: 52a3962588122fbc261b91ab8a55b038640f169349d93e7f8ccf8e44dd4ec5ab
3
+ metadata.gz: 40440c74a9f3245bc18bc95f36f3fddc4512249611f680ba0a8a8ee3027411a0
4
+ data.tar.gz: f4c16aa614332d0f7938deaee0feedfc6d13bbca695f54a42147aa6911d5226b
5
5
  SHA512:
6
- metadata.gz: aeb2ba4d3bd6cc24d9f88ad0c74e910d0a2b6ab20328d890538f6b60451b0c6e1c92641726b925a6720beddff082e766cbd7a6d30881ad1078d2004b6b077346
7
- data.tar.gz: a61d551a0ee9bb628c10b3e57b2ab8efffb84dcae53939203b9257fb6a92e4c1470df0348654382bbf788b238461ff7ff8f437108cb568644db5dc333af3ad71
6
+ metadata.gz: 06b836f7100a74801a7d3f3c46e2df2a9d620fad44bc5279b92ec3e1748daa1d7b938cdbf496b00f4b8edd541c0d44e3c704720990ebf746f031fc8707b69d94
7
+ data.tar.gz: 0cc9e35e18192a913138a20f442e5f8bbb927aab67caa6a1b381df27e2b126792db86cd21e6842ce76dac165a526416aa27fca447b91d507eb5b722df2c735b4
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ .ruby-version
3
4
  /.config
4
5
  /coverage/
5
6
  /InstalledFiles
@@ -10,6 +11,7 @@
10
11
  /test/version_tmp/
11
12
  /tmp/
12
13
  /.idea/
14
+ Gemfile.lock
13
15
 
14
16
  # Used by dotenv library to load environment variables.
15
17
  # .env
data/.rubocop.yml CHANGED
@@ -1,12 +1,13 @@
1
1
  inherit_from: .rubocop_todo.yml
2
- require:
3
- - rubocop/cop/internal_affairs
2
+
3
+ plugins:
4
+ - rubocop-internal_affairs
4
5
  - rubocop-rake
5
6
  - rubocop-rspec
6
7
  - rubocop-performance
7
8
 
8
9
  AllCops:
9
- TargetRubyVersion: 2.5
10
+ TargetRubyVersion: 2.7
10
11
  NewCops: enable
11
12
 
12
13
  # rubocop-i18n does not have config/default.
data/.rubocop_todo.yml CHANGED
@@ -1,11 +1,19 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-01-15 21:44:52 UTC using RuboCop version 1.70.0.
3
+ # on 2025-01-23 02:17:39 UTC using RuboCop version 1.71.0.
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
8
 
9
+ # Offense count: 4
10
+ InternalAffairs/OnSendWithoutOnCSend:
11
+ Exclude:
12
+ - 'lib/rubocop/cop/i18n/gettext/decorate_function_message.rb'
13
+ - 'lib/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation.rb'
14
+ - 'lib/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent.rb'
15
+ - 'lib/rubocop/cop/i18n/rails_i18n/decorate_string_formatting_using_interpolation.rb'
16
+
9
17
  # Offense count: 1
10
18
  # This cop supports unsafe autocorrection (--autocorrect-all).
11
19
  Lint/InterpolationCheck:
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### [master (Unreleased)](https://github.com/rubocop/rubocop-i18n/compare/v3.1.0...master)
4
4
 
5
+ ### [3.2.0](https://github.com/rubocop/rubocop-i18n/compare/v3.1.0...v3.2.0)
6
+
7
+ * Pluginfy rubocop-i18n (#65)
8
+
5
9
  ### [3.1.0](https://github.com/rubocop/rubocop-i18n/compare/v3.0.0...v3.1.0)
6
10
 
7
11
  * Transfer ownership of rubocop-i18n from puppetlabs org to rubocop org (#62)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rubocop::I18n
2
2
 
3
- [![Build Status](https://travis-ci.com/puppetlabs/rubocop-i18n.svg?branch=master)](https://travis-ci.com/puppetlabs/rubocop-i18n)
3
+ [![CI](https://github.com/rubocop/rubocop-i18n/actions/workflows/rubocop.yml/badge.svg)](https://github.com/rubocop/rubocop-i18n/actions/workflows/rubocop.yml)
4
4
 
5
5
  A set of cops for detecting strings that need i18n decoration in your project.
6
6
 
@@ -28,8 +28,9 @@ Or install it yourself as:
28
28
  ## Usage
29
29
 
30
30
  In your `rubocop.yml`:
31
- ```
32
- require:
31
+
32
+ ```yaml
33
+ plugins:
33
34
  - rubocop-i18n
34
35
  ...
35
36
  # You *must* choose GetText or Rails-i18n style checking
@@ -58,6 +59,9 @@ I18n/RailsI18n/DecorateString:
58
59
  Enabled: false
59
60
  ```
60
61
 
62
+ > [!NOTE]
63
+ > The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
64
+
61
65
  ## Cops
62
66
 
63
67
  ### I18n/GetText/DecorateString
@@ -331,4 +335,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
331
335
 
332
336
  ## Contributing
333
337
 
334
- Bug reports and pull requests are welcome on GitHub at https://github.com/rubocop/rubocop-i18n. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [The RuboCop Community Code of Conduct](CODE_OF_CONDUCT.md).
338
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rubocop/rubocop-i18n. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [RuboCop Community Code of Conduct](CODE_OF_CONDUCT.md).
@@ -33,7 +33,7 @@ module RuboCop
33
33
 
34
34
  parent = node.parent
35
35
  if parent.respond_to?(:type)
36
- return if parent.regexp_type? || parent.dstr_type?
36
+ return if parent.type?(:regexp, :dstr)
37
37
  end
38
38
 
39
39
  check_for_parent_decorator(node)
@@ -44,7 +44,7 @@ module RuboCop
44
44
  def contains_string_formatting_with_interpolation?(node)
45
45
  return node.any? { |n| contains_string_formatting_with_interpolation?(n) } if node.is_a?(Array)
46
46
 
47
- return string_contains_interpolation_format?(node.source) if node.respond_to?(:type) && (node.str_type? || node.dstr_type?)
47
+ return string_contains_interpolation_format?(node.source) if node.respond_to?(:type) && node.type?(:str, :dstr)
48
48
 
49
49
  return node.children.any? { |child| contains_string_formatting_with_interpolation?(child) } if node.respond_to?(:children)
50
50
 
@@ -50,7 +50,7 @@ module RuboCop
50
50
  end
51
51
 
52
52
  if node.respond_to?(:type)
53
- if node.str_type? || node.dstr_type?
53
+ if node.type?(:str, :dstr)
54
54
  return string_contains_percent_format?(node.source)
55
55
  end
56
56
  end
@@ -90,7 +90,7 @@ module RuboCop
90
90
 
91
91
  parent = node.parent
92
92
  if parent.respond_to?(:type)
93
- return if parent.regexp_type? || parent.dstr_type?
93
+ return if parent.type?(:regexp, :dstr)
94
94
  end
95
95
 
96
96
  check_for_parent_decorator(node)
@@ -48,7 +48,7 @@ module RuboCop
48
48
  def contains_string_formatting_with_interpolation?(node)
49
49
  return node.any? { |n| contains_string_formatting_with_interpolation?(n) } if node.is_a?(Array)
50
50
 
51
- return string_contains_interpolation_format?(node.source) if node.respond_to?(:type) && (node.str_type? || node.dstr_type?)
51
+ return string_contains_interpolation_format?(node.source) if node.respond_to?(:type) && node.type?(:str, :dstr)
52
52
 
53
53
  return node.children.any? { |child| contains_string_formatting_with_interpolation?(child) } if node.respond_to?(:children)
54
54
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lint_roller'
4
+
5
+ module RuboCop
6
+ module I18n
7
+ # A plugin that integrates rubocop-i18n with RuboCop's plugin system.
8
+ class Plugin < LintRoller::Plugin
9
+ def about
10
+ LintRoller::About.new(
11
+ name: 'rubocop-i18n',
12
+ version: Version::STRING,
13
+ homepage: 'https://github.com/rubocop/rubocop-i18n',
14
+ description: 'RuboCop rules for i18n.'
15
+ )
16
+ end
17
+
18
+ def supported?(context)
19
+ context.engine == :rubocop
20
+ end
21
+
22
+ def rules(_context)
23
+ LintRoller::Rules.new(
24
+ type: :path,
25
+ config_format: :rubocop,
26
+ value: Pathname.new(__dir__).join('../../../config/default.yml')
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
data/lib/rubocop/i18n.rb CHANGED
@@ -3,9 +3,5 @@
3
3
  module RuboCop
4
4
  # RuboCop I18n project namespace
5
5
  module I18n
6
- PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
7
- CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
8
-
9
- private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
10
6
  end
11
7
  end
data/lib/rubocop-i18n.rb CHANGED
@@ -3,8 +3,5 @@
3
3
  require 'rubocop'
4
4
 
5
5
  require_relative 'rubocop/i18n'
6
- require_relative 'rubocop/i18n/inject'
7
-
8
- RuboCop::I18n::Inject.defaults!
9
-
6
+ require_relative 'rubocop/i18n/plugin'
10
7
  require_relative 'rubocop/cop/i18n_cops'
data/rubocop-i18n.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'rubocop-i18n'
8
- spec.version = '3.1.0'
8
+ spec.version = '3.2.0'
9
9
  spec.authors = ['Puppet', 'Brandon High', 'TP Honey', 'Helen Campbell']
10
10
 
11
11
  spec.summary = 'RuboCop rules for i18n'
@@ -20,11 +20,13 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.required_ruby_version = '>= 2.5.8'
23
+ spec.required_ruby_version = '>= 2.7.0'
24
24
 
25
25
  spec.metadata = {
26
- 'rubygems_mfa_required' => 'true'
26
+ 'rubygems_mfa_required' => 'true',
27
+ 'default_lint_roller_plugin' => 'RuboCop::I18n::Plugin'
27
28
  }
28
29
 
29
- spec.add_dependency 'rubocop', '~> 1.0'
30
+ spec.add_dependency 'lint_roller', '~> 1.1'
31
+ spec.add_dependency 'rubocop', '~> 1.72.1'
30
32
  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: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
@@ -10,22 +10,36 @@ authors:
10
10
  - Helen Campbell
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2025-01-21 00:00:00.000000000 Z
13
+ date: 2025-02-19 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: lint_roller
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.1'
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: rubocop
17
31
  requirement: !ruby/object:Gem::Requirement
18
32
  requirements:
19
33
  - - "~>"
20
34
  - !ruby/object:Gem::Version
21
- version: '1.0'
35
+ version: 1.72.1
22
36
  type: :runtime
23
37
  prerelease: false
24
38
  version_requirements: !ruby/object:Gem::Requirement
25
39
  requirements:
26
40
  - - "~>"
27
41
  - !ruby/object:Gem::Version
28
- version: '1.0'
42
+ version: 1.72.1
29
43
  description: RuboCop rules for detecting and autocorrecting undecorated strings for
30
44
  i18n (gettext and rails-i18n)
31
45
  executables: []
@@ -39,7 +53,6 @@ files:
39
53
  - ".rspec"
40
54
  - ".rubocop.yml"
41
55
  - ".rubocop_todo.yml"
42
- - ".ruby-version"
43
56
  - CHANGELOG.md
44
57
  - CODE_OF_CONDUCT.md
45
58
  - Gemfile
@@ -60,13 +73,14 @@ files:
60
73
  - lib/rubocop/cop/i18n/rails_i18n/decorate_string_formatting_using_interpolation.rb
61
74
  - lib/rubocop/cop/i18n_cops.rb
62
75
  - lib/rubocop/i18n.rb
63
- - lib/rubocop/i18n/inject.rb
76
+ - lib/rubocop/i18n/plugin.rb
64
77
  - rubocop-i18n.gemspec
65
78
  homepage: https://github.com/rubocop/rubocop-i18n
66
79
  licenses:
67
80
  - Apache-2.0
68
81
  metadata:
69
82
  rubygems_mfa_required: 'true'
83
+ default_lint_roller_plugin: RuboCop::I18n::Plugin
70
84
  rdoc_options: []
71
85
  require_paths:
72
86
  - lib
@@ -74,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
88
  requirements:
75
89
  - - ">="
76
90
  - !ruby/object:Gem::Version
77
- version: 2.5.8
91
+ version: 2.7.0
78
92
  required_rubygems_version: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ">="
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.4.1
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module I18n
5
- # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
6
- # bit of our configuration.
7
- module Inject
8
- def self.defaults!
9
- path = CONFIG_DEFAULT.to_s
10
- hash = ConfigLoader.send(:load_yaml_configuration, path)
11
- config = RuboCop::Config.new(hash, path)
12
- puts "configuration from #{path}" if ConfigLoader.debug?
13
- config = ConfigLoader.merge_with_default(config, path)
14
- ConfigLoader.instance_variable_set(:@default_configuration, config)
15
- end
16
- end
17
- end
18
- end