rubocop-decko 0.1

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: 91fe3230eb2beec60d685171f8ed8c74038e4cad
4
+ data.tar.gz: 304dc90817b0786fcb33874afc6eec54a459983d
5
+ SHA512:
6
+ metadata.gz: 735556d6247f244f691a68e57e8b08acd8a2dea0fde5697d5805464b01cbb80048b324cdaf58bea6b2164c2d4e8318ab9b855d126b76f0245b7e5b7c84247497
7
+ data.tar.gz: 989342f968dad91e3351f7626adc30128d5e8909baf978b68e64c9d58a6a83b021f05a77436e73d0e8b56b0b7e2ebfc9b75067de10e1b95161b566cc019fb0d2
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # rubocop-decko
2
+ Code style checking for Wagn/Decko files
data/Rakefile ADDED
File without changes
@@ -0,0 +1,10 @@
1
+ Decko/ViewLength:
2
+ Description: Avoid views longer than 15 lines of code.
3
+ Enabled: true
4
+ CountComments: false
5
+ Max: 15
6
+ Decko/EventLength:
7
+ Description: Avoid events longer than 15 lines of code.
8
+ Enabled: true
9
+ CountComments: false
10
+ Max: 15
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubocop'
4
+
5
+ require 'rubocop/decko/version'
6
+ require 'rubocop/decko/inject'
7
+
8
+ RuboCop::Decko::Inject.defaults!
9
+
10
+ require 'rubocop/cop/mixin/block_length'
11
+
12
+ # cops
13
+ require 'rubocop/cop/decko/view_length'
14
+ require 'rubocop/cop/decko/event_length'
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Decko
6
+ # Checks that the lines of a view block don't exceed the allowed maximum
7
+ # @example
8
+ # view :editor do |args|
9
+ # ...
10
+ # end
11
+ class EventLength < Cop
12
+ include BlockLength
13
+
14
+ def on_block(node)
15
+ method, args, body = *node
16
+ _receiver, method_name, _args = *method
17
+ return unless method_name == :event
18
+ check_code_length(node, body)
19
+ end
20
+
21
+ private
22
+ def message(length, max_length)
23
+ format('Event has too many lines. [%d/%d]', length, max_length)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Decko
6
+ # Checks that the lines of a view block don't exceed the allowed maximum
7
+ # @example
8
+ # view :editor do |args|
9
+ # ...
10
+ # end
11
+ class ViewLength < Cop
12
+ include BlockLength
13
+
14
+ def on_block(node)
15
+ method, args, body = *node
16
+ _receiver, method_name, _args = *method
17
+ return unless method_name == :view
18
+ check_code_length(node, body)
19
+ end
20
+
21
+ private
22
+ def message(length, max_length)
23
+ format('View has too many lines. [%d/%d]', length, max_length)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module BlockLength
6
+ # Common functionality for checking length of a block.
7
+ include CodeLength
8
+
9
+ def check_code_length(node, body)
10
+ length = code_length(body.loc.expression)
11
+ return unless length > max_length
12
+
13
+ add_offense(node, :expression, message(length, max_length)) do
14
+ self.max = length
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def code_length(node)
21
+ lines = node.source.lines.to_a[1..-2] || []
22
+
23
+ lines.count { |line| !irrelevant_line(line) }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ module RuboCop
6
+ module Decko
7
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
8
+ # bit of our configuration.
9
+ module Inject
10
+ DEFAULT_FILE = File.expand_path(
11
+ '../../../../config/default.yml', __FILE__
12
+ )
13
+
14
+ def self.defaults!
15
+ hash = YAML.load_file(DEFAULT_FILE)
16
+ puts "configuration from #{DEFAULT_FILE}" if ConfigLoader.debug?
17
+ config = ConfigLoader.merge_with_default(hash, DEFAULT_FILE)
18
+
19
+ ConfigLoader.instance_variable_set(:@default_configuration, config)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ module RuboCop
4
+ module Decko
5
+ # Version information for the Decko RuboCop plugin.
6
+ module Version
7
+ STRING = '0.1'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+ require 'rubocop/decko/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'rubocop-decko'
6
+ spec.summary = 'Code style checking for Wagn/Decko files'
7
+ spec.description = <<-end_description
8
+ Code style checking for Wagn/Decko files.
9
+ A plugin for the RuboCop code style enforcing & linting tool.
10
+ end_description
11
+ spec.date = '2015-01-06'
12
+ spec.homepage = 'http://github.com/xithan/rubocop-decko'
13
+ spec.authors = ['Philipp Kuehl']
14
+ spec.email = ['philipp.kuehl@gmail.com']
15
+ spec.licenses = ['MIT']
16
+
17
+ spec.version = RuboCop::Decko::Version::STRING
18
+ spec.platform = Gem::Platform::RUBY
19
+ spec.required_ruby_version = '>= 1.9.3'
20
+
21
+ spec.require_paths = ['lib']
22
+ spec.files = Dir[
23
+ '{config,lib,spec}/**/*',
24
+ '*.md',
25
+ '*.gemspec',
26
+ 'Gemfile',
27
+ 'Rakefile'
28
+ ]
29
+ spec.test_files = spec.files.grep(%r{^spec/})
30
+ spec.extra_rdoc_files = ['README.md']
31
+
32
+ spec.add_development_dependency('rubocop', '~> 0.31')
33
+ # spec.add_development_dependency('rake', '~> 10.1')
34
+ # spec.add_development_dependency('rspec', '~> 3.0')
35
+ # spec.add_development_dependency('simplecov', '~> 0.8')
36
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-decko
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Philipp Kuehl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.31'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.31'
27
+ description: |2
28
+ Code style checking for Wagn/Decko files.
29
+ A plugin for the RuboCop code style enforcing & linting tool.
30
+ email:
31
+ - philipp.kuehl@gmail.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files:
35
+ - README.md
36
+ files:
37
+ - README.md
38
+ - Rakefile
39
+ - config/default.yml
40
+ - lib/rubocop-decko.rb
41
+ - lib/rubocop/cop/decko/event_length.rb
42
+ - lib/rubocop/cop/decko/view_length.rb
43
+ - lib/rubocop/cop/mixin/block_length.rb
44
+ - lib/rubocop/decko/inject.rb
45
+ - lib/rubocop/decko/version.rb
46
+ - rubocop-decko.gemspec
47
+ homepage: http://github.com/xithan/rubocop-decko
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.9.3
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 2.4.8
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Code style checking for Wagn/Decko files
71
+ test_files: []