pronto-foodcritic 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 597ae3f64b94c516e8a72a66b180605e8f7d82d8
4
+ data.tar.gz: bddf5f74f76486662da4f6b2983cf10a1ce0cb18
5
+ SHA512:
6
+ metadata.gz: d11b2315267d6effa4ac77ae54c3f94196f4492081f9fd1fd209842fe09d8ed22df4f65ada4612206aa72b9e2c79e98c7db99ed46b5ebcb45501edc4ef1fe3ee
7
+ data.tar.gz: ea77be4ef5af122c8b26014a7726c24ae8d5a16dc53d5f88ec765da2903244e215036cbff9e429305594e9f2b895b9145f7da9471edc06567f1a71887b770ce1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2014 Mindaugas Mozūras
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Pronto runner for Food Critic
2
+
3
+ [![Code Climate](https://codeclimate.com/github/mmozuras/pronto-foodcritic.png)](https://codeclimate.com/github/mmozuras/pronto-foodcritic)
4
+ [![Build Status](https://travis-ci.org/mmozuras/pronto-foodcritic.png)](https://travis-ci.org/mmozuras/pronto-foodcritic)
5
+ [![Gem Version](https://badge.fury.io/rb/pronto-foodcritic.png)](http://badge.fury.io/rb/pronto-foodcritic)
6
+ [![Dependency Status](https://gemnasium.com/mmozuras/pronto-foodcritic.png)](https://gemnasium.com/mmozuras/pronto-foodcritic)
7
+
8
+ Pronto runner for [Food Critic](https://github.com/acrmp/foodcritic), lint tool for chef. [What is Pronto?](https://github.com/mmozuras/pronto)
9
+
10
+ ## Note
11
+
12
+ Currently, naively uses path to determine if a file is a cookbook or a role configuration.
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module FoodCriticVersion
3
+ VERSION = '0.2.0'
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+ require 'pronto'
2
+ require 'foodcritic'
3
+
4
+ module Pronto
5
+ class FoodCritic < Runner
6
+ def initialize
7
+ @linter = ::FoodCritic::Linter.new
8
+ end
9
+
10
+ def run(patches, _)
11
+ return [] unless patches
12
+
13
+ patches.select { |patch| patch.additions > 0 }
14
+ .select { |patch| ruby_file?(patch.new_file_full_path) }
15
+ .map { |patch| inspect(patch) }
16
+ .flatten.compact
17
+ end
18
+
19
+ def inspect(patch)
20
+ path = patch.new_file_full_path.to_s
21
+ path_type = if path.include?('cookbook')
22
+ :cookbook_paths
23
+ elsif path.include?('role')
24
+ :role_paths
25
+ end
26
+
27
+ return if path_type.nil?
28
+
29
+ review = @linter.check({ path_type => path })
30
+ review.warnings.map do |warning|
31
+ patch.added_lines.select { |line| line.new_lineno == warning.match[:line] }
32
+ .map { |line| new_message(warning, line) }
33
+ end
34
+ end
35
+
36
+ def new_message(warning, line)
37
+ path = line.patch.delta.new_file[:path]
38
+ message = "#{warning.rule.code} - #{warning.rule.name}"
39
+ Message.new(path, line, :warning, message)
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-foodcritic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Mindaugas Mozūras
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: foodcritic
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pronto
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 10.1.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 10.1.0
55
+ description:
56
+ email: mindaugas.mozuras@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - LICENSE
62
+ - README.md
63
+ - lib/pronto/foodcritic.rb
64
+ - lib/pronto/foodcritic/version.rb
65
+ homepage: http://github.org/mmozuras/pronto-foodcritic
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.6
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.2.2
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Pronto runner for Food Critic, lint tool for chef
89
+ test_files: []