rubocop-chromebrew 0.0.2 → 0.0.4

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: c3d431011e66045f1bd16d7c3e92ddb7f3a9b8008ba59ee9e784c7d768e24f39
4
- data.tar.gz: 7cc26b424245fb3d123443ffed2e1180255b0795d59e5d7c418df1b6d5364679
3
+ metadata.gz: 813fad19ddbaa64b268ceac478ef0d764a86dab0731de35e92d75c1fe62d5b2e
4
+ data.tar.gz: d80f5ff6b5cdf5601f285eb1f931395cf2a1a1338277d297edba1bf08744abfe
5
5
  SHA512:
6
- metadata.gz: 24d466bd63143724e77fc4530bb070c16de17f2f703f24420ce458b84023b9d02dc168d77e4fea127a30e70c1edbca7538cacd313c7ad23e2eb0bf67d693cab1
7
- data.tar.gz: 890d6b1d53b9034f0ad4b7eee71231f97a5d956c9d8f930ca84c8d75a9ba357e7de8580c9e19436db31b19c45deb5d88e48e0bc665346e21e14ff10ca8046f31
6
+ metadata.gz: ac4ac31978d9421440a77d1818c4e9b43e70a40f0dd9ec6d2205f0852fc6cd1528840de8efc584d6ba3394a46b96eb91da15a63de8bff3cad5857bc273dbdb57
7
+ data.tar.gz: cd537f9567def5b66d856b47941914935f7258950c1f0bec721b7d706a6a9c87149edca17a3491dc1005e049d9c15c5d3e08c53f0976849a790c562cfa173fd9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 0.0.4 (2025-03-12)
2
+
3
+ ### Bug fixes
4
+
5
+ * Fix disabling all non-Chromebrew cops when the extension is required ([@zopolis4][])
6
+
7
+ ## 0.0.3 (2025-02-10)
8
+
9
+ ### New features
10
+
11
+ * Add Chromebrew/OrderedCompatibility cop ([@zopolis4][])
12
+
13
+ ### Changes
14
+
15
+ * Limit Chromebrew/CompatibilityAll offense reporting to the offensive compatibility value rather than the whole node ([@zopolis4][])
16
+
1
17
  ## 0.0.2 (2025-02-02)
2
18
 
3
19
  ### Bug fixes
data/config/default.yml CHANGED
@@ -1,7 +1,9 @@
1
- AllCops:
2
- DisabledByDefault: true
3
-
4
1
  Chromebrew/CompatibilityAll:
5
2
  Description: "This cop checks for compatibility values that can be replaced by 'all'."
6
3
  Enabled: true
7
4
  VersionAdded: '0.0.1'
5
+
6
+ Chromebrew/OrderedCompatibility:
7
+ Description: 'This cop checks for compatibility values that are not in alphabetical order.'
8
+ Enabled: true
9
+ VersionAdded: '0.0.3'
@@ -28,9 +28,9 @@ module RuboCop
28
28
  # Check if the compatibility value includes all four architectures.
29
29
  return unless architectures.all? { |arch| value.include?(arch) }
30
30
 
31
- # If requested, replace the offending line with compatibility 'all'.
32
- add_offense(node) do |corrector|
33
- corrector.replace(node, "compatibility 'all'")
31
+ # If requested, replace the offending compatibility value with 'all'.
32
+ add_offense(node.children.last) do |corrector|
33
+ corrector.replace(node.children.last, "'all'")
34
34
  end
35
35
  end
36
36
  end
@@ -0,0 +1,39 @@
1
+ module RuboCop
2
+ module Cop
3
+ module Chromebrew
4
+ # Compatibility values should be in alphabetic order.
5
+ #
6
+ # @example
7
+ # # bad
8
+ # compatibility 'x86_64 aarch64 armv7l'
9
+ #
10
+ # # good
11
+ # compatibility 'aarch64 armv7l x86_64'
12
+ #
13
+ class OrderedCompatibility < Base
14
+ extend AutoCorrector
15
+ MSG = 'Compatibility values should be in alphabetical order.'
16
+
17
+ def_node_matcher :compatibility?, <<~PATTERN
18
+ (send nil? :compatibility
19
+ (str $_))
20
+ PATTERN
21
+
22
+ def on_send(node)
23
+ # Check that we're operating on the compatibility property.
24
+ value = compatibility?(node)
25
+ return unless value
26
+
27
+ sorted_value = value.split.sort.join(' ')
28
+
29
+ return if sorted_value == value
30
+
31
+ # If requested, replace the offending compatibility value with the sorted version.
32
+ add_offense(node.children.last) do |corrector|
33
+ corrector.replace(node.children.last, "'#{sorted_value}'")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1 +1,2 @@
1
1
  require_relative 'chromebrew/compatibility_all'
2
+ require_relative 'chromebrew/ordered_compatibility'
@@ -1,11 +1,11 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'rubocop-chromebrew'
3
3
  spec.summary = 'A RuboCop extension for Chromebrew-specific practices.'
4
- spec.version = '0.0.2'
4
+ spec.version = '0.0.4'
5
5
  spec.license = 'GPL-3.0-or-later'
6
6
  spec.author = 'Zopolis4'
7
7
  spec.email = 'creatorsmithmdt@gmail.com'
8
- spec.homepage = 'https://github.com/Zopolis4/rubocop-chromebrew'
8
+ spec.homepage = 'https://github.com/chromebrew/rubocop-chromebrew'
9
9
 
10
10
  spec.files = `git ls-files`.split("\n")
11
11
  spec.require_paths = ['lib']
@@ -2,7 +2,7 @@ RSpec.describe RuboCop::Cop::Chromebrew::CompatibilityAll, :config do
2
2
  it 'registers an offense when all four architectures are listed' do
3
3
  expect_offense(<<~'RUBY')
4
4
  compatibility 'aarch64 armv7l i686 x86_64'
5
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
5
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
6
6
  RUBY
7
7
 
8
8
  expect_correction(<<~'RUBY')
@@ -13,7 +13,7 @@ RSpec.describe RuboCop::Cop::Chromebrew::CompatibilityAll, :config do
13
13
  it 'registers an offense when all four architectures are listed with commas' do
14
14
  expect_offense(<<~'RUBY')
15
15
  compatibility 'aarch64, armv7l, i686, x86_64'
16
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
16
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
17
17
  RUBY
18
18
 
19
19
  expect_correction(<<~'RUBY')
@@ -24,7 +24,7 @@ RSpec.describe RuboCop::Cop::Chromebrew::CompatibilityAll, :config do
24
24
  it 'registers an offense when all four architectures are listed in a different order' do
25
25
  expect_offense(<<~'RUBY')
26
26
  compatibility 'i686 armv7l x86_64 aarch64'
27
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
27
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
28
28
  RUBY
29
29
 
30
30
  expect_correction(<<~'RUBY')
@@ -0,0 +1,41 @@
1
+ RSpec.describe RuboCop::Cop::Chromebrew::OrderedCompatibility, :config do
2
+ it 'registers an offense when compatibiltiy is not in alphabetical order with three elements' do
3
+ expect_offense(<<~'RUBY')
4
+ compatibility 'x86_64 aarch64 armv7l'
5
+ ^^^^^^^^^^^^^^^^^^^^^^^ Compatibility values should be in alphabetical order.
6
+ RUBY
7
+
8
+ expect_correction(<<~'RUBY')
9
+ compatibility 'aarch64 armv7l x86_64'
10
+ RUBY
11
+ end
12
+
13
+ it 'registers an offense when compatibiltiy is not in alphabetical order with two elements' do
14
+ expect_offense(<<~'RUBY')
15
+ compatibility 'x86_64 i686'
16
+ ^^^^^^^^^^^^^ Compatibility values should be in alphabetical order.
17
+ RUBY
18
+
19
+ expect_correction(<<~'RUBY')
20
+ compatibility 'i686 x86_64'
21
+ RUBY
22
+ end
23
+
24
+ it 'does not register an offense when compatibility is in alphabetical order' do
25
+ expect_no_offenses(<<~'RUBY')
26
+ compatibility 'aarch64 armv7l x86_64'
27
+ RUBY
28
+ end
29
+
30
+ it 'does not register an offense when compatibility is a single architecture' do
31
+ expect_no_offenses(<<~'RUBY')
32
+ compatibility 'x86_64'
33
+ RUBY
34
+ end
35
+
36
+ it 'does not register an offense when compatibility is all' do
37
+ expect_no_offenses(<<~'RUBY')
38
+ compatibility 'all'
39
+ RUBY
40
+ end
41
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-chromebrew
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zopolis4
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-02 00:00:00.000000000 Z
10
+ date: 2025-03-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rubocop
@@ -39,11 +39,13 @@ files:
39
39
  - lib/rubocop/chromebrew.rb
40
40
  - lib/rubocop/chromebrew/inject.rb
41
41
  - lib/rubocop/cop/chromebrew/compatibility_all.rb
42
+ - lib/rubocop/cop/chromebrew/ordered_compatibility.rb
42
43
  - lib/rubocop/cop/chromebrew_cops.rb
43
44
  - rubocop-chromebrew.gemspec
44
45
  - spec/rubocop/cop/chromebrew/compatibility_all_spec.rb
46
+ - spec/rubocop/cop/chromebrew/ordered_compatibility_spec.rb
45
47
  - spec/spec_helper.rb
46
- homepage: https://github.com/Zopolis4/rubocop-chromebrew
48
+ homepage: https://github.com/chromebrew/rubocop-chromebrew
47
49
  licenses:
48
50
  - GPL-3.0-or-later
49
51
  metadata: {}
@@ -61,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
63
  - !ruby/object:Gem::Version
62
64
  version: '0'
63
65
  requirements: []
64
- rubygems_version: 3.6.2
66
+ rubygems_version: 3.6.5
65
67
  specification_version: 4
66
68
  summary: A RuboCop extension for Chromebrew-specific practices.
67
69
  test_files: []