rubocop-i18n 3.1.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8757409734d4423d1eadc150b14ab3ea6d9ba9a0063dc9dd47de719e22ba5f3
4
- data.tar.gz: 52a3962588122fbc261b91ab8a55b038640f169349d93e7f8ccf8e44dd4ec5ab
3
+ metadata.gz: fda7be0dbfbfc1501a16330bb1e4cc629a91d9f3a87635ea563e161e9fa66c97
4
+ data.tar.gz: 7919994e5321618fe590f699c39f0056bdba4ba8269d89fe6be91548a5ec5404
5
5
  SHA512:
6
- metadata.gz: aeb2ba4d3bd6cc24d9f88ad0c74e910d0a2b6ab20328d890538f6b60451b0c6e1c92641726b925a6720beddff082e766cbd7a6d30881ad1078d2004b6b077346
7
- data.tar.gz: a61d551a0ee9bb628c10b3e57b2ab8efffb84dcae53939203b9257fb6a92e4c1470df0348654382bbf788b238461ff7ff8f437108cb568644db5dc333af3ad71
6
+ metadata.gz: 119d18b16d3dec2a93a84861516f8ca4f79e1878cf71e63a400c9c24e9eb9da0579fc8c0b61963a0285e4509874ca5ffe51942f8dc95acb3b920b0f830176c34
7
+ data.tar.gz: 32115fb43cadb384bceeff872b5640a70641e8da497ac189a6ccfd8c567cd9966dfd3e90b9548b31e2e9d681d709ce3ba68d21c8ce9384890c6171b68f6d98a6
@@ -8,9 +8,11 @@ assignees: ''
8
8
  ---
9
9
 
10
10
  **Describe the bug**
11
+
11
12
  A clear and concise description of what the bug is.
12
13
 
13
14
  **To Reproduce**
15
+
14
16
  Steps to reproduce the behavior:
15
17
  1. Go to '...'
16
18
  2. Click on '....'
@@ -18,21 +20,39 @@ Steps to reproduce the behavior:
18
20
  4. See error
19
21
 
20
22
  **Expected behavior**
23
+
21
24
  A clear and concise description of what you expected to happen.
22
25
 
23
26
  **Screenshots**
27
+
24
28
  If applicable, add screenshots to help explain your problem.
25
29
 
26
30
  **Desktop (please complete the following information):**
31
+
27
32
  - OS: [e.g. iOS]
28
33
  - Browser [e.g. chrome, safari]
29
34
  - Version [e.g. 22]
30
35
 
31
36
  **Smartphone (please complete the following information):**
37
+
32
38
  - Device: [e.g. iPhone6]
33
39
  - OS: [e.g. iOS8.1]
34
40
  - Browser [e.g. stock browser, safari]
35
41
  - Version [e.g. 22]
36
42
 
37
43
  **Additional context**
44
+
38
45
  Add any other context about the problem here.
46
+
47
+ **RuboCop version**
48
+
49
+ Include the output of `rubocop -V` or `bundle exec rubocop -V` if using Bundler.
50
+ If you see extension cop versions (e.g. `rubocop-performance`, `rubocop-rspec`, and others)
51
+ output by `rubocop -V`, include them as well. Here's an example:
52
+
53
+ ```console
54
+ $ [bundle exec] rubocop -V
55
+ 1.73.1 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux]
56
+ - rubocop-performance 1.22.1
57
+ - rubocop-rspec 3.1.0
58
+ ```
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
@@ -1,6 +1,14 @@
1
1
  # Change Log
2
2
 
3
- ### [master (Unreleased)](https://github.com/rubocop/rubocop-i18n/compare/v3.1.0...master)
3
+ ### [master (Unreleased)](https://github.com/rubocop/rubocop-i18n/compare/v3.2.1...master)
4
+
5
+ ### [3.2.1](https://github.com/rubocop/rubocop-i18n/compare/v3.2.0...v3.2.1)
6
+
7
+ * Make the runtime dependency on RuboCop more flexible.
8
+
9
+ ### [3.2.0](https://github.com/rubocop/rubocop-i18n/compare/v3.1.0...v3.2.0)
10
+
11
+ * Pluginfy rubocop-i18n (#65)
4
12
 
5
13
  ### [3.1.0](https://github.com/rubocop/rubocop-i18n/compare/v3.0.0...v3.1.0)
6
14
 
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).
data/Rakefile CHANGED
@@ -11,5 +11,5 @@ task test: %i[rubocop spec]
11
11
 
12
12
  desc 'Run RuboCop'
13
13
  task :rubocop do
14
- sh 'rubocop -P'
14
+ sh 'rubocop'
15
15
  end
@@ -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.1'
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.1
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-03-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: rubocop
16
+ name: lint_roller
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.0'
21
+ version: '1.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '1.0'
28
+ version: '1.1'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rubocop
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.72.1
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
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