rubocop-cask 0.22.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cask/ast/cask_header.rb +1 -17
- data/lib/rubocop/cask/constants.rb +0 -3
- data/lib/rubocop/cask/extend/node.rb +1 -7
- data/lib/rubocop/cask/version.rb +1 -1
- data/lib/rubocop/cop/cask/homepage_matches_url.rb +4 -3
- data/spec/rubocop/cop/cask/homepage_matches_url_spec.rb +3 -2
- data/spec/rubocop/cop/cask/no_dsl_version_spec.rb +0 -45
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0416ad989e2e206697e6e3a255f6ca37c4455134453cb8d79225dd275743728d
|
4
|
+
data.tar.gz: bd884af3ba5b89ac48b69070c7d6d53a2176ab381ee64d5996d042c125a0cd85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 607c4f15c81aa2592ac0812b6472c5ee62f95439eb972bbfc6636664e8ba586c62f38e53a2e362444e5acfd3ced5206f642bdc638038ff179bfc39ea1bd932e6
|
7
|
+
data.tar.gz: b453fc2ca3ffd8f6680094890acb691d992095dd7bfa7fc14ba8a9f1e99141c8b13ecc4381d7b4b88d3eee93f0cdac413c20f721f392866c084c6e83332b08c0
|
@@ -14,10 +14,6 @@ module RuboCop
|
|
14
14
|
hash_node
|
15
15
|
end
|
16
16
|
|
17
|
-
def test_cask?
|
18
|
-
header_method_name == :test_cask || dsl_version.to_s.include?('test')
|
19
|
-
end
|
20
|
-
|
21
17
|
def header_str
|
22
18
|
@header_str ||= source_range.source
|
23
19
|
end
|
@@ -27,19 +23,7 @@ module RuboCop
|
|
27
23
|
end
|
28
24
|
|
29
25
|
def preferred_header_str
|
30
|
-
"
|
31
|
-
end
|
32
|
-
|
33
|
-
def preferred_header_method_name
|
34
|
-
test_cask? ? :test_cask : :cask
|
35
|
-
end
|
36
|
-
|
37
|
-
def header_method_name
|
38
|
-
@header_method_name ||= method_node.method_name
|
39
|
-
end
|
40
|
-
|
41
|
-
def dsl_version
|
42
|
-
@dsl_version ||= pair_node.key_node.children.first
|
26
|
+
"cask '#{cask_token}'"
|
43
27
|
end
|
44
28
|
|
45
29
|
def cask_token
|
@@ -2,14 +2,11 @@ module RuboCop
|
|
2
2
|
module Cask
|
3
3
|
# Constants available globally for use in all Cask cops.
|
4
4
|
module Constants
|
5
|
-
CASK_METHOD_NAMES = [:cask, :test_cask].freeze
|
6
|
-
|
7
5
|
STANZA_GROUPS = [
|
8
6
|
[:version, :sha256],
|
9
7
|
[:url, :appcast, :name, :homepage],
|
10
8
|
[
|
11
9
|
:auto_updates,
|
12
|
-
:accessibility_access,
|
13
10
|
:conflicts_with,
|
14
11
|
:depends_on,
|
15
12
|
:container
|
@@ -11,13 +11,7 @@ module RuboCop
|
|
11
11
|
def_node_matcher :key_node, '{(pair $_ _) (hash (pair $_ _) ...)}'
|
12
12
|
def_node_matcher :val_node, '{(pair _ $_) (hash (pair _ $_) ...)}'
|
13
13
|
|
14
|
-
|
15
|
-
block_type? && method_node.cask_header?
|
16
|
-
end
|
17
|
-
|
18
|
-
def cask_header?
|
19
|
-
send_type? && CASK_METHOD_NAMES.include?(method_name)
|
20
|
-
end
|
14
|
+
def_node_matcher :cask_block?, '(block (send nil? :cask _) args ...)'
|
21
15
|
|
22
16
|
def stanza?
|
23
17
|
(send_type? || block_type?) && STANZA_ORDER.include?(method_name)
|
data/lib/rubocop/cask/version.rb
CHANGED
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
|
15
15
|
REFERENCE_URL = 'https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-a-comment'.freeze
|
16
16
|
|
17
|
-
COMMENT_FORMAT = /# [^ ]+ was verified as official when first introduced to the cask
|
17
|
+
COMMENT_FORMAT = /# [^ ]+ was verified as official when first introduced to the cask/.freeze
|
18
18
|
|
19
19
|
MSG_NO_MATCH = '`%<url>s` does not match `%<full_url>s`'.freeze
|
20
20
|
|
@@ -24,8 +24,8 @@ module RuboCop
|
|
24
24
|
MSG_WRONG_FORMAT = '`%<comment>s` does not match the expected comment format. ' \
|
25
25
|
'For details, see ' + REFERENCE_URL
|
26
26
|
|
27
|
-
MSG_UNNECESSARY = '`%<domain>s` matches `%<homepage>s`,
|
28
|
-
'stanza is unnecessary'.freeze
|
27
|
+
MSG_UNNECESSARY = 'The URL\'s domain `%<domain>s` matches the homepage `%<homepage>s`, ' \
|
28
|
+
'the comment above the `url` stanza is unnecessary'.freeze
|
29
29
|
|
30
30
|
def on_cask(cask_block)
|
31
31
|
@cask_block = cask_block
|
@@ -52,6 +52,7 @@ module RuboCop
|
|
52
52
|
def add_offense_unnecessary_comment(stanza)
|
53
53
|
return unless comment?(stanza)
|
54
54
|
return unless url_match_homepage?(stanza)
|
55
|
+
return unless comment_matches_format?(stanza)
|
55
56
|
return unless comment_matches_url?(stanza)
|
56
57
|
|
57
58
|
comment = comment(stanza).loc.expression
|
@@ -75,8 +75,9 @@ describe RuboCop::Cop::Cask::HomepageMatchesUrl do
|
|
75
75
|
end
|
76
76
|
let(:expected_offenses) do
|
77
77
|
[{
|
78
|
-
message: '`foo.example.com` matches
|
79
|
-
'the comment above the `url` stanza is
|
78
|
+
message: 'The URL\'s domain `foo.example.com` matches the homepage ' \
|
79
|
+
'`example.com`, the comment above the `url` stanza is ' \
|
80
|
+
'unnecessary',
|
80
81
|
severity: :convention,
|
81
82
|
line: 2,
|
82
83
|
column: 2,
|
@@ -29,50 +29,5 @@ describe RuboCop::Cop::Cask::NoDslVersion do
|
|
29
29
|
|
30
30
|
include_examples 'autocorrects source'
|
31
31
|
end
|
32
|
-
|
33
|
-
context 'with dsl version containing "test"' do
|
34
|
-
let(:source) { "cask :v1test => 'foo' do; end" }
|
35
|
-
let(:correct_source) { "test_cask 'foo' do; end" }
|
36
|
-
let(:expected_offenses) do
|
37
|
-
[{
|
38
|
-
message: "Use `test_cask 'foo'` instead of `cask :v1test => 'foo'`",
|
39
|
-
severity: :convention,
|
40
|
-
line: 1,
|
41
|
-
column: 0,
|
42
|
-
source: "cask :v1test => 'foo'"
|
43
|
-
}]
|
44
|
-
end
|
45
|
-
|
46
|
-
include_examples 'reports offenses'
|
47
|
-
|
48
|
-
include_examples 'autocorrects source'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'with header method `test_cask`' do
|
53
|
-
context 'with no dsl version' do
|
54
|
-
let(:source) { "test_cask 'foo' do; end" }
|
55
|
-
|
56
|
-
include_examples 'does not report any offenses'
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'with dsl version' do
|
60
|
-
let(:source) { "test_cask :v1 => 'foo' do; end" }
|
61
|
-
let(:correct_source) { "test_cask 'foo' do; end" }
|
62
|
-
let(:expected_offenses) do
|
63
|
-
[{
|
64
|
-
message: "Use `test_cask 'foo'` instead of "\
|
65
|
-
"`test_cask :v1 => 'foo'`",
|
66
|
-
severity: :convention,
|
67
|
-
line: 1,
|
68
|
-
column: 0,
|
69
|
-
source: "test_cask :v1 => 'foo'"
|
70
|
-
}]
|
71
|
-
end
|
72
|
-
|
73
|
-
include_examples 'reports offenses'
|
74
|
-
|
75
|
-
include_examples 'autocorrects source'
|
76
|
-
end
|
77
32
|
end
|
78
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-cask
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Hagins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: public_suffix
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 0.60.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.60.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.7.
|
132
|
+
rubygems_version: 2.7.8
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Code style checking for Homebrew-Cask files
|