rubocop-facter 0.2.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: 46f23a12f0b06ea5ef21512d8445a38ffe5c6fa0
4
+ data.tar.gz: d4c33c8a59a38ee1b2e7c94fd2f6814f151afea4
5
+ SHA512:
6
+ metadata.gz: ff13ef23e6f4fcb3e4453522672a3a8750d33deb76211fb664d3e592572dd500785fe37d9e92f071b46d43611c7904afaca237d9bd2ed2a5dfacef66b1c95d33
7
+ data.tar.gz: 59f728e346ac41febb70e012813fbb750e3056569f84310eb18b1d5b92c6d3a97c239f57bf416fa2eb8323f3712a048a9274e1ff396f7599a33db41c2128f02d
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ before_install: gem install bundler -v 1.11.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 0.2.0
2
+
3
+ - Detect use of `require facter/util/*`, which no longer exists in recent versions of Facter.
4
+
5
+ ## 0.1.0
6
+
7
+ - Support for detection of `require_relative` in custom facts.
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at zee@zee.space. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubocop-facter.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # rubocop-facter
2
+
3
+ The goal of `rubocop-facter` is to extend rubocop to support facter-specific checks.
4
+ There are various "gotchas" that apply to facter specifically, and not general Ruby programming.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'rubocop-facter'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install rubocop-facter
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubocop-facter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
35
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :rubocop
9
+
10
+ RuboCop::RakeTask.new
@@ -0,0 +1,3 @@
1
+ Facter/RequireRelative:
2
+ Description: 'Check that custom facts are not using require_relative'
3
+ Enabled: true
@@ -0,0 +1,25 @@
1
+ module RuboCop
2
+ module Cop
3
+ module Facter
4
+ # Check that custom facts do not require files in facter/util, as they've all been removed in cfacter.
5
+ #
6
+ # @example
7
+ # # bad
8
+ # Facter::Util::Macaddress.standardize('eth1')
9
+ #
10
+ # # good
11
+ # Facter::Core::Resolution.exec('ip addr show eth1|sed -n 2p').split(' ')[1]
12
+ class FacterUtil < Cop
13
+ # rubocop:disable Metrics/LineLength
14
+ MSG = 'Functionality under facter/util has been mostly removed and must be implemented at the fact-level'.freeze
15
+ # rubocop:enable Metrics/LineLength
16
+
17
+ def on_send(node)
18
+ _receiver, method_name, *args = *node
19
+
20
+ add_offense(node, :selector) if (method_name == :require && _receiver == nil && args.first.children.first =~ /facter\/util/)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ module RuboCop
2
+ module Cop
3
+ module Facter
4
+ # Check that custom facts do no use require_relative, as many Puppet deployments
5
+ # may be using a version of Ruby that doesn't support it. require_relative was
6
+ # introduced in Ruby 1.9.3, but many Puppet installations still use 1.8.7, as this
7
+ # is the default version supplied with RHEL 6
8
+ #
9
+ # @example
10
+ # # bad
11
+ # require_relative 'helpers/custom_fact_helper'
12
+ #
13
+ # # good
14
+ # require 'helpers/custom_fact_helper'
15
+ class RequireRelative < Cop
16
+ # rubocop:disable Metrics/LineLength
17
+ MSG = 'Avoid use of `require_relative` as it is not supported in Ruby 1.8.7, still used in many Puppet deployments'.freeze
18
+ # rubocop:enable Metrics/LineLength
19
+
20
+ def on_send(node)
21
+ _receiver, method_name, *args = *node
22
+
23
+ add_offense(node, :selector) if (method_name == :require_relative && _receiver == nil)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ module RuboCop
2
+ module Facter
3
+ module Inject
4
+ DEFAULT_FILE = File.expand_path(
5
+ '../../../../config/default.yml', __FILE__
6
+ )
7
+
8
+ def self.defaults!
9
+ path = File.absolute_path(DEFAULT_FILE)
10
+ hash = ConfigLoader.send(:load_yaml_configuration, path)
11
+ config = Config.new(hash, path)
12
+ puts "configuration from #{DEFAULT_FILE}" if ConfigLoader.debug?
13
+ config = ConfigLoader.merge_with_default(config, path)
14
+ ConfigLoader.instance_variable_set(:@default_configuration, config)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module RuboCop
2
+ module Facter
3
+ # Central reference point for current version of rubocop-facter
4
+ module Version
5
+ # rubocop:disable all
6
+ VERSION = '0.2.0'
7
+ # rubocop:enable all
8
+
9
+ def self.current
10
+ VERSION
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubocop'
2
+ require 'rubocop/facter/version'
3
+ require 'rubocop/facter/inject'
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module Facter
8
+
9
+ end
10
+ end
11
+ end
12
+ RuboCop::Facter::Inject.defaults!
13
+
14
+ # cops
15
+ require 'rubocop/cop/facter/require_relative'
16
+ require 'rubocop/cop/facter/facter_util'
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rubocop/facter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ # rubocop:disable Metrics/LineLength
8
+ spec.name = 'rubocop-facter'
9
+ spec.version = RuboCop::Facter::Version.current
10
+ spec.authors = ['Zee Alexander']
11
+ spec.email = ['zee@puppet.com']
12
+ spec.license = 'Apache-2.0'
13
+
14
+ spec.summary = 'RuboCop Custom Cops for Puppet/Facter Custom Facts'
15
+ spec.homepage = 'https://github.com/pizzaops/rubocop-facter'
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.required_ruby_version = ['>= 1.9.3']
21
+
22
+ spec.add_dependency 'rubocop', '~> 0.33'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.11'
25
+ spec.add_development_dependency 'rake', '~> 10.0', '< 11'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'pry'
28
+ # rubocop:enable Metrics/LineLength
29
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-facter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Zee Alexander
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-20 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.33'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.33'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
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.0'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '11'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '10.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '11'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: pry
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description:
90
+ email:
91
+ - zee@puppet.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".travis.yml"
99
+ - CHANGELOG.md
100
+ - CODE_OF_CONDUCT.md
101
+ - Gemfile
102
+ - README.md
103
+ - Rakefile
104
+ - config/default.yml
105
+ - lib/rubocop-facter.rb
106
+ - lib/rubocop/cop/facter/facter_util.rb
107
+ - lib/rubocop/cop/facter/require_relative.rb
108
+ - lib/rubocop/facter/inject.rb
109
+ - lib/rubocop/facter/version.rb
110
+ - rubocop-facter.gemspec
111
+ homepage: https://github.com/pizzaops/rubocop-facter
112
+ licenses:
113
+ - Apache-2.0
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 1.9.3
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.4.5.1
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: RuboCop Custom Cops for Puppet/Facter Custom Facts
135
+ test_files: []