rubocop-chromebrew 0.0.1 → 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/.github/workflows/test.yml +17 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +16 -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/lib/rubocop-chromebrew.rb +1 -1
- data/rubocop-chromebrew.gemspec +2 -2
- data/spec/rubocop/cop/chromebrew/compatibility_all_spec.rb +40 -0
- data/spec/rubocop/cop/chromebrew/ordered_compatibility_spec.rb +41 -0
- data/spec/spec_helper.rb +14 -0
- metadata +10 -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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: Test
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
steps:
|
7
|
+
- name: Download source
|
8
|
+
uses: actions/checkout@v4
|
9
|
+
- name: Install Ruby
|
10
|
+
uses: ruby/setup-ruby@v1
|
11
|
+
with:
|
12
|
+
ruby-version: '3.4.1'
|
13
|
+
# TODO: Convert this to a Gemfile when we have multiple/versioned dependencies.
|
14
|
+
- name: Install dependencies
|
15
|
+
run: gem install rspec rubocop
|
16
|
+
- name: Run spec
|
17
|
+
run: rspec
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
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
|
+
|
11
|
+
## 0.0.2 (2025-02-02)
|
12
|
+
|
13
|
+
### Bug fixes
|
14
|
+
|
15
|
+
* Fix cop loading ([@zopolis4][])
|
16
|
+
|
1
17
|
## 0.0.1 (2024-06-18)
|
2
18
|
|
3
19
|
### New features
|
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/lib/rubocop-chromebrew.rb
CHANGED
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']
|
@@ -0,0 +1,40 @@
|
|
1
|
+
RSpec.describe RuboCop::Cop::Chromebrew::CompatibilityAll, :config do
|
2
|
+
it 'registers an offense when all four architectures are listed' do
|
3
|
+
expect_offense(<<~'RUBY')
|
4
|
+
compatibility 'aarch64 armv7l i686 x86_64'
|
5
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
|
6
|
+
RUBY
|
7
|
+
|
8
|
+
expect_correction(<<~'RUBY')
|
9
|
+
compatibility 'all'
|
10
|
+
RUBY
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'registers an offense when all four architectures are listed with commas' do
|
14
|
+
expect_offense(<<~'RUBY')
|
15
|
+
compatibility 'aarch64, armv7l, i686, x86_64'
|
16
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
|
17
|
+
RUBY
|
18
|
+
|
19
|
+
expect_correction(<<~'RUBY')
|
20
|
+
compatibility 'all'
|
21
|
+
RUBY
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'registers an offense when all four architectures are listed in a different order' do
|
25
|
+
expect_offense(<<~'RUBY')
|
26
|
+
compatibility 'i686 armv7l x86_64 aarch64'
|
27
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compatibility properties which match all architectures should be replaced with 'all'
|
28
|
+
RUBY
|
29
|
+
|
30
|
+
expect_correction(<<~'RUBY')
|
31
|
+
compatibility 'all'
|
32
|
+
RUBY
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'does not register an offense when only some architectures are listed' do
|
36
|
+
expect_no_offenses(<<~'RUBY')
|
37
|
+
compatibility 'i686 x86_64'
|
38
|
+
RUBY
|
39
|
+
end
|
40
|
+
end
|
@@ -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
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubocop-chromebrew'
|
2
|
+
require 'rubocop/rspec/support'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.include RuboCop::RSpec::ExpectOffense
|
6
|
+
|
7
|
+
config.disable_monkey_patching!
|
8
|
+
config.raise_errors_for_deprecations!
|
9
|
+
config.raise_on_warning = true
|
10
|
+
config.fail_if_no_examples = true
|
11
|
+
|
12
|
+
config.order = :random
|
13
|
+
Kernel.srand config.seed
|
14
|
+
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-
|
10
|
+
date: 2025-02-10 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rubocop
|
@@ -28,7 +28,9 @@ executables: []
|
|
28
28
|
extensions: []
|
29
29
|
extra_rdoc_files: []
|
30
30
|
files:
|
31
|
+
- ".github/workflows/test.yml"
|
31
32
|
- ".gitignore"
|
33
|
+
- ".rspec"
|
32
34
|
- CHANGELOG.md
|
33
35
|
- LICENSE
|
34
36
|
- README.md
|
@@ -37,9 +39,13 @@ files:
|
|
37
39
|
- lib/rubocop/chromebrew.rb
|
38
40
|
- lib/rubocop/chromebrew/inject.rb
|
39
41
|
- lib/rubocop/cop/chromebrew/compatibility_all.rb
|
42
|
+
- lib/rubocop/cop/chromebrew/ordered_compatibility.rb
|
40
43
|
- lib/rubocop/cop/chromebrew_cops.rb
|
41
44
|
- rubocop-chromebrew.gemspec
|
42
|
-
|
45
|
+
- spec/rubocop/cop/chromebrew/compatibility_all_spec.rb
|
46
|
+
- spec/rubocop/cop/chromebrew/ordered_compatibility_spec.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
homepage: https://github.com/chromebrew/rubocop-chromebrew
|
43
49
|
licenses:
|
44
50
|
- GPL-3.0-or-later
|
45
51
|
metadata: {}
|
@@ -57,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
63
|
- !ruby/object:Gem::Version
|
58
64
|
version: '0'
|
59
65
|
requirements: []
|
60
|
-
rubygems_version: 3.6.
|
66
|
+
rubygems_version: 3.6.3
|
61
67
|
specification_version: 4
|
62
68
|
summary: A RuboCop extension for Chromebrew-specific practices.
|
63
69
|
test_files: []
|