rubocop-cask 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24d992c9eea4197d74d5c85d4a61fe4cace1527e
|
4
|
+
data.tar.gz: bf06c75b18669a7bf7e64a0a6919e8797d55c5ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2da13aead784851dea5e2889aeb14106e788630225200fa9f058b9e8b186b9ab2e0a33442f5dff1918204cfe24938bff13cfc8230a40484c74225c514e2c28f4
|
7
|
+
data.tar.gz: 575ec4e8f2149ec6b8681ba8ad2eed4407fecfd43b00a458df677f19d9c8039ccc4f2b7a05a1facfe9d579451101d2d1f8c42b825bb4a673e6840de1fd78ee16
|
data/lib/rubocop/cask/version.rb
CHANGED
@@ -12,11 +12,17 @@ module RuboCop
|
|
12
12
|
extend Forwardable
|
13
13
|
include CaskHelp
|
14
14
|
|
15
|
+
REFERENCE_URL = 'https://github.com/caskroom/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-a-comment'.freeze
|
16
|
+
|
17
|
+
COMMENT_FORMAT = /# [^ ]+ was verified as official when first introduced to the cask/
|
18
|
+
|
15
19
|
MSG_NO_MATCH = '`%s` does not match `%s`'.freeze
|
16
20
|
|
17
21
|
MSG_MISSING = '`%s` does not match `%s`, a comment has to be added ' \
|
18
|
-
'above the `url` stanza. For details, see '
|
19
|
-
|
22
|
+
'above the `url` stanza. For details, see ' + REFERENCE_URL
|
23
|
+
|
24
|
+
MSG_WRONG_FORMAT = '`%s` does not match the expected comment format. ' \
|
25
|
+
'For details, see ' + REFERENCE_URL
|
20
26
|
|
21
27
|
MSG_UNNECESSARY = '`%s` matches `%s`, the comment above the `url` ' \
|
22
28
|
'stanza is unnecessary'.freeze
|
@@ -34,35 +40,53 @@ module RuboCop
|
|
34
40
|
|
35
41
|
def add_offenses
|
36
42
|
toplevel_stanzas.select(&:url?).each do |url|
|
37
|
-
if
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
add_offense_missing_comment(url)
|
42
|
-
elsif !comment_matches_url?(url)
|
43
|
-
add_offense_no_match(url)
|
44
|
-
end
|
43
|
+
next if add_offense_unnecessary_comment(url)
|
44
|
+
next if add_offense_missing_comment(url)
|
45
|
+
next if add_offense_no_match(url)
|
46
|
+
next if add_offense_wrong_format(url)
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
50
|
+
def add_offense_unnecessary_comment(stanza)
|
51
|
+
return unless comment?(stanza)
|
52
|
+
return unless url_match_homepage?(stanza)
|
53
|
+
return unless comment_matches_url?(stanza)
|
54
|
+
|
55
|
+
comment = comment(stanza).loc.expression
|
56
|
+
add_offense(comment,
|
57
|
+
comment,
|
58
|
+
format(MSG_UNNECESSARY, domain(stanza), homepage))
|
59
|
+
end
|
60
|
+
|
48
61
|
def add_offense_missing_comment(stanza)
|
62
|
+
return if url_match_homepage?(stanza)
|
63
|
+
return if !url_match_homepage?(stanza) && comment?(stanza)
|
64
|
+
|
49
65
|
range = stanza.source_range
|
50
66
|
url_domain = domain(stanza)
|
51
67
|
add_offense(range, range, format(MSG_MISSING, url_domain, homepage, url_domain))
|
52
68
|
end
|
53
69
|
|
54
|
-
def
|
70
|
+
def add_offense_no_match(stanza)
|
71
|
+
return if url_match_homepage?(stanza)
|
72
|
+
return unless comment?(stanza)
|
73
|
+
return if !url_match_homepage?(stanza) && comment_matches_url?(stanza)
|
74
|
+
|
55
75
|
comment = comment(stanza).loc.expression
|
56
76
|
add_offense(comment,
|
57
77
|
comment,
|
58
|
-
format(
|
78
|
+
format(MSG_NO_MATCH, url_from_comment(stanza), full_url(stanza)))
|
59
79
|
end
|
60
80
|
|
61
|
-
def
|
81
|
+
def add_offense_wrong_format(stanza)
|
82
|
+
return if url_match_homepage?(stanza)
|
83
|
+
return unless comment?(stanza)
|
84
|
+
return if comment_matches_format?(stanza)
|
85
|
+
|
62
86
|
comment = comment(stanza).loc.expression
|
63
87
|
add_offense(comment,
|
64
88
|
comment,
|
65
|
-
format(
|
89
|
+
format(MSG_WRONG_FORMAT, comment(stanza).text))
|
66
90
|
end
|
67
91
|
|
68
92
|
def comment?(stanza)
|
@@ -73,9 +97,13 @@ module RuboCop
|
|
73
97
|
stanza.comments.last
|
74
98
|
end
|
75
99
|
|
100
|
+
def comment_matches_format?(stanza)
|
101
|
+
comment(stanza).text =~ COMMENT_FORMAT
|
102
|
+
end
|
103
|
+
|
76
104
|
def url_from_comment(stanza)
|
77
105
|
comment(stanza).text
|
78
|
-
.sub(
|
106
|
+
.sub(/[^ ]*# ([^ ]+) .*/, '\1')
|
79
107
|
end
|
80
108
|
|
81
109
|
def comment_matches_url?(stanza)
|
@@ -93,6 +93,31 @@ describe RuboCop::Cop::Cask::HomepageMatchesUrl do
|
|
93
93
|
context 'when the url does not match the homepage' do
|
94
94
|
context 'and there is a comment' do
|
95
95
|
context 'which matches the url' do
|
96
|
+
context 'but does not match the expected format' do
|
97
|
+
let(:source) do
|
98
|
+
<<-CASK.undent
|
99
|
+
cask 'foo' do
|
100
|
+
# example.com was verified as official
|
101
|
+
url 'https://example.com/foo.zip'
|
102
|
+
homepage 'https://foo.example.org'
|
103
|
+
end
|
104
|
+
CASK
|
105
|
+
end
|
106
|
+
let(:expected_offenses) do
|
107
|
+
[{
|
108
|
+
message: '`# example.com was verified as official` does not ' \
|
109
|
+
'match the expected comment format. For details, see ' \
|
110
|
+
'https://github.com/caskroom/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-a-comment',
|
111
|
+
severity: :convention,
|
112
|
+
line: 2,
|
113
|
+
column: 2,
|
114
|
+
source: '# example.com was verified as official'
|
115
|
+
}]
|
116
|
+
end
|
117
|
+
|
118
|
+
include_examples 'reports offenses'
|
119
|
+
end
|
120
|
+
|
96
121
|
context 'and does not have slashes' do
|
97
122
|
let(:source) do
|
98
123
|
<<-CASK.undent
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-cask
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Hagins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: public_suffix
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.43.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.43.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.3'
|
55
55
|
description: |2
|
@@ -63,7 +63,10 @@ extra_rdoc_files:
|
|
63
63
|
- MIT-LICENSE.md
|
64
64
|
- README.md
|
65
65
|
files:
|
66
|
+
- MIT-LICENSE.md
|
67
|
+
- README.md
|
66
68
|
- config/default.yml
|
69
|
+
- lib/rubocop-cask.rb
|
67
70
|
- lib/rubocop/cask/ast/cask_block.rb
|
68
71
|
- lib/rubocop/cask/ast/cask_header.rb
|
69
72
|
- lib/rubocop/cask/ast/stanza.rb
|
@@ -77,9 +80,6 @@ files:
|
|
77
80
|
- lib/rubocop/cop/cask/no_dsl_version.rb
|
78
81
|
- lib/rubocop/cop/cask/stanza_grouping.rb
|
79
82
|
- lib/rubocop/cop/cask/stanza_order.rb
|
80
|
-
- lib/rubocop-cask.rb
|
81
|
-
- MIT-LICENSE.md
|
82
|
-
- README.md
|
83
83
|
- spec/project_spec.rb
|
84
84
|
- spec/rubocop/cop/cask/homepage_matches_url_spec.rb
|
85
85
|
- spec/rubocop/cop/cask/no_dsl_version_spec.rb
|
@@ -97,17 +97,17 @@ require_paths:
|
|
97
97
|
- lib
|
98
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: 1.9.3
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- -
|
105
|
+
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.6.6
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Code style checking for Homebrew-Cask files
|