rubocop-cask 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28972420dc9ce7f5af5f9acd84d29315618b81b6
4
+ data.tar.gz: 7805e7dc619fd148d982a7397a7cf49c0eb7aa17
5
+ SHA512:
6
+ metadata.gz: 898b80daadf2ab178beae041529bb41e580d6fb59c031b46c03411132d9ec0a829099204024efa22e5940f02e46d412ed723a30797ee4c4c9f0a58d1c4250a6a
7
+ data.tar.gz: 950eaf10f6c9cf303b10d0d38b89355ddb6ac3652b19788e63f71cef51a01d7c0ae043a5c855b2479e20d60473b2c21f22cc940d193dc09ec5ae6521f68e7c7e
data/MIT-LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+ =====================
3
+
4
+ Copyright (c) Joshua Hagins <hagins.josh@gmail.com>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ of the Software, and to permit persons to whom the Software is furnished to do
11
+ so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # RuboCop Cask
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/rubocop-cask.svg)](http://badge.fury.io/rb/rubocop-cask)
4
+ [![Dependency Status](https://gemnasium.com/jawshooah/rubocop-cask.svg)](https://gemnasium.com/jawshooah/rubocop-cask)
5
+ [![Build Status](https://travis-ci.org/jawshooah/rubocop-cask.svg?branch=master)](https://travis-ci.org/jawshooah/rubocop-cask)
6
+ [![Coverage Status](https://img.shields.io/codeclimate/coverage/github/jawshooah/rubocop-cask.svg)](https://codeclimate.com/github/jawshooah/rubocop-cask)
7
+ [![Code Climate](https://codeclimate.com/github/jawshooah/rubocop-cask/badges/gpa.svg)](https://codeclimate.com/github/jawshooah/rubocop-cask)
8
+ [![Inline docs](http://inch-ci.org/github/jawshooah/rubocop-cask.svg)](http://inch-ci.org/github/jawshooah/rubocop-cask)
9
+
10
+ Cask-specific analysis for your Homebrew-Cask taps, as an extension to
11
+ [RuboCop](https://github.com/bbatsov/rubocop). Heavily inspired by [`rubocop-rspec`](https://github.com/nevir/rubocop-rspec).
12
+
13
+
14
+ ## Installation
15
+
16
+ Just install the `rubocop-cask` gem
17
+
18
+ ```bash
19
+ gem install rubocop-cask
20
+ ```
21
+
22
+ or if you use bundler put this in your `Gemfile`
23
+
24
+ ```
25
+ gem 'rubocop-cask'
26
+ ```
27
+
28
+
29
+ ## Usage
30
+
31
+ You need to tell RuboCop to load the Cask extension. There are three ways to do this:
32
+
33
+ ### RuboCop configuration file
34
+
35
+ Put this into your `.rubocop.yml`:
36
+
37
+ ```
38
+ require: rubocop-cask
39
+ ```
40
+
41
+ Now you can run `rubocop` and it will automatically load the RuboCop Cask cops together with the standard cops.
42
+
43
+ ### Command line
44
+
45
+ ```bash
46
+ rubocop --require rubocop-cask
47
+ ```
48
+
49
+ ### Rake task
50
+
51
+ ```ruby
52
+ RuboCop::RakeTask.new do |task|
53
+ task.requires << 'rubocop-cask'
54
+ end
55
+ ```
56
+
57
+
58
+ ## The Cops
59
+
60
+ All cops are located under [`lib/rubocop/cop/cask`](lib/rubocop/cop/cask), and contain examples/documentation.
61
+
62
+ In your `.rubocop.yml`, you may treat the Cask cops just like any other cop. For example:
63
+
64
+ ```yaml
65
+ Cask/NoDslVersion:
66
+ Enabled: false
67
+ ```
68
+
69
+
70
+ ## Contributing
71
+
72
+ 1. Fork it
73
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
74
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
75
+ 4. Push to the branch (`git push origin my-new-feature`)
76
+ 5. Create new Pull Request
77
+
78
+ For running the spec files, this project depends on RuboCop's spec helpers. This means that in order to run the specs locally, you need a (shallow) clone of the RuboCop repository:
79
+
80
+ ```bash
81
+ git clone --depth 1 git://github.com/bbatsov/rubocop.git vendor/rubocop
82
+ ```
83
+
84
+ ## License
85
+
86
+ `rubocop-cask` is MIT licensed. [See the accompanying file](MIT-LICENSE.md) for
87
+ the full text.
@@ -0,0 +1,3 @@
1
+ Cask/NoDslVersion:
2
+ Description: 'Do not use the deprecated DSL version syntax in your cask header.'
3
+ Enabled: true
@@ -0,0 +1,21 @@
1
+ require 'yaml'
2
+
3
+ module RuboCop
4
+ module Cask
5
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
6
+ # bit of our configuration.
7
+ module Inject
8
+ DEFAULT_FILE = File.expand_path(
9
+ '../../../../config/default.yml', __FILE__
10
+ )
11
+
12
+ def self.defaults!
13
+ hash = YAML.load_file(DEFAULT_FILE)
14
+ puts "configuration from #{DEFAULT_FILE}" if ConfigLoader.debug?
15
+ config = ConfigLoader.merge_with_default(hash, DEFAULT_FILE)
16
+
17
+ ConfigLoader.instance_variable_set(:@default_configuration, config)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+
3
+ module RuboCop
4
+ module Cask
5
+ # Version information for the Cask RuboCop plugin.
6
+ module Version
7
+ STRING = '0.0.0'
8
+
9
+ def self.gem_version
10
+ Gem::Version.new(STRING)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,42 @@
1
+ module RuboCop
2
+ module Cop
3
+ module Cask
4
+ # Do not use the deprecated DSL version syntax in your cask header.
5
+ #
6
+ # @example
7
+ # # bad
8
+ # cask :v1 => 'foo' do
9
+ # ...
10
+ # end
11
+ #
12
+ # # good
13
+ # cask 'foo' do
14
+ # ...
15
+ # end
16
+ class NoDslVersion < Cop
17
+ MESSAGE = "Use `%s '%s'` instead of `%s %s => '%s'`"
18
+
19
+ CASK_METHOD_NAMES = [:cask, :test_cask]
20
+
21
+ def on_block(node)
22
+ method, _args, _body = node.children
23
+ _receiver, method_name, object = method.children
24
+ return unless CASK_METHOD_NAMES.include?(method_name)
25
+ return unless object.type == :hash
26
+ check(method_name, object)
27
+ end
28
+
29
+ private
30
+
31
+ def check(method_name, object)
32
+ left, right = *object.children.first
33
+ dsl_version_sym = left.children.first
34
+ cask_token = right.children.first
35
+ message = format(MESSAGE, method_name, cask_token, method_name,
36
+ dsl_version_sym.inspect, cask_token)
37
+ add_offense(object, :expression, message)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubocop'
2
+
3
+ require 'rubocop/cask/version'
4
+ require 'rubocop/cask/inject'
5
+
6
+ RuboCop::Cask::Inject.defaults!
7
+
8
+ require 'rubocop/cop/cask/no_dsl_version'
@@ -0,0 +1,30 @@
1
+ describe 'RuboCop Project' do
2
+ describe 'default configuration file' do
3
+ let(:cop_names) do
4
+ cop_files = Dir.glob(File.join(File.dirname(__FILE__), '..', 'lib',
5
+ 'rubocop', 'cop', 'cask', '*.rb'))
6
+ cop_files.map do |file|
7
+ cop_name = File.basename(file, '.rb')
8
+ .gsub(/(^|_)(.)/) { Regexp.last_match(2).upcase }
9
+
10
+ "Cask/#{cop_name}"
11
+ end
12
+ end
13
+
14
+ subject(:default_config) do
15
+ RuboCop::ConfigLoader.load_file('config/default.yml')
16
+ end
17
+
18
+ it 'has configuration for all cops' do
19
+ expect(default_config.keys.sort).to eq((cop_names).sort)
20
+ end
21
+
22
+ it 'has a nicely formatted description for all cops' do
23
+ cop_names.each do |name|
24
+ description = default_config[name]['Description']
25
+ expect(description).not_to be_nil
26
+ expect(description).not_to include("\n")
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ describe RuboCop::Cop::Cask::NoDslVersion do
2
+ subject(:cop) { described_class.new }
3
+
4
+ it 'checks for dsl version in cask header' do
5
+ inspect_source(cop, [
6
+ "cask :v1 => 'foo' do",
7
+ 'end'
8
+ ])
9
+ expect(cop.offenses.size).to eq(1)
10
+ expect(cop.offenses.first.line).to eq(1)
11
+ expect(cop.messages)
12
+ .to eq(["Use `cask 'foo'` instead of `cask :v1 => 'foo'`"])
13
+ expect(cop.highlights)
14
+ .to eq([":v1 => 'foo'"])
15
+ end
16
+
17
+ it 'ignores cask header with no dsl version' do
18
+ inspect_source(cop, [
19
+ "cask 'foo' do",
20
+ 'end'
21
+ ])
22
+ expect(cop.offenses).to be_empty
23
+ end
24
+
25
+ it 'checks for dsl version in test_cask header' do
26
+ inspect_source(cop, [
27
+ "test_cask :v1 => 'foo' do",
28
+ 'end'
29
+ ])
30
+ expect(cop.offenses.size).to eq(1)
31
+ expect(cop.offenses.first.line).to eq(1)
32
+ expect(cop.messages)
33
+ .to eq(["Use `test_cask 'foo'` instead of `test_cask :v1 => 'foo'`"])
34
+ expect(cop.highlights)
35
+ .to eq([":v1 => 'foo'"])
36
+ end
37
+
38
+ it 'ignores test_cask header with no dsl version' do
39
+ inspect_source(cop, [
40
+ "test_cask 'foo' do",
41
+ 'end'
42
+ ])
43
+ expect(cop.offenses).to be_empty
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubocop'
2
+
3
+ rubocop_path = File.join(File.dirname(__FILE__), '../vendor/rubocop')
4
+ unless File.directory?(rubocop_path)
5
+ fail "Can't run specs without a local RuboCop checkout. Look in the README."
6
+ end
7
+ Dir["#{rubocop_path}/spec/support/**/*.rb"].each { |f| require f }
8
+
9
+ RSpec.configure do |config|
10
+ config.order = :random
11
+
12
+ config.expect_with :rspec do |expectations|
13
+ expectations.syntax = :expect # Disable `should`
14
+ end
15
+
16
+ config.mock_with :rspec do |mocks|
17
+ mocks.syntax = :expect # Disable `should_receive` and `stub`
18
+ end
19
+ end
20
+
21
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
22
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
23
+ require 'rubocop-cask'
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-cask
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Joshua Hagins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ description: |2
28
+ Code style checking for Homebrew-Cask files.
29
+ A plugin for the RuboCop code style enforcing & linting tool.
30
+ email:
31
+ - hagins.josh@gmail.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files:
35
+ - MIT-LICENSE.md
36
+ - README.md
37
+ files:
38
+ - MIT-LICENSE.md
39
+ - README.md
40
+ - config/default.yml
41
+ - lib/rubocop-cask.rb
42
+ - lib/rubocop/cask/inject.rb
43
+ - lib/rubocop/cask/version.rb
44
+ - lib/rubocop/cop/cask/no_dsl_version.rb
45
+ - spec/project_spec.rb
46
+ - spec/rubocop/cop/cask/no_dsl_version_spec.rb
47
+ - spec/spec_helper.rb
48
+ homepage: https://github.com/jawshooah/rubocop-cask
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.9.3
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.4.5.1
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Code style checking for Homebrew-Cask files
72
+ test_files:
73
+ - spec/project_spec.rb
74
+ - spec/rubocop/cop/cask/no_dsl_version_spec.rb
75
+ - spec/spec_helper.rb