foodcritic-rackspace-rules 0.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.
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in foodcritic-rackspace-rules.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Foodcritic::Rackspace::Rules
2
+
3
+ This gem ships additional RACK### rules for foodcritic. This provides a nice way to check best practices.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'foodcritic-rackspace-rules'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install foodcritic-rackspace-rules
18
+
19
+ ## Usage
20
+
21
+ Run `foodcritic -G` to search gems for additional rules.
22
+
23
+ ## Contributing
24
+
25
+ See the [CONTRIBUTING](https://github.com/AutomationSupport/templatestack/blob/master/CONTRIBUTING.md) document for more information.
26
+
27
+ ## LICENSE
28
+
29
+ ```
30
+ # Copyright 2014. Rackspace, US Inc.
31
+ #
32
+ # Licensed under the Apache License, Version 2.0 (the 'License');
33
+ # you may not use this file except in compliance with the License.
34
+ # You may obtain a copy of the License at
35
+ #
36
+ # http://www.apache.org/licenses/LICENSE-2.0
37
+ #
38
+ # Unless required by applicable law or agreed to in writing, software
39
+ # distributed under the License is distributed on an 'AS IS' BASIS,
40
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41
+ # See the License for the specific language governing permissions and
42
+ # limitations under the License.
43
+ #
44
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'foodcritic/rackspace/rules/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "foodcritic-rackspace-rules"
8
+ spec.version = Foodcritic::Rackspace::Rules::VERSION
9
+ spec.authors = ["Martin Smith"]
10
+ spec.email = ["martin@mbs3.org"]
11
+ spec.summary = %q{Foodcritic rules for rackops cookbooks or stacks}
12
+ spec.description = %q{See README.md}
13
+ spec.homepage = "https://github.com/AutomationSupport/foodcritic-rackspace-rules"
14
+ spec.license = "Apache-2.0"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,71 @@
1
+ require 'pp'
2
+
3
+ rule 'RACK001', 'Missing license declaration' do
4
+ tags %w(style rackspace)
5
+ cookbook do |path|
6
+ matches = []
7
+
8
+ recipes = Dir["#{path}/{#{standard_cookbook_subdirs.join(',')}}/**/*.rb"]
9
+ recipes += Dir["#{path}/*.rb"]
10
+ recipes.collect do |recipe|
11
+
12
+ # skip things without 'recipes' in the path
13
+ next if !recipe.include? '/recipes/'
14
+
15
+ # need to scan comments for this rule
16
+ lines = File.readlines(recipe)
17
+ next if lines.collect do |line|
18
+ line.include?('http://www.apache.org/licenses/LICENSE-2.0')
19
+ end.compact.flatten.include? true
20
+
21
+ matches << {
22
+ :filename => recipe,
23
+ :matched => recipe,
24
+ :line => 0,
25
+ :column => 0
26
+ }
27
+ end # recipe
28
+
29
+ matches
30
+ end # cookbook
31
+ end # rule
32
+
33
+ rule 'RACK002', 'Recipe contains a single include_recipe' do
34
+ tags %w(style rackspace)
35
+ cookbook do |path|
36
+ matches = []
37
+
38
+ recipes = Dir["#{path}/{#{standard_cookbook_subdirs.join(',')}}/**/*.rb"]
39
+ recipes += Dir["#{path}/*.rb"]
40
+ recipes.collect do |recipe|
41
+
42
+ # skip things without 'recipes' in the path
43
+ next if !recipe.include? '/recipes/'
44
+
45
+ # unfortunately, we need to scan source for this rule
46
+ # as the AST of a recipe could span multiple files
47
+ lines = File.readlines(recipe)
48
+ non_comments = lines.collect do |line|
49
+ next if line.nil?
50
+ next if line.strip.nil?
51
+ next if line.strip.start_with? '#'
52
+ next if line.strip == ""
53
+ line.strip
54
+ end.compact
55
+
56
+ next if non_comments.length != 1
57
+ next if !non_comments.first.start_with? "include_recipe"
58
+
59
+ matches << {
60
+ :filename => recipe,
61
+ :matched => recipe,
62
+ :line => 0,
63
+ :column => 0
64
+ }
65
+ end # recipe
66
+
67
+ matches
68
+ end # cookbook
69
+ end # rule
70
+
71
+
@@ -0,0 +1,7 @@
1
+ module Foodcritic
2
+ module Rackspace
3
+ module Rules
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foodcritic-rackspace-rules
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Martin Smith
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-07-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.6'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: See README.md
47
+ email:
48
+ - martin@mbs3.org
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - README.md
56
+ - Rakefile
57
+ - foodcritic-rackspace-rules.gemspec
58
+ - lib/foodcritic/rackspace/rules/rules.rb
59
+ - lib/foodcritic/rackspace/rules/version.rb
60
+ homepage: https://github.com/AutomationSupport/foodcritic-rackspace-rules
61
+ licenses:
62
+ - Apache-2.0
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.23
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Foodcritic rules for rackops cookbooks or stacks
85
+ test_files: []