onceover-codequality 0.13.0 → 1.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 +4 -4
- data/.github/dependabot.yml +17 -0
- data/.github/labeler.yml +3 -0
- data/.github/release.yml +40 -0
- data/.github/workflows/ci.yaml +52 -0
- data/.github/workflows/labeler.yaml +15 -0
- data/.github/workflows/release.yaml +106 -0
- data/.gitignore +8 -8
- data/.rubocop.yml +12 -0
- data/.rubocop_todo.yml +284 -0
- data/CHANGELOG.md +173 -0
- data/Gemfile +6 -1
- data/README.md +26 -33
- data/Rakefile +16 -0
- data/lib/onceover/codequality/cli.rb +39 -41
- data/lib/onceover/codequality/docs.rb +0 -2
- data/lib/onceover/codequality/environment.rb +3 -4
- data/lib/onceover/codequality/executor.rb +0 -1
- data/lib/onceover/codequality/formatter.rb +1 -3
- data/lib/onceover/codequality/lint.rb +2 -3
- data/lib/onceover/codequality/puppetfile.rb +0 -4
- data/lib/onceover/codequality/syntax.rb +1 -4
- data/lib/onceover/codequality/version.rb +1 -1
- data/lib/onceover/codequality.rb +0 -2
- data/onceover-codequality.gemspec +13 -12
- metadata +32 -28
- data/.travis.yml +0 -4
- data/Gemfile.lock +0 -212
data/CHANGELOG.md
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [v1.0.0](https://github.com/voxpupuli/onceover-codequality/tree/v1.0.0) (2025-07-11)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.12.0...v1.0.0)
|
6
|
+
|
7
|
+
**Breaking changes:**
|
8
|
+
|
9
|
+
- feat: update gemspec, add voxpupuli workflows, rubocop, require ruby 3.2+ [\#37](https://github.com/voxpupuli/onceover-codequality/pull/37) ([rwaffen](https://github.com/rwaffen))
|
10
|
+
|
11
|
+
**Implemented enhancements:**
|
12
|
+
|
13
|
+
- fix: remove obsolete travis, use older bundler to get ci working [\#38](https://github.com/voxpupuli/onceover-codequality/pull/38) ([rwaffen](https://github.com/rwaffen))
|
14
|
+
- Support puppet-syntax 4.x [\#36](https://github.com/voxpupuli/onceover-codequality/pull/36) ([tq-t](https://github.com/tq-t))
|
15
|
+
|
16
|
+
## [v0.12.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.12.0) (2024-05-08)
|
17
|
+
|
18
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.11.0...v0.12.0)
|
19
|
+
|
20
|
+
**Merged pull requests:**
|
21
|
+
|
22
|
+
- Revert back to puppet-lint [\#31](https://github.com/voxpupuli/onceover-codequality/pull/31) ([jordanbreen28](https://github.com/jordanbreen28))
|
23
|
+
|
24
|
+
## [v0.11.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.11.0) (2023-11-12)
|
25
|
+
|
26
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.10.0...v0.11.0)
|
27
|
+
|
28
|
+
**Closed issues:**
|
29
|
+
|
30
|
+
- puppet-lint renamed to puppetlabs-puppet-lint [\#30](https://github.com/voxpupuli/onceover-codequality/issues/30)
|
31
|
+
- rubygems has 0.9.0 whereas the repo has 0.8.0 as latest version/tag [\#27](https://github.com/voxpupuli/onceover-codequality/issues/27)
|
32
|
+
|
33
|
+
## [v0.10.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.10.0) (2023-06-16)
|
34
|
+
|
35
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.9.0...v0.10.0)
|
36
|
+
|
37
|
+
**Merged pull requests:**
|
38
|
+
|
39
|
+
- Support puppet-lint 4.x and puppet-strings 4.x [\#29](https://github.com/voxpupuli/onceover-codequality/pull/29) ([treydock](https://github.com/treydock))
|
40
|
+
|
41
|
+
## [v0.9.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.9.0) (2023-06-16)
|
42
|
+
|
43
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.8.0...v0.9.0)
|
44
|
+
|
45
|
+
**Closed issues:**
|
46
|
+
|
47
|
+
- bump puppet-strings to 3.0 [\#24](https://github.com/voxpupuli/onceover-codequality/issues/24)
|
48
|
+
- bump puppet-lint to 3.1 [\#23](https://github.com/voxpupuli/onceover-codequality/issues/23)
|
49
|
+
- Support for puppet-syntax 3.x needed [\#17](https://github.com/voxpupuli/onceover-codequality/issues/17)
|
50
|
+
|
51
|
+
**Merged pull requests:**
|
52
|
+
|
53
|
+
- Bump git from 1.8.1 to 1.15.0 [\#26](https://github.com/voxpupuli/onceover-codequality/pull/26) ([dependabot[bot]](https://github.com/apps/dependabot))
|
54
|
+
- update puppet-lint and puppet-strings dependencies [\#25](https://github.com/voxpupuli/onceover-codequality/pull/25) ([rwaffen](https://github.com/rwaffen))
|
55
|
+
- Bump puppet from 7.4.0 to 7.12.1 [\#19](https://github.com/voxpupuli/onceover-codequality/pull/19) ([dependabot[bot]](https://github.com/apps/dependabot))
|
56
|
+
|
57
|
+
## [v0.8.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.8.0) (2021-02-11)
|
58
|
+
|
59
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.7.2...v0.8.0)
|
60
|
+
|
61
|
+
**Merged pull requests:**
|
62
|
+
|
63
|
+
- Update dependency for puppet-syntax [\#18](https://github.com/voxpupuli/onceover-codequality/pull/18) ([kreeuwijk](https://github.com/kreeuwijk))
|
64
|
+
- Update rake requirement from ~\> 10.0 to ~\> 13.0 [\#16](https://github.com/voxpupuli/onceover-codequality/pull/16) ([dependabot[bot]](https://github.com/apps/dependabot))
|
65
|
+
|
66
|
+
## [v0.7.2](https://github.com/voxpupuli/onceover-codequality/tree/v0.7.2) (2019-08-13)
|
67
|
+
|
68
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.7.1...v0.7.2)
|
69
|
+
|
70
|
+
**Merged pull requests:**
|
71
|
+
|
72
|
+
- Exclude files in `vendor` during validate\_yaml [\#15](https://github.com/voxpupuli/onceover-codequality/pull/15) ([alexjfisher](https://github.com/alexjfisher))
|
73
|
+
|
74
|
+
## [v0.7.1](https://github.com/voxpupuli/onceover-codequality/tree/v0.7.1) (2019-06-19)
|
75
|
+
|
76
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.7.0...v0.7.1)
|
77
|
+
|
78
|
+
## [v0.7.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.7.0) (2019-06-19)
|
79
|
+
|
80
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.6.0...v0.7.0)
|
81
|
+
|
82
|
+
## [v0.6.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.6.0) (2019-06-18)
|
83
|
+
|
84
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.5.3...v0.6.0)
|
85
|
+
|
86
|
+
## [v0.5.3](https://github.com/voxpupuli/onceover-codequality/tree/v0.5.3) (2019-05-29)
|
87
|
+
|
88
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.5.2...v0.5.3)
|
89
|
+
|
90
|
+
## [v0.5.2](https://github.com/voxpupuli/onceover-codequality/tree/v0.5.2) (2019-05-29)
|
91
|
+
|
92
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.5.1...v0.5.2)
|
93
|
+
|
94
|
+
**Closed issues:**
|
95
|
+
|
96
|
+
- if python-yaml missing yaml validation silently fails [\#14](https://github.com/voxpupuli/onceover-codequality/issues/14)
|
97
|
+
|
98
|
+
## [v0.5.1](https://github.com/voxpupuli/onceover-codequality/tree/v0.5.1) (2019-05-13)
|
99
|
+
|
100
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.5.0...v0.5.1)
|
101
|
+
|
102
|
+
**Merged pull requests:**
|
103
|
+
|
104
|
+
- Configure `PuppetSyntax.exclude_paths` [\#13](https://github.com/voxpupuli/onceover-codequality/pull/13) ([alexjfisher](https://github.com/alexjfisher))
|
105
|
+
- update README.md for --no\_docs flag [\#12](https://github.com/voxpupuli/onceover-codequality/pull/12) ([salderma](https://github.com/salderma))
|
106
|
+
|
107
|
+
## [v0.5.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.5.0) (2019-03-21)
|
108
|
+
|
109
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.4.2...v0.5.0)
|
110
|
+
|
111
|
+
**Closed issues:**
|
112
|
+
|
113
|
+
- \[bug\] invalid yaml doesn't fail the sytax check [\#11](https://github.com/voxpupuli/onceover-codequality/issues/11)
|
114
|
+
|
115
|
+
## [v0.4.2](https://github.com/voxpupuli/onceover-codequality/tree/v0.4.2) (2018-12-10)
|
116
|
+
|
117
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.4.1...v0.4.2)
|
118
|
+
|
119
|
+
**Closed issues:**
|
120
|
+
|
121
|
+
- The .puppet-lint.rc file is ignored [\#8](https://github.com/voxpupuli/onceover-codequality/issues/8)
|
122
|
+
|
123
|
+
**Merged pull requests:**
|
124
|
+
|
125
|
+
- Call the rake syntax target directly [\#10](https://github.com/voxpupuli/onceover-codequality/pull/10) ([franknarf8](https://github.com/franknarf8))
|
126
|
+
- lib/onceover/codequality/lint.rb : Call puppet-lint from the root of … [\#9](https://github.com/voxpupuli/onceover-codequality/pull/9) ([franknarf8](https://github.com/franknarf8))
|
127
|
+
|
128
|
+
## [v0.4.1](https://github.com/voxpupuli/onceover-codequality/tree/v0.4.1) (2018-11-12)
|
129
|
+
|
130
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.4.0...v0.4.1)
|
131
|
+
|
132
|
+
**Closed issues:**
|
133
|
+
|
134
|
+
- options dont work! [\#7](https://github.com/voxpupuli/onceover-codequality/issues/7)
|
135
|
+
|
136
|
+
## [v0.4.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.4.0) (2018-11-11)
|
137
|
+
|
138
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.3.0...v0.4.0)
|
139
|
+
|
140
|
+
**Closed issues:**
|
141
|
+
|
142
|
+
- do syntax check before lint [\#6](https://github.com/voxpupuli/onceover-codequality/issues/6)
|
143
|
+
- \[feature\] Enable lint options [\#5](https://github.com/voxpupuli/onceover-codequality/issues/5)
|
144
|
+
|
145
|
+
## [v0.3.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.3.0) (2018-08-27)
|
146
|
+
|
147
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.2.0...v0.3.0)
|
148
|
+
|
149
|
+
**Closed issues:**
|
150
|
+
|
151
|
+
- switch document generation to reference format [\#4](https://github.com/voxpupuli/onceover-codequality/issues/4)
|
152
|
+
- Add a check for puppetfile syntax [\#3](https://github.com/voxpupuli/onceover-codequality/issues/3)
|
153
|
+
- getting strange errors in CI-container... [\#2](https://github.com/voxpupuli/onceover-codequality/issues/2)
|
154
|
+
|
155
|
+
**Merged pull requests:**
|
156
|
+
|
157
|
+
- update puppet strings to version 2 [\#1](https://github.com/voxpupuli/onceover-codequality/pull/1) ([Nekototori](https://github.com/Nekototori))
|
158
|
+
|
159
|
+
## [v0.2.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.2.0) (2017-09-22)
|
160
|
+
|
161
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.1.1...v0.2.0)
|
162
|
+
|
163
|
+
## [v0.1.1](https://github.com/voxpupuli/onceover-codequality/tree/v0.1.1) (2017-09-12)
|
164
|
+
|
165
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/v0.1.0...v0.1.1)
|
166
|
+
|
167
|
+
## [v0.1.0](https://github.com/voxpupuli/onceover-codequality/tree/v0.1.0) (2017-09-12)
|
168
|
+
|
169
|
+
[Full Changelog](https://github.com/voxpupuli/onceover-codequality/compare/de308542fc264aa2e96098704334d6e4b14c9034...v0.1.0)
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in onceover-helloworld.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
group :release, optional: true do
|
9
|
+
gem 'faraday-retry', require: false
|
10
|
+
gem 'github_changelog_generator', require: false
|
11
|
+
end
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Onceover::CodeQuality
|
2
2
|
|
3
|
-
This is the Code Quality plugin for [Onceover](https://github.com/
|
3
|
+
This is the Code Quality plugin for [Onceover](https://github.com/voxpupuli/onceover), _The gateway drug to automated infrastructure testing with Puppet_
|
4
4
|
|
5
5
|
## What does it do?
|
6
|
+
|
6
7
|
The plugin checks your control repository for:
|
7
8
|
|
8
9
|
* Linting
|
@@ -17,7 +18,7 @@ For sure you can hack around with rake/make and hack something up each time but
|
|
17
18
|
Install the `onceover-codequality` gem by adding it to your `Gemfile` or by running the following command:
|
18
19
|
|
19
20
|
```shell
|
20
|
-
|
21
|
+
gem install onceover-codequality
|
21
22
|
```
|
22
23
|
|
23
24
|
## Usage
|
@@ -26,46 +27,46 @@ Installing the codequality gem creates a new item within onceover's `run` comman
|
|
26
27
|
|
27
28
|
The command will return `1` to the system if any tests fail, otherwise `0`, which makes it perfect to include in build pipelines.
|
28
29
|
|
29
|
-
|
30
|
-
**Check all code in the control repository for Lint and Syntax errors**
|
30
|
+
### Check all code in the control repository for Lint and Syntax errors
|
31
31
|
|
32
32
|
```shell
|
33
|
-
|
33
|
+
onceover run codequality
|
34
34
|
```
|
35
35
|
|
36
|
-
|
36
|
+
### Skip Lint check
|
37
37
|
|
38
38
|
```shell
|
39
|
-
|
39
|
+
onceover run codequality --no_lint
|
40
40
|
```
|
41
41
|
|
42
|
-
|
42
|
+
### Skip Puppet syntax check
|
43
43
|
|
44
44
|
```shell
|
45
|
-
|
45
|
+
onceover run codequality --no_syntax
|
46
46
|
```
|
47
47
|
|
48
|
-
|
48
|
+
### Skip Puppetfile syntax check
|
49
49
|
|
50
50
|
```shell
|
51
|
-
|
51
|
+
onceover run codequality --no_puppetfile
|
52
52
|
```
|
53
53
|
|
54
|
-
|
54
|
+
### Skip documentation generation
|
55
55
|
|
56
56
|
```shell
|
57
|
-
|
57
|
+
onceover run codequality --no_docs
|
58
58
|
```
|
59
59
|
|
60
|
-
|
60
|
+
### Use custom lint setting
|
61
|
+
|
61
62
|
Create a file `puppet-lint.rc` in the directory you run `onceover codequality`
|
62
63
|
from and it will be automatically used by Puppet Lint. If missing, the built-in
|
63
|
-
defaults from `lib/onceover/codequality/lint.rb` will be used.
|
64
|
+
defaults from `lib/onceover/codequality/lint.rb` will be used.
|
64
65
|
|
65
66
|
|
66
67
|
## Sample output
|
67
68
|
|
68
|
-
|
69
|
+
### All clear
|
69
70
|
|
70
71
|
```shell
|
71
72
|
$ onceover run codequality
|
@@ -79,7 +80,7 @@ INFO -> Checking syntax...
|
|
79
80
|
INFO -> Code Quality tests passed, have a nice day
|
80
81
|
```
|
81
82
|
|
82
|
-
|
83
|
+
### Lint and syntax errors
|
83
84
|
|
84
85
|
```shell
|
85
86
|
$ onceover run codequality
|
@@ -105,7 +106,7 @@ $ echo $?
|
|
105
106
|
|
106
107
|
I get these errors when I run `onceover run codequality` but everything seems to work, what gives?:
|
107
108
|
|
108
|
-
```
|
109
|
+
```shell
|
109
110
|
WARN: Unresolved specs during Gem::Specification.reset:
|
110
111
|
rake (>= 0)
|
111
112
|
hiera (< 4, >= 2.0)
|
@@ -117,14 +118,14 @@ Please report a bug if this causes problems.
|
|
117
118
|
Beats me - something to do with rubygems. The best way to beat this message is to use [bundler](https://github.com/bundler/bundler) which basically you should already be doing anyway (for your own sanity):
|
118
119
|
|
119
120
|
```shell
|
120
|
-
|
121
|
+
bundle exec onceover run codequality
|
121
122
|
```
|
122
123
|
|
123
124
|
**What are you using under-the-hood?**
|
124
125
|
|
125
126
|
* [puppet-lint](https://github.com/rodjek/puppet-lint)
|
126
127
|
* [puppet-syntax](https://github.com/voxpupuli/puppet-syntax)
|
127
|
-
* [puppet-strings](https://github.com/puppetlabs/puppet-strings/)
|
128
|
+
* [puppet-strings](https://github.com/puppetlabs/puppet-strings/)
|
128
129
|
* [r10k](https://github.com/puppetlabs/r10k/)
|
129
130
|
|
130
131
|
## Development
|
@@ -139,19 +140,11 @@ Have a look at [helloworld plugin](https://github.com/declarativesystems/onceove
|
|
139
140
|
bundle exec rake spec
|
140
141
|
```
|
141
142
|
|
142
|
-
### How to build gem
|
143
|
-
|
144
|
-
```shell
|
145
|
-
gem build onceover-codequality.gemspec
|
146
|
-
```
|
147
|
-
|
148
|
-
### How to upload to rubygems.org
|
149
|
-
|
150
|
-
```shell
|
151
|
-
gem push XXX.gem
|
152
|
-
```
|
153
|
-
|
154
143
|
## Contributing
|
155
144
|
|
156
|
-
* [This project is looking for a maintainer](https://github.com/declarativesystems/onceover-codequality/issues/21)
|
157
145
|
* Bug reports and pull requests welcome
|
146
|
+
|
147
|
+
## Transfer Notice
|
148
|
+
|
149
|
+
This project was originally authored by dylanratcliffe. The maintainer preferred that Vox Pupuli take ownership of the project for future improvement and maintenance.
|
150
|
+
Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of voxpupuli/onceover-codequality.
|
data/Rakefile
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require 'voxpupuli/test/rake'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
7
|
task :default => :spec
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'rubygems'
|
11
|
+
require 'github_changelog_generator/task'
|
12
|
+
rescue LoadError
|
13
|
+
# Do nothing if no required gem installed
|
14
|
+
else
|
15
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
16
|
+
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions]
|
17
|
+
config.user = 'voxpupuli'
|
18
|
+
config.project = 'onceover-codequality'
|
19
|
+
gem_version = Gem::Specification.load("#{config.project}.gemspec").version
|
20
|
+
config.future_release = "v#{gem_version}"
|
21
|
+
end
|
22
|
+
end
|
@@ -8,60 +8,58 @@ require "onceover/codequality/formatter"
|
|
8
8
|
class Onceover
|
9
9
|
module CodeQuality
|
10
10
|
class CLI
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
description <<-DESCRIPTION
|
11
|
+
def self.command
|
12
|
+
@cmd ||= Cri::Command.define do
|
13
|
+
name 'codequality'
|
14
|
+
usage 'codequality [--no-syntax] [--no-lint] [--no-docs] [--html-docs] [--no-puppetfile]'
|
15
|
+
summary "Code Quality checking for onceover"
|
16
|
+
description <<-DESCRIPTION
|
18
17
|
Check files in your Control Repository for Lint and Syntax errors
|
19
|
-
|
20
|
-
|
21
|
-
flag nil, :no_lint, 'Do not check for lint errors', :argument => :optional
|
22
|
-
flag nil, :no_puppetfile, 'Do not check Puppetfile for syntax errors', :argument => :optional
|
23
|
-
flag nil, :no_syntax, 'Do not check for syntax errors', :argument => :optional
|
24
|
-
flag nil, :no_docs, 'Do not generate documentation (puppet-strings) for local modules', :argument => :optional
|
25
|
-
flag nil, :html_docs, 'Generate docs in HTML format instead of markdown', :argument => :optional
|
18
|
+
DESCRIPTION
|
26
19
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
html_docs = opts[:html_docs] || false
|
33
|
-
status = true
|
20
|
+
flag nil, :no_lint, 'Do not check for lint errors', :argument => :optional
|
21
|
+
flag nil, :no_puppetfile, 'Do not check Puppetfile for syntax errors', :argument => :optional
|
22
|
+
flag nil, :no_syntax, 'Do not check for syntax errors', :argument => :optional
|
23
|
+
flag nil, :no_docs, 'Do not generate documentation (puppet-strings) for local modules', :argument => :optional
|
24
|
+
flag nil, :html_docs, 'Generate docs in HTML format instead of markdown', :argument => :optional
|
34
25
|
|
35
|
-
|
26
|
+
run do |opts, args, cmd|
|
27
|
+
no_lint = opts[:no_lint] || false
|
28
|
+
no_syntax = opts[:no_syntax] || false
|
29
|
+
no_docs = opts[:no_docs] || false
|
30
|
+
no_puppetfile = opts[:no_puppetfile] || false
|
31
|
+
html_docs = opts[:html_docs] || false
|
32
|
+
status = true
|
36
33
|
|
37
|
-
|
38
|
-
status &= Onceover::CodeQuality::Puppetfile.puppetfile
|
39
|
-
end
|
34
|
+
logger.info "Running Code Quality tests"
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
if !no_puppetfile
|
37
|
+
status &= Onceover::CodeQuality::Puppetfile.puppetfile
|
38
|
+
end
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
if !no_syntax
|
41
|
+
status &= Onceover::CodeQuality::Syntax.puppet
|
42
|
+
end
|
48
43
|
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
if !no_lint
|
45
|
+
status &= Onceover::CodeQuality::Lint.puppet
|
46
|
+
end
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
48
|
+
if !no_docs
|
49
|
+
status &= Onceover::CodeQuality::Docs.puppet_strings(html_docs)
|
50
|
+
end
|
51
|
+
|
52
|
+
if status
|
53
|
+
logger.info "Code Quality tests PASSED, have a nice day"
|
54
|
+
else
|
55
|
+
logger.error "Code Quality tests FAILED, see previous error(s)"
|
56
|
+
exit 1
|
59
57
|
end
|
60
58
|
end
|
61
59
|
end
|
62
60
|
end
|
61
|
+
end
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
Onceover::CLI::Run.command.add_command(Onceover::CodeQuality::CLI.command)
|
67
|
-
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class Onceover
|
2
2
|
module CodeQuality
|
3
3
|
module Environment
|
4
|
-
|
5
4
|
ENVIRONMENT_CONF = "environment.conf"
|
6
5
|
|
7
6
|
# Latest best practice is to change the name of `site` to be
|
@@ -9,7 +8,7 @@ class Onceover
|
|
9
8
|
# to extract this...
|
10
9
|
def self.get_site_dirs()
|
11
10
|
if File.exist?(ENVIRONMENT_CONF)
|
12
|
-
#modulepath = site-modules:modules:$basemodulepath
|
11
|
+
# modulepath = site-modules:modules:$basemodulepath
|
13
12
|
modulepath = open(ENVIRONMENT_CONF) { |f| f.each_line.find { |line| line.include?("modulepath") } }
|
14
13
|
|
15
14
|
begin
|
@@ -17,8 +16,8 @@ class Onceover
|
|
17
16
|
# reject any elements containing interpolation or referencing modules
|
18
17
|
# loaded by r10k
|
19
18
|
e =~ /\$/ || e == "modules" || e =~ /[\\.\/]/
|
20
|
-
}.map {
|
21
|
-
|
19
|
+
}.map { |e|
|
20
|
+
e.strip
|
22
21
|
}
|
23
22
|
rescue NoMethodError => e
|
24
23
|
raise "Malformed environment configuration: #{ENVIRONMENT_CONF}"
|
@@ -1,16 +1,14 @@
|
|
1
1
|
class Onceover
|
2
2
|
module CodeQuality
|
3
3
|
module Formatter
|
4
|
-
|
5
4
|
START_TEST = "Checking".freeze
|
6
5
|
MSG_TEST_OK = "...OK".freeze
|
7
6
|
|
8
|
-
|
9
7
|
def self.start_test(test_name)
|
10
8
|
logger.info "Checking #{test_name}..."
|
11
9
|
end
|
12
10
|
|
13
|
-
def self.end_test(output, ok, show_output=false)
|
11
|
+
def self.end_test(output, ok, show_output = false)
|
14
12
|
if !ok || show_output
|
15
13
|
output.each_line do |line|
|
16
14
|
logger.info("\t#{line.chomp}")
|
@@ -1,14 +1,13 @@
|
|
1
1
|
class Onceover
|
2
2
|
module CodeQuality
|
3
3
|
module Lint
|
4
|
-
|
5
4
|
# Apply linting to the manifests directory and each module under `site`
|
6
5
|
LINT_PATHS = [
|
7
6
|
"manifests",
|
8
7
|
]
|
9
8
|
|
10
9
|
# use our default options unless user has created own settings
|
11
|
-
if !
|
10
|
+
if !File.exist? ".puppet-lint.rc"
|
12
11
|
LINT_OPTIONS = [
|
13
12
|
"--relative",
|
14
13
|
"--fail-on-warnings",
|
@@ -27,7 +26,7 @@ class Onceover
|
|
27
26
|
# wait until runtime to scan directories for unit tests
|
28
27
|
lint_paths = LINT_PATHS.concat(
|
29
28
|
CodeQuality::Environment.get_site_dirs.each { |site_dir|
|
30
|
-
Dir.glob("#{site_dir}/*").select { |f| File.directory? f}
|
29
|
+
Dir.glob("#{site_dir}/*").select { |f| File.directory? f }
|
31
30
|
}
|
32
31
|
)
|
33
32
|
lint_paths.each { |p|
|
@@ -1,8 +1,6 @@
|
|
1
|
-
|
2
1
|
class Onceover
|
3
2
|
module CodeQuality
|
4
3
|
module Syntax
|
5
|
-
|
6
4
|
def self.puppet
|
7
5
|
status = true
|
8
6
|
|
@@ -19,7 +17,7 @@ class Onceover
|
|
19
17
|
PuppetSyntax.exclude_paths = ['vendor/**/*','spec/templates/*.erb']
|
20
18
|
Rake::Task['syntax'].invoke
|
21
19
|
RUBY_CODE
|
22
|
-
#output, s = Open3.capture2e("ruby", "-e", inline_ruby)
|
20
|
+
# output, s = Open3.capture2e("ruby", "-e", inline_ruby)
|
23
21
|
output, ok = CodeQuality::Executor.run("ruby", "-e", inline_ruby)
|
24
22
|
status &= ok
|
25
23
|
CodeQuality::Formatter.end_test(output, ok)
|
@@ -54,4 +52,3 @@ class Onceover
|
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
57
|
-
|
data/lib/onceover/codequality.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path("../lib", __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require "onceover/codequality/version"
|
@@ -6,26 +7,26 @@ require "onceover/codequality/version"
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = "onceover-codequality"
|
8
9
|
spec.version = Onceover::CodeQuality::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
10
|
+
spec.authors = ["Dylan Ratcliffe", 'Vox Pupuli']
|
11
|
+
spec.email = ["voxpupuli@groups.io"]
|
11
12
|
spec.license = "Apache-2.0"
|
12
13
|
|
13
14
|
spec.summary = %q{Lint and syntax validation for onceover}
|
14
|
-
spec.homepage = "https://github.com/
|
15
|
+
spec.homepage = "https://github.com/voxpupuli/onceover-codequality"
|
15
16
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
17
|
-
f.match(%r{^(test|spec|features)/})
|
18
|
-
end
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
18
|
spec.bindir = "exe"
|
20
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
20
|
spec.require_paths = ["lib"]
|
22
21
|
|
22
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.2')
|
23
|
+
|
23
24
|
spec.add_development_dependency "bundler", "~> 2.4"
|
24
|
-
spec.add_development_dependency "rake", "~> 13.
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.
|
25
|
+
spec.add_development_dependency "rake", "~> 13.3"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.13"
|
26
27
|
|
27
|
-
spec.add_runtime_dependency 'onceover', '~>
|
28
|
-
spec.add_runtime_dependency 'puppet-
|
29
|
-
spec.add_runtime_dependency 'puppet-
|
30
|
-
spec.add_runtime_dependency 'puppet-
|
28
|
+
spec.add_runtime_dependency 'onceover', '~> 5.0'
|
29
|
+
spec.add_runtime_dependency 'puppet-lint', '~> 4.3'
|
30
|
+
spec.add_runtime_dependency 'puppet-strings', '~> 5.0'
|
31
|
+
spec.add_runtime_dependency 'puppet-syntax', '~> 6.0'
|
31
32
|
end
|