onceover-codequality 0.5.3 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62bf60e630876715685b9a6cf9c92f7664481b86ce6a3fc2544146891d416a13
4
- data.tar.gz: 690ee5d1ff1655aca38c26c05711e2bbe401c01686c9a981c4040e025241a01b
3
+ metadata.gz: ee41694d81a21ab44a8d2c7b6630740ac8caa219d64e2bbcf14fadf1f9d919af
4
+ data.tar.gz: a3a16cc00241852ee07f0cf162cdd2fb10187c9218912ef814f3f13dcd6ce44d
5
5
  SHA512:
6
- metadata.gz: ae234b3b18058e23d409dee9d3fcbe31c1df4b1d047386e96d940f066aafab0ebdda10ac2ccc1017e7f8acc60709b25b8a1c98062bf58f6f91327ea15132dece
7
- data.tar.gz: efe6218964f4329e9e20ab2546b744b851a5daab8e334257f8dae9a9cb757bfed6a4ac0b0bcd1dbebd8847fe7cb1a8846e8fd5806eb57ec5e2d588459a20a496
6
+ metadata.gz: 6f63484487dc3d9211652a827648879b1d8c9dc76e7720b959dff30e17357061bd249cc5eb1fc5a22ac3fe714809e36bdd2cff65f72e4ddf2ac6dedcb6b1ea78
7
+ data.tar.gz: 75e20bdd744457c8783c903f290cc4238d83f3d44479db02146f00f666daacab8041cb7d0abead69df1b468ed0e441b488cb0863a48f89d5b2e3e021b8757f65
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
2
+ **/.yardoc
3
+ **/REFERENCE.md
4
+ /spec/fixtures/**/doc
4
5
  /_yardoc/
5
6
  /coverage/
6
7
  /doc/
@@ -12,3 +13,4 @@
12
13
  .rspec_status
13
14
  /.idea
14
15
  *.gem
16
+
data/Gemfile.lock ADDED
@@ -0,0 +1,143 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ onceover-codequality (0.6.0)
5
+ onceover (~> 3)
6
+ puppet-lint (~> 2)
7
+ puppet-strings (~> 2)
8
+ puppet-syntax (~> 2)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ backticks (1.0.2)
14
+ blockenspiel (0.5.0)
15
+ colored (1.2)
16
+ cri (2.15.6)
17
+ deep_merge (1.2.1)
18
+ diff-lcs (1.3)
19
+ facter (2.5.1)
20
+ faraday (0.13.1)
21
+ multipart-post (>= 1.2, < 3)
22
+ faraday_middleware (0.12.2)
23
+ faraday (>= 0.7.4, < 1.0)
24
+ fast_gettext (1.1.2)
25
+ gettext (3.2.9)
26
+ locale (>= 2.0.5)
27
+ text (>= 1.3.0)
28
+ gettext-setup (0.30)
29
+ fast_gettext (~> 1.1.0)
30
+ gettext (>= 3.0.2)
31
+ locale
32
+ git (1.5.0)
33
+ hiera (3.5.0)
34
+ hocon (1.2.5)
35
+ httpclient (2.8.3)
36
+ json (2.2.0)
37
+ little-plugger (1.1.4)
38
+ locale (2.1.2)
39
+ log4r (1.1.10)
40
+ logging (2.2.2)
41
+ little-plugger (~> 1.1)
42
+ multi_json (~> 1.10)
43
+ metaclass (0.0.4)
44
+ minitar (0.8)
45
+ mocha (1.9.0)
46
+ metaclass (~> 0.0.1)
47
+ multi_json (1.13.1)
48
+ multipart-post (2.1.1)
49
+ onceover (3.13.4)
50
+ backticks (>= 1.0.2)
51
+ colored (~> 1.2)
52
+ cri (>= 2.6)
53
+ deep_merge (>= 1.0.0)
54
+ git
55
+ json (>= 1.8.2)
56
+ logging (>= 2.0.0)
57
+ parallel_tests (>= 2.0.0)
58
+ puppet (>= 3.4.0)
59
+ puppetlabs_spec_helper (>= 0.4.0)
60
+ r10k (>= 2.1.0)
61
+ rake (>= 10.0.0)
62
+ rspec (>= 3.0.0)
63
+ rspec-puppet (>= 2.4.0)
64
+ rspec_junit_formatter (>= 0.2.0)
65
+ table_print (>= 1.0.0)
66
+ versionomy (>= 0.5.0)
67
+ parallel (1.17.0)
68
+ parallel_tests (2.29.1)
69
+ parallel
70
+ pathspec (0.2.1)
71
+ puppet (6.4.2)
72
+ facter (> 2.0.1, < 4)
73
+ fast_gettext (~> 1.1.2)
74
+ hiera (>= 3.2.1, < 4)
75
+ httpclient (~> 2.8)
76
+ locale (~> 2.1)
77
+ multi_json (~> 1.10)
78
+ puppet-resource_api (~> 1.5)
79
+ semantic_puppet (~> 1.0)
80
+ puppet-lint (2.3.6)
81
+ puppet-resource_api (1.8.3)
82
+ hocon (>= 1.0)
83
+ puppet-strings (2.2.0)
84
+ rgen
85
+ yard (~> 0.9.5)
86
+ puppet-syntax (2.4.3)
87
+ rake
88
+ puppet_forge (2.2.9)
89
+ faraday (>= 0.9.0, < 0.14.0)
90
+ faraday_middleware (>= 0.9.0, < 0.13.0)
91
+ gettext-setup (~> 0.11)
92
+ minitar
93
+ semantic_puppet (~> 1.0)
94
+ puppetlabs_spec_helper (2.14.1)
95
+ mocha (~> 1.0)
96
+ pathspec (~> 0.2.1)
97
+ puppet-lint (~> 2.0)
98
+ puppet-syntax (~> 2.0)
99
+ rspec-puppet (~> 2.0)
100
+ r10k (3.3.0)
101
+ colored (= 1.2)
102
+ cri (= 2.15.6)
103
+ gettext-setup (~> 0.24)
104
+ log4r (= 1.1.10)
105
+ multi_json (~> 1.10)
106
+ puppet_forge (~> 2.2.8)
107
+ rake (10.5.0)
108
+ rgen (0.8.2)
109
+ rspec (3.8.0)
110
+ rspec-core (~> 3.8.0)
111
+ rspec-expectations (~> 3.8.0)
112
+ rspec-mocks (~> 3.8.0)
113
+ rspec-core (3.8.1)
114
+ rspec-support (~> 3.8.0)
115
+ rspec-expectations (3.8.4)
116
+ diff-lcs (>= 1.2.0, < 2.0)
117
+ rspec-support (~> 3.8.0)
118
+ rspec-mocks (3.8.1)
119
+ diff-lcs (>= 1.2.0, < 2.0)
120
+ rspec-support (~> 3.8.0)
121
+ rspec-puppet (2.7.5)
122
+ rspec
123
+ rspec-support (3.8.2)
124
+ rspec_junit_formatter (0.4.1)
125
+ rspec-core (>= 2, < 4, != 2.12.0)
126
+ semantic_puppet (1.0.2)
127
+ table_print (1.5.6)
128
+ text (1.3.1)
129
+ versionomy (0.5.0)
130
+ blockenspiel (~> 0.5)
131
+ yard (0.9.19)
132
+
133
+ PLATFORMS
134
+ ruby
135
+
136
+ DEPENDENCIES
137
+ bundler (~> 2.0)
138
+ onceover-codequality!
139
+ rake (~> 10.0)
140
+ rspec (~> 3.0)
141
+
142
+ BUNDLED WITH
143
+ 2.0.1
@@ -3,7 +3,6 @@ require "onceover/codequality/cli"
3
3
 
4
4
  class Onceover
5
5
  module CodeQuality
6
- # Your code goes here...
7
6
  end
8
7
  end
9
8
 
@@ -2,6 +2,8 @@ require "onceover/codequality/lint"
2
2
  require "onceover/codequality/syntax"
3
3
  require "onceover/codequality/docs"
4
4
  require "onceover/codequality/puppetfile"
5
+ require "onceover/codequality/executor"
6
+ require "onceover/codequality/formatter"
5
7
  class Onceover
6
8
  module CodeQuality
7
9
  class CLI
@@ -29,6 +31,8 @@ class Onceover
29
31
  html_docs = opts[:html_docs] || false
30
32
  status = true
31
33
 
34
+ logger.info "Running Code Quality tests"
35
+
32
36
  if ! no_puppetfile
33
37
  status &= Onceover::CodeQuality::Puppetfile.puppetfile
34
38
  end
@@ -46,9 +50,9 @@ class Onceover
46
50
  end
47
51
 
48
52
  if status
49
- logger.info "Code Quality tests passed, have a nice day"
53
+ logger.info "Code Quality tests PASSED, have a nice day"
50
54
  else
51
- logger.error "Code Quality tests failed, see previous error"
55
+ logger.error "Code Quality tests FAILED, see previous error(s)"
52
56
  exit 1
53
57
  end
54
58
  end
@@ -6,18 +6,16 @@ class Onceover
6
6
  LOCAL_MOD_DIR = "site"
7
7
 
8
8
  def self.puppet_strings(html_docs)
9
- logger.info "Generating documentation..."
10
9
  status = true
11
- format = html_docs ? "html" : "markdown"
10
+ format = html_docs ? "--markup html" : "--format markdown"
12
11
  if Dir.exist?(LOCAL_MOD_DIR)
13
12
  Dir.glob("#{LOCAL_MOD_DIR}/*/") { |dir|
14
13
  Dir.chdir(dir) {
14
+ CodeQuality::Formatter.start_test("Generate documentation in #{dir}")
15
15
  # puppet strings prints useful metrics so don't swallow its output
16
- s = system("puppet strings generate --format #{format}")
17
- if ! s
18
- logger.error("Error running puppet strings - see previous output")
19
- end
20
- status &= s
16
+ output, ok = CodeQuality::Executor.run("puppet strings generate #{format}")
17
+ status &= ok
18
+ CodeQuality::Formatter.end_test(output, ok, true)
21
19
  }
22
20
  }
23
21
  end
@@ -0,0 +1,14 @@
1
+ class Onceover
2
+ module CodeQuality
3
+ module Executor
4
+
5
+ # Capture all program output and check the exit status was zero
6
+ def self.run(*command)
7
+ output, s = Open3.capture2e(*command)
8
+ ok = s.exitstatus.zero?
9
+
10
+ return output, ok
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ class Onceover
2
+ module CodeQuality
3
+ module Formatter
4
+
5
+ START_TEST = "Checking".freeze
6
+ MSG_TEST_OK = "...OK".freeze
7
+
8
+
9
+ def self.start_test(test_name)
10
+ logger.info "Checking #{test_name}..."
11
+ end
12
+
13
+ def self.end_test(output, ok, show_output=false)
14
+ if !ok || show_output
15
+ output.each_line do |line|
16
+ logger.info("\t#{line.chomp}")
17
+ end
18
+ end
19
+
20
+ if ok
21
+ logger.info "...OK"
22
+ else
23
+ logger.error "...FAILED"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -5,7 +5,7 @@ class Onceover
5
5
  # Apply linting to the manifests directory and each module under `site`
6
6
  LINT_PATHS = [
7
7
  "manifests",
8
- ].concat(Dir.glob('site/*').select {|f| File.directory? f})
8
+ ]
9
9
 
10
10
  # use our default options unless user has created own settings
11
11
  if ! File.exist? ".puppet-lint.rc"
@@ -23,15 +23,18 @@ class Onceover
23
23
 
24
24
  def self.puppet
25
25
  status = true
26
- LINT_PATHS.each { |p|
27
- if Dir.exists?(p)
28
- logger.info("checking lint in #{p}...")
29
- if ! system("puppet-lint #{LINT_OPTIONS.join ' '} #{p}")
30
- status = false
31
- else
32
- logger.info("...ok")
33
- end
34
26
 
27
+ # wait until runtime to scan directories for unit tests
28
+ lint_paths = LINT_PATHS.concat(
29
+ Dir.glob('site/*')
30
+ .select { |f| File.directory? f}
31
+ )
32
+ lint_paths.each { |p|
33
+ if Dir.exists?(p)
34
+ CodeQuality::Formatter.start_test("lint in #{p}")
35
+ output, ok = CodeQuality::Executor.run("puppet-lint #{LINT_OPTIONS.join ' '} #{p}")
36
+ status &= ok
37
+ CodeQuality::Formatter.end_test(output, ok)
35
38
  end
36
39
  }
37
40
 
@@ -6,16 +6,12 @@ class Onceover
6
6
  def self.puppetfile
7
7
  status = true
8
8
  if File.exist?("Puppetfile")
9
- logger.info("Checking Puppetfile...")
10
- output, s = Open3.capture2e("r10k puppetfile check")
11
- ok = s.exitstatus.zero?
9
+ CodeQuality::Formatter.start_test("Puppetfile")
10
+ output, ok = CodeQuality::Executor.run("r10k puppetfile check")
11
+
12
12
  status &= ok
13
13
 
14
- if ok
15
- logger.info("...ok")
16
- else
17
- logger.error("Puppetfile validation failed: #{output}")
18
- end
14
+ CodeQuality::Formatter.end_test(output, ok)
19
15
  else
20
16
  logger.warn("No Puppetfile found... continuing")
21
17
  end
@@ -1,4 +1,4 @@
1
- require 'open3'
1
+
2
2
  class Onceover
3
3
  module CodeQuality
4
4
  module Syntax
@@ -10,7 +10,7 @@ class Onceover
10
10
  # puppet-syntax
11
11
  #
12
12
 
13
- logger.info("Checking syntax using puppet-syntax rake task...")
13
+ CodeQuality::Formatter.start_test("puppet-syntax rake task")
14
14
  # puppet-syntax seems to assign $stdout/$stderr internally in ways that
15
15
  # prevent capturing output. As a nasty hack, run it as inline ruby and
16
16
  # capture the output from the process...
@@ -19,15 +19,10 @@ class Onceover
19
19
  PuppetSyntax.exclude_paths = ['vendor/**/*','spec/templates/*.erb']
20
20
  Rake::Task['syntax'].invoke
21
21
  RUBY_CODE
22
- output, s = Open3.capture2e("ruby", "-e", inline_ruby)
23
- ok = s.exitstatus.zero?
22
+ #output, s = Open3.capture2e("ruby", "-e", inline_ruby)
23
+ output, ok = CodeQuality::Executor.run("ruby", "-e", inline_ruby)
24
24
  status &= ok
25
-
26
- if ok
27
- logger.info("...ok")
28
- else
29
- logger.error("puppet-syntax validation failed: #{output}")
30
- end
25
+ CodeQuality::Formatter.end_test(output, ok)
31
26
 
32
27
  #
33
28
  # python yaml
@@ -45,17 +40,11 @@ class Onceover
45
40
  # users would be advised to fix the file, so lets _also_ validate yaml
46
41
  # files with python if available on our path...
47
42
  if system("python --version && python -c 'import yaml'", :err => File::NULL)
48
- logger.info("Running additional python YAML validation")
43
+ CodeQuality::Formatter.start_test("Additional python YAML validation")
49
44
  script = File.join(File.dirname(File.expand_path(__FILE__)), "../../../res/validate_yaml.py")
50
- output, s = Open3.capture2e("python #{script}")
51
- ok = s.exitstatus.zero?
45
+ output, ok = CodeQuality::Executor.run("python #{script}")
52
46
  status &= ok
53
-
54
- if ok
55
- logger.info("...ok")
56
- else
57
- logger.error("Puppetfile validation failed: #{output}")
58
- end
47
+ CodeQuality::Formatter.end_test(output, ok)
59
48
  else
60
49
  logger.warn("Please install python and pyyaml for enhanced YAML validation (pip install pyyaml)")
61
50
  end
@@ -1,5 +1,5 @@
1
1
  class Onceover
2
2
  module CodeQuality
3
- VERSION = "0.5.3"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.15"
23
+ spec.add_development_dependency "bundler", "~> 2.0"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onceover-codequality
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Declarative Systems
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2019-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.15'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -119,6 +119,7 @@ files:
119
119
  - ".rspec"
120
120
  - ".travis.yml"
121
121
  - Gemfile
122
+ - Gemfile.lock
122
123
  - LICENSE
123
124
  - README.md
124
125
  - Rakefile
@@ -127,6 +128,8 @@ files:
127
128
  - lib/onceover/codequality.rb
128
129
  - lib/onceover/codequality/cli.rb
129
130
  - lib/onceover/codequality/docs.rb
131
+ - lib/onceover/codequality/executor.rb
132
+ - lib/onceover/codequality/formatter.rb
130
133
  - lib/onceover/codequality/lint.rb
131
134
  - lib/onceover/codequality/puppetfile.rb
132
135
  - lib/onceover/codequality/syntax.rb