rubocop-cask 0.4.1 → 0.5.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/README.md +2 -3
- data/config/default.yml +0 -4
- data/lib/rubocop-cask.rb +0 -1
- data/lib/rubocop/cask/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +4 -7
- data/lib/rubocop/cop/cask/license_unknown_comment.rb +0 -72
- data/spec/rubocop/cop/cask/license_unknown_comment_spec.rb +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a4259d68effdfccd9b90d0a5c05719f1c8f75f6
|
4
|
+
data.tar.gz: 660486500a297c9f6ac98b314534ba5a10aec51f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70146ce66a4790694e73212933589ea4bcd7f3034bb5d3dac5e9843fc18d16b542d5c15e30ba1307c489435b6cb530df2255e2703d9318673667aa16ce433d97
|
7
|
+
data.tar.gz: 95b53d4a9e858c4694c286e1eb3eece0d1826f5abc61299ba3c0c1bd56d12e78611370af7bd930a2e6c69a281d8a8a7a3d17529f9b46ec755cd2319038eeac64
|
data/README.md
CHANGED
@@ -10,7 +10,6 @@
|
|
10
10
|
Cask-specific analysis for your [Homebrew-Cask](https://github.com/caskroom/homebrew-cask) taps, as an extension to
|
11
11
|
[RuboCop](https://github.com/bbatsov/rubocop). Heavily inspired by [`rubocop-rspec`](https://github.com/nevir/rubocop-rspec).
|
12
12
|
|
13
|
-
|
14
13
|
## Installation
|
15
14
|
|
16
15
|
Just install the `rubocop-cask` gem
|
@@ -21,7 +20,7 @@ gem install rubocop-cask
|
|
21
20
|
|
22
21
|
or if you use bundler put this in your `Gemfile`
|
23
22
|
|
24
|
-
```
|
23
|
+
```ruby
|
25
24
|
gem 'rubocop-cask'
|
26
25
|
```
|
27
26
|
|
@@ -34,7 +33,7 @@ You need to tell RuboCop to load the Cask extension. There are three ways to do
|
|
34
33
|
|
35
34
|
Put this into your `.rubocop.yml`:
|
36
35
|
|
37
|
-
```
|
36
|
+
```yaml
|
38
37
|
require: rubocop-cask
|
39
38
|
```
|
40
39
|
|
data/config/default.yml
CHANGED
data/lib/rubocop-cask.rb
CHANGED
@@ -12,7 +12,6 @@ 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/license_unknown_comment'
|
16
15
|
require 'rubocop/cop/cask/no_dsl_version'
|
17
16
|
require 'rubocop/cop/cask/stanza_order'
|
18
17
|
require 'rubocop/cop/cask/stanza_grouping'
|
data/lib/rubocop/cask/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rubocop'
|
|
3
3
|
project_path = File.join(File.dirname(__FILE__), '..')
|
4
4
|
rubocop_path = File.join(project_path, 'vendor/rubocop')
|
5
5
|
unless File.directory?(rubocop_path)
|
6
|
-
|
6
|
+
raise "Can't run specs without a local RuboCop checkout. Look in the README."
|
7
7
|
end
|
8
8
|
Dir["#{rubocop_path}/spec/support/**/*.rb"].each { |f| require f }
|
9
9
|
Dir["#{project_path}/spec/support/**/*.rb"].each { |f| require f }
|
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.5.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: 2016-
|
11
|
+
date: 2016-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.37.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
|
-
version:
|
26
|
+
version: 0.37.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,13 +61,11 @@ files:
|
|
61
61
|
- lib/rubocop/cask/extend/string.rb
|
62
62
|
- lib/rubocop/cask/inject.rb
|
63
63
|
- lib/rubocop/cask/version.rb
|
64
|
-
- lib/rubocop/cop/cask/license_unknown_comment.rb
|
65
64
|
- lib/rubocop/cop/cask/mixin/cask_help.rb
|
66
65
|
- lib/rubocop/cop/cask/no_dsl_version.rb
|
67
66
|
- lib/rubocop/cop/cask/stanza_grouping.rb
|
68
67
|
- lib/rubocop/cop/cask/stanza_order.rb
|
69
68
|
- spec/project_spec.rb
|
70
|
-
- spec/rubocop/cop/cask/license_unknown_comment_spec.rb
|
71
69
|
- spec/rubocop/cop/cask/no_dsl_version_spec.rb
|
72
70
|
- spec/rubocop/cop/cask/stanza_grouping_spec.rb
|
73
71
|
- spec/rubocop/cop/cask/stanza_order_spec.rb
|
@@ -99,7 +97,6 @@ specification_version: 4
|
|
99
97
|
summary: Code style checking for Homebrew-Cask files
|
100
98
|
test_files:
|
101
99
|
- spec/project_spec.rb
|
102
|
-
- spec/rubocop/cop/cask/license_unknown_comment_spec.rb
|
103
100
|
- spec/rubocop/cop/cask/no_dsl_version_spec.rb
|
104
101
|
- spec/rubocop/cop/cask/stanza_grouping_spec.rb
|
105
102
|
- spec/rubocop/cop/cask/stanza_order_spec.rb
|
@@ -1,72 +0,0 @@
|
|
1
|
-
module RuboCop
|
2
|
-
module Cop
|
3
|
-
module Cask
|
4
|
-
# This cop checks that if a cask uses `license :unknown`, it is followed
|
5
|
-
# on the same line by the machine-generated TODO comment.
|
6
|
-
class LicenseUnknownComment < Cop
|
7
|
-
include CaskHelp
|
8
|
-
|
9
|
-
COMMENT_TEXT = '# TODO: change license and remove this comment; ' \
|
10
|
-
"':unknown' is a machine-generated placeholder"
|
11
|
-
MISSING_MSG = "Missing required comment: `#{COMMENT_TEXT}`"
|
12
|
-
INLINE_MSG = 'Comment belongs on the same line as `license :unknown`'
|
13
|
-
|
14
|
-
def on_cask(cask_block)
|
15
|
-
license_stanza = cask_block.stanzas.find(&:license?)
|
16
|
-
return unless license_stanza && license_unknown?(license_stanza)
|
17
|
-
add_offenses(license_stanza)
|
18
|
-
end
|
19
|
-
|
20
|
-
def autocorrect(stanza)
|
21
|
-
lambda do |corrector|
|
22
|
-
comment = license_unknown_comment
|
23
|
-
remove_comment(corrector, comment) if comment
|
24
|
-
add_comment(corrector, stanza)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :cask_block
|
31
|
-
|
32
|
-
def license_unknown?(stanza)
|
33
|
-
stanza.source.include?(':unknown')
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_offenses(stanza)
|
37
|
-
comment = license_unknown_comment
|
38
|
-
add_missing_offense(stanza) unless comment
|
39
|
-
add_not_inline_offense(stanza, comment) if comment &&
|
40
|
-
!on_same_line?(stanza, comment)
|
41
|
-
end
|
42
|
-
|
43
|
-
def license_unknown_comment
|
44
|
-
processed_source.comments.find { |c| c.text == COMMENT_TEXT }
|
45
|
-
end
|
46
|
-
|
47
|
-
def add_missing_offense(stanza)
|
48
|
-
add_offense(stanza, stanza.source_range, MISSING_MSG)
|
49
|
-
end
|
50
|
-
|
51
|
-
def add_not_inline_offense(stanza, comment)
|
52
|
-
add_offense(stanza, comment.loc.expression, INLINE_MSG)
|
53
|
-
end
|
54
|
-
|
55
|
-
def on_same_line?(stanza, comment)
|
56
|
-
stanza.source_range.line == comment.loc.line
|
57
|
-
end
|
58
|
-
|
59
|
-
def remove_comment(corrector, comment)
|
60
|
-
line = comment.loc.line
|
61
|
-
length = processed_source[line - 1].length
|
62
|
-
range = source_range(processed_source.buffer, line, 0, length + 1)
|
63
|
-
corrector.remove(range)
|
64
|
-
end
|
65
|
-
|
66
|
-
def add_comment(corrector, stanza)
|
67
|
-
corrector.insert_after(stanza.source_range, " #{COMMENT_TEXT}")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
describe RuboCop::Cop::Cask::LicenseUnknownComment do
|
2
|
-
include CopSharedExamples
|
3
|
-
|
4
|
-
subject(:cop) { described_class.new }
|
5
|
-
let(:license_unknown_comment) { described_class.const_get(:COMMENT_TEXT) }
|
6
|
-
|
7
|
-
context 'when cask has no license stanza' do
|
8
|
-
let(:source) { "cask 'foo' do; end" }
|
9
|
-
|
10
|
-
include_examples 'does not report any offenses'
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'when license is not :unknown' do
|
14
|
-
let(:source) do
|
15
|
-
<<-CASK.undent
|
16
|
-
cask 'foo' do
|
17
|
-
license :mit
|
18
|
-
end
|
19
|
-
CASK
|
20
|
-
end
|
21
|
-
|
22
|
-
include_examples 'does not report any offenses'
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when license is :unknown' do
|
26
|
-
let(:correct_source) do
|
27
|
-
<<-CASK.undent
|
28
|
-
cask 'foo' do
|
29
|
-
license :unknown #{license_unknown_comment}
|
30
|
-
end
|
31
|
-
CASK
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'with required comment on same line' do
|
35
|
-
let(:source) { correct_source }
|
36
|
-
|
37
|
-
include_examples 'does not report any offenses'
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'with required comment on preceding line' do
|
41
|
-
let(:source) do
|
42
|
-
<<-CASK.undent
|
43
|
-
cask 'foo' do
|
44
|
-
#{license_unknown_comment}
|
45
|
-
license :unknown
|
46
|
-
end
|
47
|
-
CASK
|
48
|
-
end
|
49
|
-
let(:expected_offenses) do
|
50
|
-
[{
|
51
|
-
message: 'Comment belongs on the same line as `license :unknown`',
|
52
|
-
severity: :convention,
|
53
|
-
line: 2,
|
54
|
-
column: 2,
|
55
|
-
source: license_unknown_comment
|
56
|
-
}]
|
57
|
-
end
|
58
|
-
|
59
|
-
include_examples 'reports offenses'
|
60
|
-
|
61
|
-
include_examples 'autocorrects source'
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'with required comment missing' do
|
65
|
-
let(:source) do
|
66
|
-
<<-CASK.undent
|
67
|
-
cask 'foo' do
|
68
|
-
license :unknown
|
69
|
-
end
|
70
|
-
CASK
|
71
|
-
end
|
72
|
-
let(:expected_offenses) do
|
73
|
-
[{
|
74
|
-
message: "Missing required comment: `#{license_unknown_comment}`",
|
75
|
-
severity: :convention,
|
76
|
-
line: 2,
|
77
|
-
column: 2,
|
78
|
-
source: 'license :unknown'
|
79
|
-
}]
|
80
|
-
end
|
81
|
-
|
82
|
-
include_examples 'reports offenses'
|
83
|
-
|
84
|
-
include_examples 'autocorrects source'
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|