rubocop-chromebrew 0.0.2 → 0.0.3
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/config/default.yml +5 -0
- data/lib/rubocop/cop/chromebrew/compatibility_all.rb +3 -3
- data/lib/rubocop/cop/chromebrew/ordered_compatibility.rb +39 -0
- data/lib/rubocop/cop/chromebrew_cops.rb +1 -0
- data/rubocop-chromebrew.gemspec +2 -2
- data/spec/rubocop/cop/chromebrew/compatibility_all_spec.rb +3 -3
- data/spec/rubocop/cop/chromebrew/ordered_compatibility_spec.rb +41 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0607503886d47cd386967c421e1cbd48cf548b603bef64f6cfd1ebafbd65f9b0'
|
4
|
+
data.tar.gz: ecce859a1eca8fb82bbf17b2735be68e4bcfbfd2344cedb11dd9607fca03b583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ceb68e04f6bc65d767507eb2b0a17b3990af3d0407724426762ab55dbe0f74d88ab6bdce89f40ceb6d23aa7b98bc6b09491603334957f6edd8e7adcaf0c6e97
|
7
|
+
data.tar.gz: 57839de0cfff500323a8d5237d344edd1f6c50e2b487e642d4870ea57ff4f14eafc0aaaf22805d24103fea8dfb9d12e781467ce803491609d75df8a830bab88c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 0.0.3 (2025-02-10)
|
2
|
+
|
3
|
+
### New features
|
4
|
+
|
5
|
+
* Add Chromebrew/OrderedCompatibility cop ([@zopolis4][])
|
6
|
+
|
7
|
+
### Changes
|
8
|
+
|
9
|
+
* Limit Chromebrew/CompatibilityAll offense reporting to the offensive compatibility value rather than the whole node ([@zopolis4][])
|
10
|
+
|
1
11
|
## 0.0.2 (2025-02-02)
|
2
12
|
|
3
13
|
### Bug fixes
|
data/config/default.yml
CHANGED
@@ -5,3 +5,8 @@ Chromebrew/CompatibilityAll:
|
|
5
5
|
Description: "This cop checks for compatibility values that can be replaced by 'all'."
|
6
6
|
Enabled: true
|
7
7
|
VersionAdded: '0.0.1'
|
8
|
+
|
9
|
+
Chromebrew/OrderedCompatibility:
|
10
|
+
Description: 'This cop checks for compatibility values that are not in alphabetical order.'
|
11
|
+
Enabled: true
|
12
|
+
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
|
32
|
-
add_offense(node) do |corrector|
|
33
|
-
corrector.replace(node, "
|
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
|
data/rubocop-chromebrew.gemspec
CHANGED
@@ -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.
|
4
|
+
spec.version = '0.0.3'
|
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/
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zopolis4
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-10 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/
|
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.
|
66
|
+
rubygems_version: 3.6.3
|
65
67
|
specification_version: 4
|
66
68
|
summary: A RuboCop extension for Chromebrew-specific practices.
|
67
69
|
test_files: []
|