rubocop-cask 0.11.0 → 0.12.0
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/config/default.yml +4 -0
- data/lib/rubocop/cask/version.rb +1 -1
- data/lib/rubocop/cop/cask/homepage_url_trailing_slash.rb +36 -0
- data/lib/rubocop/cop/cask/mixin/on_homepage_stanza.rb +25 -0
- data/lib/rubocop-cask.rb +2 -0
- data/spec/rubocop/cop/cask/homepage_url_trailing_slash_spec.rb +53 -0
- metadata +18 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 442d35b763d9d298b87df4a292360fe9990a018a
|
4
|
+
data.tar.gz: 088e6c62903ded5b57296b29cbfe63b9dfc1bfd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50bb469d68f72ea30723f96ad495717a714a78cbc1124dd0c6e1ec3427fa484f00936eb34cddb97a0eace82b87c09c976ebcc36619533315a44a2601609b3d19
|
7
|
+
data.tar.gz: ce1b8254d503ddc1e5bfe5b207dc953063a86055d2bb3af76a89daaa06fa0c6d26abab44f920068b93730dd028a40c3ee7d29bec93853f0462777ac28a2a5ef8
|
data/config/default.yml
CHANGED
@@ -6,6 +6,10 @@ Cask/NoDslVersion:
|
|
6
6
|
Description: 'Do not use the deprecated DSL version syntax in your cask header.'
|
7
7
|
Enabled: true
|
8
8
|
|
9
|
+
Cask/HomepageUrlTrailingSlash:
|
10
|
+
Description: 'Ensure that the homepage url has a slash after the domain name.'
|
11
|
+
Enabled: true
|
12
|
+
|
9
13
|
Cask/HomepageMatchesUrl:
|
10
14
|
Description: 'Ensure that the homepage and url match, otherwise add a comment. More info at https://github.com/caskroom/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-a-comment'
|
11
15
|
Enabled: true
|
data/lib/rubocop/cask/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module RuboCop
|
5
|
+
module Cop
|
6
|
+
module Cask
|
7
|
+
# This cop checks that a cask's homepage ends with a slash
|
8
|
+
# if it does not have a path component.
|
9
|
+
class HomepageUrlTrailingSlash < Cop
|
10
|
+
include OnHomepageStanza
|
11
|
+
|
12
|
+
MSG_NO_SLASH = "'%s' must have a slash after the domain.".freeze
|
13
|
+
|
14
|
+
def on_homepage_stanza(stanza)
|
15
|
+
url_node = stanza.stanza_node.method_args.first
|
16
|
+
url = url_node.str_content
|
17
|
+
|
18
|
+
return if url !~ %r{^.+://[^/]+$}
|
19
|
+
add_offense(url_node, :expression, format(MSG_NO_SLASH, url))
|
20
|
+
end
|
21
|
+
|
22
|
+
def autocorrect(node)
|
23
|
+
domain = URI(node.str_content).host
|
24
|
+
|
25
|
+
# This also takes URLs like 'https://example.org?path'
|
26
|
+
# and 'https://example.org#path' into account.
|
27
|
+
corrected_source = node.source.sub("://#{domain}", "://#{domain}/")
|
28
|
+
|
29
|
+
lambda do |corrector|
|
30
|
+
corrector.replace(node.source_range, corrected_source)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RuboCop
|
2
|
+
module Cop
|
3
|
+
module Cask
|
4
|
+
# Common functionality for checking homepage stanzas.
|
5
|
+
module OnHomepageStanza
|
6
|
+
extend Forwardable
|
7
|
+
include CaskHelp
|
8
|
+
|
9
|
+
def on_cask(cask_block)
|
10
|
+
@cask_block = cask_block
|
11
|
+
|
12
|
+
toplevel_stanzas.select(&:homepage?).each do |stanza|
|
13
|
+
on_homepage_stanza(stanza)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :cask_block
|
20
|
+
def_delegators :cask_block,
|
21
|
+
:toplevel_stanzas
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/rubocop-cask.rb
CHANGED
@@ -12,7 +12,9 @@ require 'rubocop/cask/inject'
|
|
12
12
|
RuboCop::Cask::Inject.defaults!
|
13
13
|
|
14
14
|
require 'rubocop/cop/cask/mixin/cask_help'
|
15
|
+
require 'rubocop/cop/cask/mixin/on_homepage_stanza'
|
15
16
|
require 'rubocop/cop/cask/homepage_matches_url'
|
17
|
+
require 'rubocop/cop/cask/homepage_url_trailing_slash'
|
16
18
|
require 'rubocop/cop/cask/no_dsl_version'
|
17
19
|
require 'rubocop/cop/cask/stanza_order'
|
18
20
|
require 'rubocop/cop/cask/stanza_grouping'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
describe RuboCop::Cop::Cask::HomepageUrlTrailingSlash do
|
2
|
+
include CopSharedExamples
|
3
|
+
|
4
|
+
subject(:cop) { described_class.new }
|
5
|
+
|
6
|
+
context 'when the homepage url ends with a slash' do
|
7
|
+
let(:source) do
|
8
|
+
<<-CASK.undent
|
9
|
+
cask 'foo' do
|
10
|
+
homepage 'https://foo.example.com/'
|
11
|
+
end
|
12
|
+
CASK
|
13
|
+
end
|
14
|
+
|
15
|
+
include_examples 'does not report any offenses'
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when the homepage url does not end with a slash' do
|
19
|
+
context 'but has a path' do
|
20
|
+
let(:source) do
|
21
|
+
<<-CASK.undent
|
22
|
+
cask 'foo' do
|
23
|
+
homepage 'https://foo.example.com/path'
|
24
|
+
end
|
25
|
+
CASK
|
26
|
+
end
|
27
|
+
|
28
|
+
include_examples 'does not report any offenses'
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'and has no path' do
|
32
|
+
let(:source) do
|
33
|
+
<<-CASK.undent
|
34
|
+
cask 'foo' do
|
35
|
+
homepage 'https://foo.example.com'
|
36
|
+
end
|
37
|
+
CASK
|
38
|
+
end
|
39
|
+
let(:expected_offenses) do
|
40
|
+
[{
|
41
|
+
message: "'https://foo.example.com' must have a slash "\
|
42
|
+
'after the domain.',
|
43
|
+
severity: :convention,
|
44
|
+
line: 2,
|
45
|
+
column: 11,
|
46
|
+
source: "'https://foo.example.com'"
|
47
|
+
}]
|
48
|
+
end
|
49
|
+
|
50
|
+
include_examples 'reports offenses'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
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.
|
4
|
+
version: 0.12.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: 2017-
|
11
|
+
date: 2017-03-14 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.47.1
|
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.47.1
|
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.14'
|
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.14'
|
55
55
|
description: |2
|
@@ -63,10 +63,7 @@ extra_rdoc_files:
|
|
63
63
|
- MIT-LICENSE.md
|
64
64
|
- README.md
|
65
65
|
files:
|
66
|
-
- MIT-LICENSE.md
|
67
|
-
- README.md
|
68
66
|
- config/default.yml
|
69
|
-
- lib/rubocop-cask.rb
|
70
67
|
- lib/rubocop/cask/ast/cask_block.rb
|
71
68
|
- lib/rubocop/cask/ast/cask_header.rb
|
72
69
|
- lib/rubocop/cask/ast/stanza.rb
|
@@ -76,12 +73,18 @@ files:
|
|
76
73
|
- lib/rubocop/cask/inject.rb
|
77
74
|
- lib/rubocop/cask/version.rb
|
78
75
|
- lib/rubocop/cop/cask/homepage_matches_url.rb
|
76
|
+
- lib/rubocop/cop/cask/homepage_url_trailing_slash.rb
|
79
77
|
- lib/rubocop/cop/cask/mixin/cask_help.rb
|
78
|
+
- lib/rubocop/cop/cask/mixin/on_homepage_stanza.rb
|
80
79
|
- lib/rubocop/cop/cask/no_dsl_version.rb
|
81
80
|
- lib/rubocop/cop/cask/stanza_grouping.rb
|
82
81
|
- lib/rubocop/cop/cask/stanza_order.rb
|
82
|
+
- lib/rubocop-cask.rb
|
83
|
+
- MIT-LICENSE.md
|
84
|
+
- README.md
|
83
85
|
- spec/project_spec.rb
|
84
86
|
- spec/rubocop/cop/cask/homepage_matches_url_spec.rb
|
87
|
+
- spec/rubocop/cop/cask/homepage_url_trailing_slash_spec.rb
|
85
88
|
- spec/rubocop/cop/cask/no_dsl_version_spec.rb
|
86
89
|
- spec/rubocop/cop/cask/stanza_grouping_spec.rb
|
87
90
|
- spec/rubocop/cop/cask/stanza_order_spec.rb
|
@@ -97,23 +100,24 @@ require_paths:
|
|
97
100
|
- lib
|
98
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
102
|
requirements:
|
100
|
-
- -
|
103
|
+
- - '>='
|
101
104
|
- !ruby/object:Gem::Version
|
102
105
|
version: 2.0.0
|
103
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
107
|
requirements:
|
105
|
-
- -
|
108
|
+
- - '>='
|
106
109
|
- !ruby/object:Gem::Version
|
107
110
|
version: '0'
|
108
111
|
requirements: []
|
109
112
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.0.14.1
|
111
114
|
signing_key:
|
112
115
|
specification_version: 4
|
113
116
|
summary: Code style checking for Homebrew-Cask files
|
114
117
|
test_files:
|
115
118
|
- spec/project_spec.rb
|
116
119
|
- spec/rubocop/cop/cask/homepage_matches_url_spec.rb
|
120
|
+
- spec/rubocop/cop/cask/homepage_url_trailing_slash_spec.rb
|
117
121
|
- spec/rubocop/cop/cask/no_dsl_version_spec.rb
|
118
122
|
- spec/rubocop/cop/cask/stanza_grouping_spec.rb
|
119
123
|
- spec/rubocop/cop/cask/stanza_order_spec.rb
|